HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

A possible workaround?

09-18-2004, 02:45 AM#1
Stinky_Pooh
Let me preface by saying i learned jass to avoid globals when possible, i dislike the fact that EVERYONE uses the same globals :( even though 2 triggers to my knowledge cant run at the same time, it bothers me that data could be changed by something else that really shouldn't be touching it.

Now for the meat of my question, the workaround, for some idiotic reason blizz chose to make it so that we cannot keep variables inside of Enum loops, even though it is obvious we would want to be able to expound upon data we gather from these, in my case all i want to do is count all the items in a group of destructables, and make an item with that amount of charges. I could
A) use a global 2 keep track of them and make the item at the end, or
B) i could creat the item before i go into loop, and just add 1 to it each time by using these 2 functions:
SetItemCharges (curr_item, (GetItemCharges(curr_item)+1) )


now my question is i know that preformance will be worse with the later, my question is, by how much? / is it not worth it?
09-18-2004, 03:59 AM#2
Grater
Erm what is the point? you'd have to set the item to a global variable anyway.

Theres no possible issue with using globals as long as you have no waits in any of the triggers that use the global. But you can use the game cache to create "variables" for a specific trigger or instance of a trigger in interesting ways - bear in mind this will be less effecient than just using local/global unless there is a good reason why local/globals wont work, like waits or a timed periodic or something.
09-18-2004, 06:47 AM#3
Stinky_Pooh
no, you dont have to global the item, you can just find the item in their inventory, there is a function that allows this, not sure what, because i desided against it, its just too damn inefficent :(