Jump to content
Ranwer135

Repairing Wheel Script - Need help

Recommended Posts

Vehicle's init:

this addAction ["Repair", {[_this select 0] call dss_fnc_repair_wheel;}];

Also, if I'm not mistaken, script suspension (using sleep, etc.) is not allowed.

  • Like 1

Share this post


Link to post
Share on other sites

Vehicle's init:

this addAction ["Repair", {[_this select 0] call dss_fnc_repair_wheel;}];

Also, if I'm not mistaken, script suspension (using sleep, etc.) is not allowed.

 

Thanks for spotting the problem, works perfectly!  ;)

 

However, what do you mean by "script suspension is not allowed"?  :blink: (I thought sleep and waitUntil were great for delaying something such as a condition or action?)

Share this post


Link to post
Share on other sites

what do you mean by "script suspension is not allowed"?

... in this context.

Check RPT-file. If there are no errors, then I was wrong.

Share this post


Link to post
Share on other sites
  Executes the function string. The argument(s) (if any) are passed as _this. (argument(s) are passed in an array). To execute a sleep function in the called code, execute it with spawn instead.

 

 

 

Source

Share this post


Link to post
Share on other sites

Can you post the working code :) :) :)

 

Soldier goes through the motions of reparing wheel on hunter, but nothing gets repaired

Share this post


Link to post
Share on other sites

You generally don't use them with 'call', but with spawn/execvm instead.

 

It goes a little deeper than that. It's not that you don't use suspension, it's that you can't use suspension. In Arma, we have scheduled environments and non-scheduled environments. In a scheduled environment, commands are put into a queue and run when it's their turn. This is what causes something called "script lag"; when a mission designer has too many active scripts running, they must all wait for their turn to execute, which can cause scripts to take much longer to run.

 

However, in a non-scheduled environment, all of the code is executed on the spot. Everything else is stopped until all non-scheduled code is run (that includes rendering and playing sounds). If you had a sleep in that code, the game would freeze until it ended. At some point during development, a BIS dev thought that would probably not be a good idea and added some code to stop suspension commands from being run and throw an error.

 

Some common non-scheduled environments include:

  • The debug box (accessed by pressing esc)
  • Initialization fields of objects placed in the editor
  • Event handler code (includes mission event handlers, object event handlers, and GUI event handlers)
  • The code in an addAction command
  • Function calls

It's a good idea to keep in mind whether your code is in a scheduled or non-scheduled environment when it will be run, you can eliminate some errors before they even happen.

 

Any non-scheduled environment can be turned into a scheduled environment through use of the spawn command.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the great info guys.

I did a little searching and found some good resources and pages like in the community page, "optimizing code".

@thesh1tgamer

Will post a public release today, so no need to rely on the already made code there. :P

 

 

EDIT-----

 

 

Script released!

 

 

Link: https://forums.bistudio.com/topic/183681-repair-wheel-and-engine-script-release/

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

×