Hey everyone, I'm making a map that contains a lot of items that all do about the same thing. Thing is, each item will change a variable when used, so I'm needing a trigger that will run every time an item is used, determine its effect, the change variables accordingly. At first I though that I could make a big “if then else chain” to take care of everything thing but thats gona be nasty. Then I remember strings.
I don't know much about strings; is there a way I can make the trigger add or subtract from the variables based on an items description? That would make adding more items sooooo much less painful.
yeah you can. Use catalogs to retrieve the value, and then match the returned string against a certain value.
use substring to get the integer part of the string, and convert it into an integer, and do whatever you want with it.
ps you can only make it work using the id's of fields.
Here is the piece of code I use to retrieve 2 integer values from an item's class (for my map this determines the size of the item in the inventory)
In my case stuff like 1x1Misc or 2x3Armor is returned by the last catalog call.
Hey everyone, I'm making a map that contains a lot of items that all do about the same thing. Thing is, each item will change a variable when used, so I'm needing a trigger that will run every time an item is used, determine its effect, the change variables accordingly. At first I though that I could make a big “if then else chain” to take care of everything thing but thats gona be nasty. Then I remember strings.
I don't know much about strings; is there a way I can make the trigger add or subtract from the variables based on an items description? That would make adding more items sooooo much less painful.
I hope I'm making sense. Thanks for the help!
@LeinadNightSky: Go
yeah you can. Use catalogs to retrieve the value, and then match the returned string against a certain value.
use substring to get the integer part of the string, and convert it into an integer, and do whatever you want with it.
ps you can only make it work using the id's of fields.
Here is the piece of code I use to retrieve 2 integer values from an item's class (for my map this determines the size of the item in the inventory)
In my case stuff like 1x1Misc or 2x3Armor is returned by the last catalog call.