• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Use locals in gui

Level 7
Joined
Mar 16, 2014
Messages
152
I want to reference locals made in custom script in jass within a gui trigger.

I have seen some various spell maps do it, how do I do it?

I have been able to substitute in locals for actions during my triggers so far with minimal issue when using gui, but because of the nature of gui/jass, I can't use custom script for conditions.

If I could just manually enter the variable into the condition things would be much simpler.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Do you mean something like this?
  • Actions
    • Custom script: local integer i = 100
    • Custom script: call MyJassFunction(i)
Not too sure what you mean by Conditions. Do you mean the parameters -> ()

You can pass any variable into the parameters of a function, global or local, as long as you do it in the correct order and use the correct variable type.
 
Level 39
Joined
Feb 27, 2007
Messages
5,024
Because of how GUI generates conditions, any locals declared in the main trigger function would NOT be visible to conditions. Try converting a trigger with conditions or an If-block and you’ll see that it puts them in a separate boolean-returning function that is then evaluated.

The easiest way around this and to work with locals directly in GUI is to just assign some other global variable to whatever the local is assigned right before you need to interface with it:
  • Actions
    • Custom script: local unit SomeUnit //imagine it’s given a value at some point
    • Custom script: set udg_GlobalUnit = SomeUnit
    • Unit Group - Pick every unit in SomeGroup and do (Actions)
      • Loop - Actions
        • //local doesn’t exist in ForGroup callbacks like this
        • Unit - Cause (Picked Unit) to damage GlobalUnit dealing …
    • Custom script: set SomeUnit = null
 
Top