HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

MUI in an If/Then/Else statement

08-21-2007, 07:00 PM#1
DurotarLord
allright, im trying to make a trigger right now that creates a local variable for a unit and an effect, and then calls on that unit in an If/Then/Else statement. The problem is, the local variable is ignored in the if/then/else, but i cant create a local variable at the begining of the if/then/else. Heres what it looks like:

Trigger:
Actions
Custom script: local unit udg_a
Custom script: local effect udg_b
Set a = (Target unit of ability being cast)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Owner of a) is an ally of (Owner of (Casting unit))) Equal to True
Collapse Then - Actions
Special Effect - Create a special effect attached to the chest of a using Abilities\Spells\Human\DivineShield\DivineShieldTarget.mdl
Custom script: set udg_b = GetLastCreatedEffectBJ()
Unit - Add Divine Shield Invonerability to a
Else - Actions

See, the special effect and ability aren't added to the unit, because the game can't use a local variable established outside of the if/then/else statement inside of it. I tried to just create the local variable inside of the statement itself, but the game gives me an error message that says "Expected 'endif'"! What can I do? I need to use the if/then/else statement, and if there isn't any way to use a local variable inside of this then I'll have to use a global variable and the spell won't be MUI.

btw, i cant just add the condition in the if/then/else statement to the conditions of the trigger itself, because in the end this is going to be a very long trigger, and this is only the small section im having trouble with.
08-21-2007, 07:10 PM#2
botanic
redeclare the locals in the If then else statment or use JASS
08-21-2007, 07:16 PM#3
cohadar
When you use those multiple-function if then else
locals do not work.

You need to use single function if-then else
and use AND , OR to concatenate.

But that would look really ugly.

Well I guess general answer for all GUI questions is - learn JASS.

EDIT:

Or you can try this:
Trigger:
Actions
Custom script: local unit udg_a
Set a = (Target unit of ability being cast)
Custom script: if GetOwningPlayer(GetSpellAbilityUnit()) == GetOwningPlayer(udg_a) then
-------- add anything here --------
Custom script: else
-------- add anything here --------
Custom script: endif
08-21-2007, 07:16 PM#4
CommanderZ
Problem is that when the gui code is being JASSized, codes within all forms of multiline loops and conditions are put into separate function, so you cannot use locals there. There are three possible solutions that come to my mind:
1) Redeclare the local inside the IF. You wont wbe able to bring its value in and out of the IF. IFs are simply separate groups of commands in GUI.
2) Use globals. If you don't have any waits there, it should be okay. [RECCOMENDED]
3) Learn JASS :P [RECCOMENDED EVEN MORE]
08-21-2007, 08:44 PM#5
Ammorth
also, there is a bug that you cannot have 2 local variables in a function with the same name as a global variable.
08-21-2007, 11:38 PM#6
DurotarLord
i know a little jass, but i always like to make my stuff in GUI so that i can show it to anyone and they'll understand it.

thanks for the help guys, i think i outa be able to get it to work now (or at least find a way to make it work)
08-22-2007, 07:57 AM#7
Pyrogasm
Just use a Temp Global:
Trigger:
Actions
Custom script: local unit udg_a
Custom script: local effect udg_b
Set a = (Target unit of ability being cast)
Set Temp_a = a
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Owner of Temp_a) is an ally of (Owner of (Triggering unit))) Equal to True
Collapse Then - Actions
Special Effect - Create a special effect attached to the chest of Temp_a using Abilities\Spells\Human\DivineShield\DivineShieldTarget.mdl
set Temp_b = (Last created special effect)
Unit - Add Divine Shield Invonerability to Temp_a
Else - Actions
Custom script: set udg_b = udg_Temp_b
Set Temp_b = (No effect)

Oh, and you spelled "invulnerability" wrong.
08-22-2007, 03:06 PM#8
DurotarLord
Theres gonna be waits in the final thing though, so if i go global i wont be able to have it be MUI.
08-22-2007, 07:10 PM#9
Pyrogasm
Temp global. You use it to pass things between the if/then elses. You can still use a wait:
Trigger:
Actions
Custom script: local unit udg_a
Custom script: local effect udg_b
Set a = (Target unit of ability being cast)
Set Temp_a = a
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Owner of Temp_a) is an ally of (Owner of (Triggering unit))) Equal to True
Collapse Then - Actions
Custom script: local unit udg_a = udg_Temp_a
Wait 1.00 Game-time seconds
Special Effect - Create a special effect attached to the chest of a using Abilities\Spells\Human\DivineShield\DivineShieldTarget.mdl
Set Temp_b = (Last created special effect)
Unit - Add Divine Shield Invonerability to a
Else - Actions
Custom script: set udg_b = udg_Temp_b
Set Temp_b = (No effect)
08-22-2007, 08:09 PM#10
DurotarLord
ah, i get what your saying.

that'd work, but in the end i just decided to convert everything to custom text and code the whole thing in half jass, half custom text converted to Jass.
08-22-2007, 08:11 PM#11
Pyrogasm
Have fun with that ><
08-22-2007, 08:14 PM#12
DurotarLord
well, i did it and it worked quite well.

right now im working on the healing part of it without using dummy units. simple enough, it just takes a little bit.