| 03-01-2005, 03:47 AM | #1 |
Hey, really noob question here: I'm trying to write a condition that checks if a hero has item Amulet of Greed in his possession, and the only option WE is giving me is "carrying item in slot X". So what I want to know is, how can I use integer A to create a loop that checks each item slot? Right now my trigger looks like this: E: Unit - A Unit Dies C: (Item carried by (Killing unit) in slot (Integer A) equal to (Item carried by (Killing unit) of type Amulet Of Greed A: Item - Create Gold Coin at (Position of (Dying Unit)) One other thing that I would very much appreciate: I've heard of memeory leaks, and I think this trigger will create one with the (Position of (Dying Unit) part, so how could I stop that from becoming a leak? Thanks for all your help. |
| 03-01-2005, 06:23 AM | #2 |
i'll just describe loops a bit since i don't have the editor open atm to look at ur specific request In setting up a standard loop you need to use the action "For each integer A from X to Y do actions" where you can add actions as a sub branch for the loop... all actions in the loop will be processed Y-X times and each time the loop passes through, integer A is incremented by 1 ex if you had For each integer A from 1 to 12 do actions + -- game - text msg ("The number" + Integer A) will print The number 1 The number 2 The number 3 ... The number 12 Theres also recursive looping, but i won't get into that for now |
| 03-01-2005, 03:20 PM | #3 |
Alright raptor, that's very helpful, and I'll definately use that. However, I noticed that in testing, any unit you killed spawned the gold coin UNLESS the killing unit had Amulet of Greed. o_O Not really something I have to know, but it's bugging me why it is working like that. |
| 03-01-2005, 10:30 PM | #4 | |
Quote:
as for you trigger, now that i have my editor open, this should do: Code:
Event:
Unit - a unit dies
Actions:
If ( ((Killing unit) has an item of type Amulet of Greed) Equal to True ) then (boolean condition)
Item - Create Gold Coin at (Position of (Dying Unit))
endif |
