| 01-07-2007, 06:33 AM | #1 |
It is common knowledge that only one local variable can be used per GUI trigger. Does this mean that it is impossible to use a local array to get around this? Also, if local variables cannot be referenced in GUI conditions, can they be referenced in JASS conditions... or do the same problems occur as do when one is using GUI? |
| 01-07-2007, 06:56 AM | #2 |
1 : Can not declare local arrays, simply. 2 : A JASS condition should work in a Custom Script like : Code:
Custom Script : if Conditions() then ----- Do Actions ----- Custom Script : endif But it is faster to write it in JASS. Notice you can't use Pick Every Actions with locals (if you are not using GetEnumUnit() to refer a unit, else the local would be null inside the Pick Every actions) |
| 01-07-2007, 07:19 AM | #3 |
Ah, thank you for your help! +Rep! |
| 01-07-2007, 10:49 AM | #4 |
You can have more than one local variable in GUI ofc... Whatever you add/type in GUI is just converting it to Jass for you, so really, ask yourself, "can i only have one local variable in Jass?", no. If you mean one local variable with the prefix of udg_, then i think yes. But you can declare hundreds of locals in GUI as you can Jass. If you wanted just the one udg_, that can store handles (unit, destructable, player, etc), then make it a integer array, and in your maps custom script, copy and paste the following: JASS:function H2I takes handle H returns integer return H return 0 endfunction Then, to store anything in that local integer array, type the unit and put H2I() around it, like this: JASS:local integer array Store set Store[1] = H2I(GetTriggerUnit()) And to get the unit back, you need to add a function in your map script for each handle type. So unit would be like this: JASS:function I2Unit takes integer I returns unit return I return null endfunction Player like this: JASS:function I2Player takes integer I returns player return I return null endfunction Notice you only change two things, and its really simple: JASS:function I2Unit takes integer I returns unit return I return null endfunction function I2Player takes integer I returns player return I return null endfunction Then your code to get it back: JASS:local integer array Store set Store[1] = H2I(GetTriggerUnit()) call KillUnit(I2Unit(Store[1])) But that defeats the advantage of using udg_ in GUI, cause your using H2I and I2Handle functions, it has to be in Jass. |
| 01-07-2007, 11:33 PM | #5 | |
Quote:
JASS:local integer array i set i[0] = 1 But I just tried it in the GUI using this: Didn't give any errors with pjass 1.0c. But it wouldn't play ingame and when I tried it with normal WE it said 'expected a name'. So all I've done is discover a bug in pjass. |
| 01-08-2007, 12:03 AM | #6 |
I think that only works because Integers aren't handles. I tried it with a Unit array and it wouldn't work. |
| 01-08-2007, 01:50 AM | #7 |
1) Save local var into global var to pass it to condition instant data transfer is good 2) Dunno why you cant declare local arrays, only code array cannot be declared. |
| 01-08-2007, 02:39 AM | #8 |
Sure you can declare a local array, that doesn't really mean you should ever use a local array. |
| 01-08-2007, 04:22 AM | #9 | |
DioD, I know that you can do that to get around the no locals in GUI conditions, I just had a question about it. Quote:
|
