• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] How Can This Be?

Status
Not open for further replies.
Level 4
Joined
Nov 10, 2007
Messages
56
Locals In GUI

Can locals be used sucsessfuly in GUI through custom scripts? I don't know JASS (yet) but I see some advantages. I just started using custom scripts to deal with leaks and while we're at it, what leaks in GUI beside Unit Groups, Points (Locations) and Special Effects?

P.S. Sorry for the wrong thread title. I accidentaly posted two same threads and then changed this one couse I don't know how to delete it.
 
Level 22
Joined
Feb 26, 2008
Messages
891
Certainly, that is possible. But it can be tricky.

If you want true locals with GUI, your only option is to use total custom scripting. However, with some care, you can use the original GUI functions with locals.

First, create a new variable. Let's say a unit. TempUnit.

Then, in your trigger, make this the first line:

  • Custom script: local unit udg_TempUnit
Then, make the rest of the trigger how you want, using the normal GUI variable, and it will be fooled into using the local version.

NOTE: This does not work in If/Then/Else conditions, Matching functions, or unit/player group loops, since they create other functions where the local would get lost.
 
Level 4
Joined
Nov 10, 2007
Messages
56
At first I tought you can create locals like this:
  • Custom script: local unit tempUnit
then set them like this:
  • Custom script: set tempUnit = something
and then use them in actions. But now when I think about that I see how stupid I am. There's no way to choose that variable in actions couse it only offers global variables to choose from, so the action would also have to be custom script but then again almost the whole trigger would be custom script and so why not just write it in JASS? I still don't know JASS but I think I'm starting to understand it slightly, especialy now when I stared writng custom sripts to remove locations and destroy effects.

While I'm at it, I have a question. Is this also used to destroy groups:
  • Custom script: set bj_wantDestroyGroup = true
How does this work and is it better than:
  • Custom script: call DestroyGroup( udg_TempGroup)
 
Status
Not open for further replies.
Top