| 08-26-2006, 07:29 PM | #1 |
In my map, hitting the ESC key toggles the leaderboard on/off. i cant figure out how to have the trigger check if a unit in the selection of the player is under construction. Basically, I'm trying to let the players cancel their buildings if they want to, and NOT toggle the leaderboard. something like no units in selection of player is under construction. i dont know. but replies are greatly appreciated |
| 08-26-2006, 07:30 PM | #2 |
Pick every building owned by the player, and check if they are selected.. If one is, then do nothing, else hide the board. EDIT: Use a condition like this: Trigger: Notice that it has a group leak. |
| 08-26-2006, 07:41 PM | #3 |
now how can i check if the building is under construction? and what is a loop memory leak and how can i prevent them from ever happening? |
| 08-26-2006, 07:47 PM | #4 |
It's not a loop memory leak, there is no such thing, it's a group memory leak. You can fix it by setting the group to a variable before using it for the loop and then destroying it after you use it. |
| 08-26-2006, 07:49 PM | #5 |
now what do these group leaks do? slow down the game? |
| 08-26-2006, 08:10 PM | #6 |
Yes, pretty much, can cause lag in bad chases. What it means is that the reference to an object, in this case a group, in memory is never deleted although it won't ever be used again - so it's still taking up RAM. (= leaking) So obviously it's much worse for older comps Trigger: ![]() set tempgroup = Units owned by (Triggering player) matching ((((Matching unit) is A structure) Equal to True) and (((Matching unit) is selected by (Triggering player)) Equal to True)))![]() If (Number of units in (tempgroup) Equal to 0 then![]() ...![]() end of if statement![]() Custom script: call DestroyGroup(udg_tempgroup) |
| 08-26-2006, 10:45 PM | #7 |
now can u please tell me where to get all the information about custom scripts? will destroygroup work for all varaibles? or only unit groups? and what is udg? if i can put destroy variables like that all the time and prevent leaks, that would be a HUGE breakthrough in my map. replies are greatly appreciated. |
| 08-26-2006, 11:01 PM | #8 |
When I learned JASS I used JassCraft, you can download it in the tools section, and the "convert trigger to custom text" you can find in the editor. DestroyGroup() only works for groups, there are several others but that one nad RemoveLocation() are the most important ones. udg_ is something WE automaticly writes in front of "globals" (those in variables list), so the udg_tempgroup would just be a variable of type group called tempgroup. And for the record, it's not the actual variable that leaks, it's the object it points to. When you store a group like above the editor makes sure a group is automaticly created, but then never destroyed :/ So no need to worry about variables leaking (for now, "local" variables which can only be used in JASS have some issues) |
| 08-27-2006, 08:04 AM | #9 |
Yea. When you set something to something, it just creates a pointer, when you destroy the variable, it destroys the thing the pointer is pointing to, if you null the variable it destroys the pointers. Destroy before null! |
