[ACS] Need some help with variables...

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Need some help with variables...

#1

Post by FranckyFox2468 » Sat Mar 11, 2017 9:09 pm

I may sound like an absolute dumbass on this regard but i am really not sure how variables work since its not THAT well explained on the zdoom wiki, on top of me being mediocre with acs...

So let's say i wanna make a thing that keeps track of a certain number. And whenever the player activates a switch somewhere it increases that number, and after a certain ammount has being reached something happens, how would i do this?

Again, i am absolutely sorry if this sounds like a retarded questions i tried playing around with variables with the info i have an i still have no damn clue how this shit works.

EDIT: I tried a bit of a code but it doesn't seem to work, can't figure why:

Code: Select all

int WaterPumplevel = 0;   
script 6 (void)
{
   WaterPumplevel++
if (WaterPumplevel == [3])
 {
 print(s:"You should be able to swim across the gap now!");
 }
else
 if (WaterPumplevel == 2)
  {
  print(s:"One more should suffice!");
  }
 else
  if (WaterPumplevel == 1)
  {
  print(s:"Its going up, still too low to get across though...");
  }
}

User avatar
Fused
Contributor
Posts: 658
Joined: Sat Nov 09, 2013 9:47 am
Location: Netherlands
Contact:

[ACS] Re: Need some help with variables...

#2

Post by Fused » Sat Mar 11, 2017 9:52 pm

You were very close, the only problem I believe needs fixing is [3] has to be 3, and WaterPumplevel++ needs a semicolon (;) after it. See if you get any errors when compiling after that.

If you really want to make a good script from this, you can probably use the suspend function. It should suspend your script and continue where it left off when called again.

Code: Select all

  
script 6 (void)
{
    print(s:"Its going up, still too low to get across though...");
    suspend;

    print(s:"One more should suffice!");
    suspend;

    print(s:"You should be able to swim across the gap now!");
}
My mods
Image Image

My socials
Image Image

User avatar
FranckyFox2468
Forum Regular
Posts: 180
Joined: Sat May 07, 2016 8:30 pm

[ACS] Re: Need some help with variables...

#3

Post by FranckyFox2468 » Sat Mar 11, 2017 10:12 pm

Fused wrote:You were very close, the only problem I believe needs fixing is [3] has to be 3, and WaterPumplevel++ needs a semicolon (;) after it. See if you get any errors when compiling after that.

If you really want to make a good script from this, you can probably use the suspend function. It should suspend your script and continue where it left off when called again.

Code: Select all

  
script 6 (void)
{
    print(s:"Its going up, still too low to get across though...");
    suspend;

    print(s:"One more should suffice!");
    suspend;

    print(s:"You should be able to swim across the gap now!");
}
Ha ha! Works now! Thanks! Also i didn't knew about suspend, i will take this in note for later use! I'm still kinda bad with variables tho but oh well...

Post Reply