Variables and if statements
-
noissessop
- New User
- Posts: 2
- Joined: Sat May 18, 2013 8:38 pm
Variables and if statements
I'm trying to learn ACS so I can make better maps but i'm struggling a bit. I've tried looking for the answer to this on the zdoom wiki but haven't had any luck.
What I want to do is have one script set a variable (e.g. set ItemCollected to 1) and then have another script use the variable in an if statement (If Itemcollected = 1) operation 1 else operation 2. I just need to know how to set a variable and the syntax I need to use in an if statement
What I want to do is have one script set a variable (e.g. set ItemCollected to 1) and then have another script use the variable in an if statement (If Itemcollected = 1) operation 1 else operation 2. I just need to know how to set a variable and the syntax I need to use in an if statement
-
Ijon Tichy
- Frequent Poster Miles card holder
- Posts: 901
- Joined: Mon Jun 04, 2012 5:07 am
RE: Variables and if statements
Code: Select all
int ItemsCollected = 0;
script 1 (int inc)
{
ItemsCollected += inc;
}
script 2 (void)
{
if (ItemsCollected > 5)
{
SetResultValue(1);
}
else
{
SetResultValue(0);
}
}
Last edited by Ijon Tichy on Sat May 18, 2013 9:22 pm, edited 1 time in total.
-
noissessop
- New User
- Posts: 2
- Joined: Sat May 18, 2013 8:38 pm
RE: Variables and if statements
Thank you, this works perfectly
- ibm5155
- Addicted to Zandronum
- Posts: 1641
- Joined: Tue Jun 05, 2012 9:32 pm
- Location: Somewhere, over the rainbow
RE: Variables and if statements
Hmm if acs works like ansi c.
if you do If (Itemcollected = 1) this sentence´ll be always true, so it´ll enter on the if state always, to compare you need two equals -> If (Itemcollected == 1)
if you do If (Itemcollected = 1) this sentence´ll be always true, so it´ll enter on the if state always, to compare you need two equals -> If (Itemcollected == 1)
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">
-
Ijon Tichy
- Frequent Poster Miles card holder
- Posts: 901
- Joined: Mon Jun 04, 2012 5:07 am
RE: Variables and if statements
That's explicitly a false statement. Assignments in if statements are not allowed.
Also, "if (herp = 0)" is guaranteeed to fail, because the value herp is being set to (0) is false. It's not a guaranteed true.
Also, "if (herp = 0)" is guaranteeed to fail, because the value herp is being set to (0) is false. It's not a guaranteed true.
- ibm5155
- Addicted to Zandronum
- Posts: 1641
- Joined: Tue Jun 05, 2012 9:32 pm
- Location: Somewhere, over the rainbow
RE: Variables and if statements
:o
master ijon, :oooooooooooooooo
I feel like a newbie now.
master ijon, :oooooooooooooooo
I feel like a newbie now.
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!
<this post is proof of "Decline">
RE: Variables and if statements
script 1 (int inc)
{
ItemsCollected += inc;
}
just how does this script work?
{
ItemsCollected += inc;
}
just how does this script work?
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there
RE: Variables and if statements
It adds the value of "inc" to "ItemsCollected".Lollipop wrote: script 1 (int inc)
{
ItemsCollected += inc;
}
just how does this script work?
It's a simplified version of
Code: Select all
ItemsCollected = ItemsCollected + inc;
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

RE: Variables and if statements
Well there's your problem. ACS doesn't make your maps better. I learned that the hard way.noissessop wrote: I'm trying to learn ACS so I can make better maps
RE: Variables and if statements
then please slap me and tell me how to give inc a value, because I dont understand, no matter how many times I look into various projects :(Ænima wrote:It adds the value of "inc" to "ItemsCollected".Lollipop wrote: script 1 (int inc)
{
ItemsCollected += inc;
}
just how does this script work?
It's a simplified version ofCode: Select all
ItemsCollected = ItemsCollected + inc;
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there
RE: Variables and if statements
With the script you posted, the value of inc gets set using an argument when you call the script. This is because after "script 1", you put "(int inc)" instead of "(VOID)". This is okay. It makes the script more flexible.Lollipop wrote:then please slap me and tell me how to give inc a value, because I dont understand, no matter how many times I look into various projects :(Ænima wrote:It adds the value of "inc" to "ItemsCollected".Lollipop wrote: script 1 (int inc)
{
ItemsCollected += inc;
}
just how does this script work?
It's a simplified version ofCode: Select all
ItemsCollected = ItemsCollected + inc;
For example,
Code: Select all
script 1 (int inc)
{
ItemsCollected += inc;
}
script 2 (void)
{
ACS_Execute(1,0, 555);
}
That means that Script 1 will be executed and "inc" will be 555. (Only for that time though. This does not permenantly set the value of "inc".)
Last edited by Ænima on Tue May 28, 2013 2:45 pm, edited 1 time in total.
Reinforcements: midgame Survival joining/respawning
Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

Doom64: Unabsolved: Doom64 + Diablo II
ZandroSkins: a pack made by our community
AeniPuffs: 3D blood and bullet puff effects, free to use for your own mods
Squad Radio: a WASD-based radio chat menu, add your own custom sounds!
Mercenaries (on hold)

RE: Variables and if statements
thank you very much, you are always so friendly :)
Combinebobnt wrote:i can see the forum league is taking off much better than the ctf ones
GalactusToday at 1:07 PM
are you getting uncomfortable jap
feeling something happen down there