Cube Dimensional Traveller
Joined: 02 Feb 2003 Posts: 294
|
Posted: Wed Jun 11, 2003 3:08 am Post subject: |
|
|
Quote: | variable (num)
variable (hero)
variable (stat)
for (num, 0, 3, 1) do (
set variable (hero, hero by slot (num))
if (hero <> -1) then (
set variable (stat, get hero stat (find hero (hero), stat:HP, current stat))
set hero stat (find hero (hero), stat:HP, stat--1, current stat)
)
)
|
Rename the variables if you need to.
Now, I'm also going to teach you what's going on, heh. Firstly, we define 3 variables which will hold information for us. Num is the slot number we check which is used in the following FOR loop. Hero is to store the hero found in the slot we check. It will return -1 if no hero is found. Finally Stat holds the hero's current HP.
Now with the for loop, the first in the argument is the variable we use. The second one is the number we start at. The third argument is the number we stop at, and the last one is the amount of numbers the variable will increase. So that being said, we start at 0 and will continue until we hit 3. This will check slots 0, 1, 2, and 3. All four of them. Just for the record, if I made the last slot of the for loop a 2, it would only check 0, and 2.
Now, inside the for loop (The DO section), we set hero by using "hero by slot". For the argument in that command, we use "Num" which is the current number the for loop is on. Then a "If" statement to check "hero". If the number isn't equal to -1, then it does the commands within the if statement. It first sets the variable "stat" to the current HP the hero has. Then it changes the hero's current HP by subtracting 1 (Or any other number you feel like using). If you don't know what going on with the "get hero stat" and "set hero stat" commands, check them out here, and here.
And that's it! I hope you understand, heheh. If you have any more questions, be sure to ask.
Last edited by Cube on Wed Jun 11, 2003 8:43 am; edited 1 time in total |
|