| 08-27-2006, 10:03 PM | #1 |
so while using these temporary unit groups and points, you can delete unwanted handles set out to locate certain unitgroups or points. I have 3 questions 1.) can you use the same variable after u destroy it. such as Trigger1: tempgroup=(units owned by trigger player) pick all units in tempgroup and remove picked units from game customscript: call destroygroup(tempgroup) Trigger2 --Well, lets just say it does the same thing as trigger1 wouldnt that cause error in the script? Not being able to find the variable unit group "TEMPGROUP"? 2.) where can i find a list of function codes to delete different variables? 3.) what is that program that has the cool GUI example interfaces that u can post as text? |
| 08-27-2006, 10:12 PM | #2 |
look for anything with the words "remove" and "destroy" at jasscraft. |
| 08-27-2006, 10:59 PM | #3 |
I think you was asking this, but not sure, as in can you have to variables with the same name. Globals, no, locals, yes, locals are a different instance. 1 local with a name in 1 function, ok. 2+ locals with the same name in 1 function, not ok. 2+ globals with the same name in any function, not ok. Example: Wont work:function ThisWontWork takes nothing returns integer local integer Hello = 5 local timer Hello = null return Hello endfunction Will work:function ThisWillWork takes nothing returns integer local integer Hello = 5 local timer Hello2 = null return Hello endfunction This will also work: You can have multiple locals with the same name in different functions, just not in the same. JASS:function ReturnHello takes nothing returns integer local integer Hello = 5 return Hello endfunction function GetHello takes nothing returns nothing local integer Hellos = 0 set Hellos = Hellos + ReturnHello() set Hellos = Hellos + ReturnHello() set Hellos = Hellos + ReturnHello() set Hellos = Hellos + ReturnHello() endfunction When running ReturnHello(), its creating multiple Hello locals inside the ReturnHello function, but because theyre in a different instance of the function, they dont collide. |
| 08-27-2006, 11:12 PM | #4 |
if i was thinking harder, id be able to understand what u were saying. but i have no idea what null is or what any of the code in JASS means. |
| 08-27-2006, 11:32 PM | #5 |
I explained that this link. Destroying/Removing a variable destroys the thing that the pointer points to. Nulling destroys the pointer. I divised a evil scheme of cheap paint images (cant be bothered loading photoshop for 15 sec), to explain easier. In the case, im going to give a example of a unit, because you can imagine a unit exsisting ingame easier than other handles. So, you set a variable, then we have this: If you Destroy/Remove that variable, this happens: If you null the variable, this happens: Nulling dosent destroy the handle, it just destroys the variable in effect. |
| 08-27-2006, 11:50 PM | #6 |
well thats pretty cool. something like, the information is held, but the nonsense connecting to it isnt causing the game to use up more memory? ----------- anyway, my question is can i use variable[unit group] --- "atempgroup" every single time i use Unit - [Pick all units in blahblahblah] ??? id think that the different triggers would conflict with eachother and start using different unit groups, or does WE do what i THOUGHT it did which is complete each trigger before it moves on? replies are greatly appreciated |
| 08-28-2006, 06:52 AM | #7 |
Yea, the pointer and the unit uses memory, thats why people say null a local variable at the end of a function, because that variable will never be used again (the thing its pointing too might, but not that local), so null it. Im not sure i understand your question. If your saying: "Can i use a variable multiple times in multiple triggers that may be used at the same/different times". Then yes, you can use a variable anytime anywhere. The thing to look out for, which may be a problem, is something with waits in it. If the trigger has no waits, its fine, but if it does, and you use globals, you may have problems. Imagine trigger1, you set a unit variable to a paladin, wait 5 seconds, kill the variable. in trigger2, you wait 2.5 seconds, set variable to a footmen. Both of those triggers will now collide, the first will kill the footmen instead of the intended paladin. This is where locals come in handy. Instant trigger (no waits) - use as many globals as many times in any trigger at any time. Waits in trigger - Use locals (If your not great in Jass, this can be difficult, but you can always ask for help or read a tutorial). Still, globals and locals need destroying. Unit groups and locations are the worst culprits, like (Position of MyUnit) and (Pick every unit in ~Criteria~). So once you'v finished using them, find the correct Destroy/Remove function for them, and get rid of them. If its a local null it because you wont use it aqain. Globals dont need nulling, this is the part that confuses me, globals have pointers, but dont need nulling, um, and whys that? (retorical question) I looked up on Jasscraft for the native destroys so you can use them when you need to. Stick them in a custom script if its in GUI, and remember, variable names have a udg_ infront of them if theyre global. JASS:native RemoveDestructable takes destructable d returns nothing // Destructable native RemoveItem takes item whichItem returns nothing // Item native RemoveLocation takes location whichLocation returns nothing // Location (point) native RemoveRect takes rect whichRect returns nothing // Dont bother, its confusing enought as it is knowing which is a rect and which is a region native RemoveRegion takes region whichRegion returns nothing // Same again native RemoveUnit takes unit whichUnit returns nothing // Unit // And now alot of destroys =( // Im not going to include Jass ones, such as DestroyBoolExpr native DestroyEffect takes effect whichEffect returns nothing // Special Effect native DestroyForce takes force whichForce returns nothing // Force (Player group) native DestroyGroup takes group whichGroup returns nothing // Group (Unit Group) native DestroyImage takes image whichImage returns nothing // Image native DestroyLeaderboard takes leaderboard lb returns nothing // Leaderboard native DestroyLightning takes lightning whichBolt returns boolean // Lightning native DestroyMultiboard takes multiboard lb returns nothing // Multiboard native DestroyQuest takes quest whichQuest returns nothing // Quest native DestroyTextTag takes texttag t returns nothing // Floating Text native DestroyTimer takes timer whichTimer returns nothing // Timer native DestroyTimerDialog takes timerdialog whichDialog returns nothing // Timer Window native DestroyTrigger takes trigger whichTrigger returns nothing // Be carful, it wont delete it from your map, but you cant get it back ingame native DialogDestroy takes dialog whichDialog returns nothing // Dialog |
