Get Player and Air Supply

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

Get Player and Air Supply

Postby Daryn » Fri Mar 15, 2019 3:36 pm

Hello.

I'm hoping someone here might be able to enlighten me as to why this doesn't work.

I am trying to create a space environment. I'm using a script triggered by an Actor enters Sector thing. The code for it is below.

Code: Select allExpand view
#include "zcommon.acs"

// EVA Environment
int PLnum = PlayerNumber();
int AirSupply = GetAirSupply(PLnum);

script 5 (int EVASectorTag)
{

   log(s:AirSupply);
   SetAirSupply(PLnum, AirSupply - 35);
   delay(35);
   restart;
}


When trying to compile the script, I get "Syntax error in constant expression" and "Missing semicolon on line 4.

I'm not hoping for a step by step guide here, where's the fun in that? I would however, like to know what is wrong and what I might look into to get the desired result.

Thanks, all!
Daryn
 
Joined: 23 Jan 2019

Re: Get Player and Air Supply

Postby Cherno » Fri Mar 15, 2019 6:05 pm

I would assume that you can't declare variables in the main body of the code that call functions to get their respective values.
You'd have to assign these values in an ENTER or OPEN script.
User avatar
Cherno
 
Joined: 06 Dec 2016

Re: Get Player and Air Supply

Postby Daryn » Fri Mar 15, 2019 7:00 pm

Hm. So if I do that in an ENTER script, wouldn't those values only apply to that script? That would mean to use them in another script I'd need to change them to have global scope.

This might be basic stuff, but I'm still new to this. My programming background is a bit of PHP and Python, so this is an adjustment.
Daryn
 
Joined: 23 Jan 2019


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest