Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Variable addition

13 years ago

Is there a way to make it so if one variable, say, SCORE gets to 100 then it automatically adds, say, 10 points to HEALTH without having to manually go through every path to make sure whenever it reaches 100 you add 10?

Variable addition

13 years ago
In the global link script:

IF %SCORE = 100 THEN
BEGIN
%HEALTH := 10
%SCORE := 101
END

You set score to 101 so that it doesn't keep setting the health to 10, over and over.

Variable addition

13 years ago

Okay, thanks a bunch, 3J!

Variable addition

13 years ago
Oh wait, that sets health to 10, you want it to add 10 so

IF %SCORE = 100 THEN
BEGIN
%HEALTH := %HEALTH + 10
%SCORE := 101
END

Variable addition

13 years ago
Likewise, if you want to add it when you get OVER 100 score (not necessarily exactly 100 score, then you need a variable called TOGGLE)

IF %SCORE > 100 THEN
BEGIN
IF %TOGGLE = 0 THEN
BEGIN
%HEALTH := %HEALTH + 10
%TOGGLE := 1
END
END

Variable addition

13 years ago

Oh, thanks again. XD Good thing I didn't put the code in yet.

Variable addition

13 years ago

Wow. Cool stuff here :)

 

BZ