How does the "return value" work?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Posts: 13534
Joined: Wed Jul 16, 2003 3:52 am

How does the "return value" work?

Post by Tormentor667 »

I am currently playing around with script stuff and noticed that "SpawnSpot" returns a value if it successfully spawns an actor, actually if you spawn an actor with "SpawnSpot" on a map spot and one is blocked, it returns "1" if I have understood this correctly.

But how can I use that in ACS? I mean, how can I restart a spawning script in case SpawnSpot doesn't return 1 but 0? Or how can I proceed through script if it returns 1 as expected?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49098
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How does the "return value" work?

Post by Graf Zahl »

You use it like any other return value:

Either assign it to a variable or check it directly with an 'if' statement.


Code: Select all

script 1(void)
    int num = SpawnSpot(...);
    if (num == 0) restart;

Return to “Scripting”