Page 1 of 1

[ACS] Need some help with variables...

Posted: Sat Mar 11, 2017 9:09 pm
by FranckyFox2468
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...");
  }
}

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

Posted: Sat Mar 11, 2017 9:52 pm
by Fused
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!");
}

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

Posted: Sat Mar 11, 2017 10:12 pm
by FranckyFox2468
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...