Results 1 to 3 of 3

Thread: Script mill

  1. #1
    ... connecting
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Script mill

    Hey guys,

    I've have a script here to make a mill rotate. This works good but i want to change the script a little bit. So when you activate the trigger, the mill should stop rotating after e.g 1min, so you have to reactivate the trigger.
    Could anyone help me here?
    Code:
    molen()
    {
       trig = getent("trigger_windmolen", "targetname");
       
       while(1)
          {
             trig waittill ("trigger",user);
             rotate_obj = getentarray("windmolen","targetname");
             if(isdefined(rotate_obj))
                {
                   for(i=0;i<rotate_obj.size;i++)
                      {
                         rotate_obj[i] thread ra_rotate();
                      }
                }
          }
    }
    
    ra_rotate()
    {
       if (!isdefined(self.speed))
       self.speed = 5;
       if (!isdefined(self.script_noteworthy))
       self.script_noteworthy = "x";
    
       while(true)
          {
             // rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
             if (self.script_noteworthy == "y")
             self rotateYaw(360,self.speed);
             else if (self.script_noteworthy == "x")
             self rotateRoll(360,self.speed);
             else if (self.script_noteworthy == "z")
             self rotatePitch(360,self.speed);
             wait ((self.speed)-0.1); // removes the slight hesitation that waittill("rotatedone"); gives.
             //self waittill("rotatedone");
             
          }
    }
    Thanks!
    Henny

  2. #2
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Code:
    molen()
    {
       trig = getent("trigger_windmolen", "targetname");
       
       while(1)
          {
             trig waittill ("trigger",user);
             rotate_obj = getentarray("windmolen","targetname");
             if(isdefined(rotate_obj))
                {
                   for(i=0;i<rotate_obj.size;i++)
                      {
                         rotate_obj[i] thread ra_rotate();
                         rotate_obj[i] thread resetTimer();
                      }
                }
          }
    }
    
    ra_rotate()
    {
       self endon("rotate_stop");
       if (!isdefined(self.speed))
       self.speed = 5;
       if (!isdefined(self.script_noteworthy))
       self.script_noteworthy = "x";
    
       while(true)
          {
             // rotateYaw(float rot, float time, <float acceleration_time>, <float deceleration_time>);
             if (self.script_noteworthy == "y")
             self rotateYaw(360,self.speed);
             else if (self.script_noteworthy == "x")
             self rotateRoll(360,self.speed);
             else if (self.script_noteworthy == "z")
             self rotatePitch(360,self.speed);
             wait ((self.speed)-0.1); // removes the slight hesitation that waittill("rotatedone"); gives.
             //self waittill("rotatedone");
             
          }
    }
    
    resetTimer()
    {
       self endon("rotate_stop");
       time = 60;
       while(time > 0)
       {
          wait 1;
          time = (time-1);
       }
       self notify("rotate_stop");
    }
    Untested, and probably not the best way of doing it, but should work.

  3. The Following 3 Users Say Thank You to filthy_freak_ For This Useful Post:

    Henny (11th July 2014),Invictus (11th July 2014),kung foo man (11th July 2014)

  4. #3
    ... connecting
    Join Date
    Jun 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you very mucht! It works excellent

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •