Thread: for(...) and i
View Single Post
  #3  
Old 11-04-2001, 06:35 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Re: for(...) and i

NPC Code:

if (wasshot) { Makes the following stuff executed when the NPC is hit by an arrow
for Initializes a for-loop
(i=0; Sets the variable "i" to 0 once
i<npcscount; Defines when to repeat the script after the ) thing: When the variable i is lower than the amount of NPCs in the level
i++) Increasing i each time the script after ) is run
callnpc i,swimming; Setting the flag "swimming" to true for the NPC with the index "i"
}



So what it would be doing in "normal" talk:
1) Wait until the NPC is hit by an arrow.
2) Set "i" to 0
3) Tell the NPC with index "i" that "swimming" is called (makes if (swimming) happen)
4) Increase "i" by one
5) Go back to 3 if "i" is lower than the amount of NPCs in the level
6) Stop executing
Reply With Quote