• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Use locals in gui

Status
Not open for further replies.
Level 7
Joined
Mar 16, 2014
Messages
169
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 73
Joined
Aug 10, 2018
Messages
7,866
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 45
Joined
Feb 27, 2007
Messages
5,578
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
 
Status
Not open for further replies.
Top