From ZDoom Wiki
Jump to navigation Jump to search

void SetResultValue (int value)


When a script is executed, it has an associated “result value”. This is somewhat akin to a function's return value. Normally, a script's result value is 1, but SetResultValue can be used to change this to something else. However, you must use SetResultValue before calling any functions that make the script wait, such as Delay or TagWait. After the script starts waiting, its result value can no longer be changed.

The following are uses for a script's result value:

If you execute a script with ACS_ExecuteWithResult, ACS_ExecuteWithResult will return the script's result value. This lets you use a script as if it was a function.
If you place the ACS_ExecuteWithResult special on a switch linedef, you can use SetResultValue to prevent the normal switch action from taking place (e.g. because the script did not perform any action). If the script's result value is set to 0, the switch texture will not be changed, nor will the switch sound be played.
You can use ACS_ExecuteWithResult in CustomInventory item's state chains to notify the item about the success or failure of the state chain.


This shows how SetResultValue is used with ACS_ExecuteWithResult to retrieve a return value from another script.

script 1 (void)
    Print(d:ACS_ExecuteWithResult(2, 0, 0, 0)); //prints 667

script 2 (void)

As this command was added specifically so that many of Strife's unique specials could be implemented through ACS, strifehelp.acs is also a good place to see this command in action.