• 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.

[Trigger] Using locals in GUI

Status
Not open for further replies.
Level 40
Joined
Dec 14, 2005
Messages
10,532
If you want to have a single local, and be accessible IN the GUI functions, then..

Assuming you have a Global variable of type globaltype and name Global_name.

Add this line as the first action of your trigger:

  • Custom script: local globaltype udg_Global_name
Now you can reference the global and it will actually reference the local instead.

However, this only works for one variable per trigger - with more, conflicts occur.

You can still, however, add an indefinite amount of Jass-only locals by writing

  • Custom script: local type name
(where type is the variable type and name is its name)

But these may only be accessed from other "Custom Script" actions.
 
Level 12
Joined
Mar 23, 2008
Messages
942
Thanks ^^
I will try it!

Edit: What do you think its best?
  • BackSlash Wave Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bakuryuha (based in war stomp)
    • Actions
      • Custom script: local Timer udg_temptimer
      • Unit - Add BackSlash Wave (effect) to (Casting unit)
      • Countdown Timer - Start temptimer as a One-shot timer that will expire in (Real((Level of Bakuryuha (based in war stomp) for (Casting unit)))) seconds
      • Wait until ((Remaining time for temptimer) Equal to 0.00), checking every 0.50 seconds
      • Unit - Remove BackSlash Wave (effect) from (Casting unit)
Or

  • BackSlash Wave Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bakuryuha (based in war stomp)
    • Actions
      • Unit - Add BackSlash Wave (effect) to (Casting unit)
      • Wait (Real((Level of Bakuryuha (based in war stomp) for (Casting unit)))) seconds
      • Unit - Remove BackSlash Wave (effect) from (Casting unit)
 
Level 12
Joined
Mar 23, 2008
Messages
942
Use the second one (there is no point to use a timer for this).
Also change the 'Casting Unit' to 'Triggering Unit', as casting unit doesn't work after waits.
Everyone says that, BUT WORKS.
Every time I put that trigger or other similar someone says that, never gave me problems, worked 100% time.

----------

But everyone tells waits are delayed in multiplayer game, and this map is 6x6.
I need this to be precise.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
But you're using a wait anyways...

The way you use timers properly can only be done with Jass (or "Custom Scripts") and doesn't work very well in GUI either way.

Example timer use:

JASS:
function Blahblah_Child takes nothing returns nothing
    call DestroyTimer(GetExpiredTimer())
    //do stuff
endfunction

function BlahBlah takes nothing returns nothing
    call TimerStart(CreateTimer(),.5,false,function Blahblah_Child)
endfunction

A "one-shot" timer that will execute Blahblah_Child after .5 seconds.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
  • Wait until ((Remaining time for temptimer) Equal to 0.00), checking every 0.50 seconds
This uses a loop that uses TriggerSleepActions, so there is no point in using it instead of just calling it directly.

To make it clearer (about what PurplePoot said) you cannot use timers in GUI to make MUI spells. It is best combined with a system for local variable access, like Katana's.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
But the problem is, I'm not very good with JASS.
So I will need someone to convert all my triggers that use waits to Jass for me...

  • BackSlash Wave Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bakuryuha (based in war stomp)
    • Actions
      • Unit - Add BackSlash Wave (effect) to (Triggering Unit)
      • Wait (Real((Level of Bakuryuha (based in war stomp) for (Triggering Unit)))) seconds
      • Unit - Remove BackSlash Wave (effect) from (Triggering unit)
This is just fine. Don't use Jass if you don't know it :/
 
That whole thing about waits being delayed in multiplayer is just because waits are a little more delayed when there are more players. I think... I heard something about this at wc3jass.com....

But anywho, it isn't something to worry about too much. The difference will be minimal, probably the MAXIMUM difference unless you seriously screw up will be 1 second. It will actually probably be only about a 0.0# difference or something low like that. Or maybe even 0.# but it isn't like people are really counting the seconds, you know?

:p

Timers are more accurate, but the downside is the callback function... If you use GUI, you shouldn't worry too much, it will hardly affect your map. ;)
 
Level 4
Joined
Jul 23, 2007
Messages
129
On the subject of waits, I noticed there are two types of waites in GUI. Game time seconds and real time seconds, or something like that. I don't clearly remember the names.

What is the difference between the two? Is one better for using in multiplayer maps than the other?
 
Level 1
Joined
Aug 24, 2007
Messages
2
Wouldn't you need to do the following...?

  • BackSlash Wave Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bakuryuha (based in war stomp)
    • Actions
      • Custom Script: local unit triggering_unit = GetTriggerUnit()
      • Unit - Add BackSlash Wave (effect) to (triggering_unit)
      • Wait (Real((Level of Bakuryuha (based in war stomp) for (triggering_unit)))) seconds
      • Unit - Remove BackSlash Wave (effect) from (triggering_unit)
It was my understanding that when you used a Wait you lose the value of any global variables (like Triggering Unit) the next time something uses them.

Using a local to store the value of Triggering Unit avoids this difficulty, does it not? The person who implied you can only access Custom Scripted local vars with other Custom Scripts was wrong.

Please advise.

Take care,

Morcrist
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Agreed, basic JASS learning is easy and fast.
My advice - convert some base GUI trigger study it, use the(yes, 'the', as this tread is about locals) locals.
Piece by piece you will learn more, eventually getting comfortable and capable of improving most of the trigger.
And Jass requires no more logic than the GUI triggering.
 
Status
Not open for further replies.
Top