Jump to content
Sign in to follow this  
SouthernGoods2

Amateur at scripting, can anyone tell me why this code is bad?

Recommended Posts

I am placing this code into the init of a Pop-Up Alien object. I am very new to scripting so I know my syntax is probably the cause. 

Spoiler

while { triggerActivated mt_1 } do {    
      sleep 2;
     _x animate ["terc", 0];
      sleep 2;
     _x animate ["terc", 1];    
   };

 

Share this post


Link to post
Share on other sites

Guessing it's due to scheduled v un-scheduled environments, and that _x reference. Worth looking into them ( scheduled/un-scheduled) if you want to understand it, but basically you cant pause a script unless it is spawned or execVM'ed, whereas code written into an object's init is called and so cannot be paused. So, spawn your code:

nul = [this] spawn {
 params ["_object"];
 while { triggerActivated mt_1 } do {    
  sleep 2;
  _object animate ["terc", 0];
  sleep 2;
  _object animate ["terc", 1];    
 };
};

But, that then all depends on what _x is too. So I'm assuming here that this is the only code you've got in the init?

  • Like 2

Share this post


Link to post
Share on other sites

I was basing the code off some code that I found where _x was their target. I was assuming _x was just another way of using "this", so should I just replace _x with this or the variable name of the target?  

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×