| 12-22-2005, 02:19 AM | #1 |
I'm starting to get a fairly obscene amount of global variables in my maps (I use GUI) and I was wondering if there's some way to declare and set local variables in GUI, like using a line of custom code or whatever. If this could be done it would help me a lot. Thanks in advance P.S. I'm not talking about the trick where you override the global variable with a local one, that's of no use to me. |
| 12-22-2005, 05:32 AM | #2 | |
Quote:
Nope.. the GUI has no reference to custom script within a trigger. So although you can do Custom Script: local integer my_int = 0, you won't have access to "my_int" through the GUI--you'd have to use JASS wherever you want to use it. As a workaround, it's become common to use temporary variables... TempInt, TempReal, TempUnit, TempPoint, etc. So when you need to store the value of something within a trigger, you can use the TempVar associated with it (so long as you don't need that same value later on in another trigger). Hope that helps answer your question. |
| 12-22-2005, 05:52 AM | #3 |
Bugger.. thanks anyways! |
| 12-22-2005, 09:33 AM | #4 |
I usually add a custom script with like "local unit target" then the actions that will be involved, I convert those in another trigger and check what I need to change. Code:
Melee Initialization
Events
Unit - A unit Dies
Conditions
Actions
Custom script: local location a
Custom script: set a = GetUnitLoc(GetDyingUnit())
Custom script: call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), a, bj_UNIT_FACING )just a fast made trigger. |
| 12-22-2005, 09:42 AM | #5 |
Bit offtopic, but I thought I'd like you know, if you need jass anyway, dont use CreateNUnitsAtLoc its a stupid function and it leaks a unit group. |
| 12-22-2005, 10:15 AM | #6 |
There is a pseudo-way to do it, however, you will not get rid of the globals. Lets say you define a global called TempUnit. Internally the variable will be called udg_TempUnit. So what you need to do to use it locally only is writing Custom Script with "local unit udg_TempUnit" as the first action in the trigger. For this trigger the value will be stored in the local variable. Just be sure to clean it up at the end of the trigger. |
| 12-22-2005, 10:29 AM | #7 |
CreateNUnitsAtLoc doesn't leak a unit group though (but yes, it sucks) |
| 12-22-2005, 11:21 AM | #8 |
I know, I just made up an fast trigger to show how you could do it so you wont need globals in all triggers. |
| 12-22-2005, 11:31 AM | #9 | |
Quote:
|
| 12-22-2005, 12:32 PM | #10 |
GetLastCreatedUnitGroup() or something like that is the function that creates a group |
