1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  5. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Do you have good ideas for new contests? If so, please open new threads in the Contest Submission sub-forum to discuss them.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

local udg_

Submitted by -Kobas-
This bundle is marked as approved. It works and satisfies the submission rules.

local udg_


Presented by -Kobas-

This cool trick can be used in many programming languages and jass is one of them.
Shadowing variables, as named, allow us to use global variables created in GUI variable
editor as jass local variables in our triggers. This way we can create MUI code really
easy using Custom script command line (trigger action).

Honestly this is something useful only for GUI coders these days. People who code jass
or any other "version" of it (vjass, vrust etc) already have local variables as well as many
other things on their disposal.

So for all you GUI coders out there this resource should show you how to easily create
MUI code using this trick. All you need to know (will try to explain this in the most simple
way) are next few steps:

Code (vJASS):
Your new MUI trigger
-> Events
-> Conditions
-> Actions
          1. Local variables initialization //<- NEW
          2. Regular code
          3. Memory leaks cleanup //<- NEW
 


  • test1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Avatar
    • Actions
      • Custom script: //-------------- Local variables setup --------------//
      • Custom script: local unit udg_local_Unit
      • Custom script: //-------------- Trigger code --------------//
      • Set local_Unit = (Triggering unit)
      • Hero - Modify Strength of local_Unit: Add 1000
      • Wait 60.00 seconds
      • Hero - Modify Strength of local_Unit: Subtract 1000
      • Custom script: //-------------- Memory leaks --------------//
      • Custom script: set udg_local_Unit = null

Test map has 2 more examples and all documentation required for you to go play with
this new method.

Notice: GUI variables are not same once you convert them to jass.

Example: FloatingText isn't
  • Custom script: local floatingtext udg_variable_name
instead it will be
  • Custom script: local texttag udg_variable_name
you can easy see that once converted to jass
Code (vJASS):
floatingtext // isn't highlighted
texttag // is


All this is explained in test map in BASIC part of examples.
For those who want to know more or already handle custom script with easy I have
added ADVANCED part with 2 examples, where is 1st just there for education purpose
(really simple one).


Keywords:
GUI, MUI, local, custom script, -Kobas-, ♥
Contents

local udg_ (Map)

Reviews
Moderator
22:29, 6th Jul 2014 PurgeandFire: Useful.
  1. 22:29, 6th Jul 2014
    PurgeandFire: Useful.
     
  2. Daffa

    Daffa

    Joined:
    Jan 30, 2013
    Messages:
    7,941
    Resources:
    29
    Packs:
    1
    Maps:
    8
    Spells:
    18
    Tutorials:
    2
    Resources:
    29
    Pretty much a good one, but ain't it's better as a tutorial with the map attached at the end? (Unless there's some exclusive codes in this system).
     
  3. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Was thinking about that as well, but somehow I see it more presented globally here, more people will find it here.
    Also dunno how good it is as tutorial.
     
  4. vypur85

    vypur85

    Joined:
    Jan 27, 2014
    Messages:
    158
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Pretty surprised there isn't any pseudo local 'tutorial' in Hive yet. Or is there...?

    Perhaps you could mention that the pseudo local method can only work for a single global variable.

    Also, pseudo locals do not really work in GUI condition block. This can easily be solved by globalising the local again.
     
  5. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Yeah any GUI code that split function (conditions for example) won't work here.
    Will show way around as you mentioned.

    Thanks.
     
  6. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,294
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    man, this is not a system..
    uhm, I don't know so much but, is there any difference between local without and with udg_? sorry to ask here

    edit:
    oh, or if I get this right, you localize a global variable?
     
  7. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Yeah. :D
     
  8. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,294
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    well, could be great if there is no limitations like
    :/
     
  9. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Then you create another global variable.
    If you need 3 unit variables.
    Create unit1, unit2, unit3 udg variables and use 3 custom script lines :D
     
  10. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,294
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    how about variable with array?
    if it's integer array named udg_i then, can it work with
    local integer array udg_i
    ?
    I'm noob, so much question in my head :3
     
  11. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Jass New Gen throw error, saying you can't use that name (it's already taken).
    You can use custom jass variable (that will be fine) but you can use this variable in GUI, like you do with udg_ variables where you click on blocks and shit.
    You will need to stick with custom script in this case.
     
  12. Quilnez

    Quilnez

    Joined:
    Oct 12, 2011
    Messages:
    3,294
    Resources:
    37
    Icons:
    2
    Tools:
    1
    Maps:
    7
    Spells:
    21
    Tutorials:
    2
    JASS:
    4
    Resources:
    37
    lol I understand, thnks.. good job with the system, I will rate this 4.75253035720 / 5.0 : little bit highly recommended

    btw, gui is poor, I wont use it XD
     
  13. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,261
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Very funny test map, enjoyed watching all explode. :d

    I think it would be good also to make test triggers leakless, since you clean locals, but you leak globals. (locations/effects)

    Apart from if this is right place in spell section or not, this might be useful. And it's good that you created a long list with custom script examples.

    What maybe would meaningful to note is that "TriggeringUnit" and "DyingUnit" already can be treatet like local, and so no extra local variables have to be created for them.
     
  14. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,181
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    I think this is much too simple. Personally I don't support shadowing globals. The wait can be troublesome in multiplayer.
     
  15. nhocklanhox6

    nhocklanhox6

    Joined:
    Feb 12, 2012
    Messages:
    343
    Resources:
    28
    Models:
    6
    Spells:
    21
    Tutorials:
    1
    Resources:
    28
    This is a cool trick ^^, it will help some people get out of the trouble with JASS & GUI compiler...

    Check the map below, why I can local them ? >.<

    Code
    • Dash
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
      • Actions
        • Custom script: local integer udg_II = 0
        • Custom script: local unit array udg_U
        • Custom script: local integer array udg_I
        • -------- ---------------------------------- --------
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • Set II = (II + 1)
        • Set I[II] = (Random integer number between 1 and 100)
        • Set U[II] = (Triggering unit)
        • For each (Integer A) from 1 to II, do (Actions)
          • Loop - Actions
            • Game - Display to (All players) for 30.00 seconds the text: (String(I[(Integer A)]))
            • Game - Display to (All players) for 30.00 seconds the text: (Name of U[(Integer A)])
            • Set U[(Integer A)] = No unit
     

    Attached Files:

  16. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,719
    Resources:
    18
    Maps:
    1
    Spells:
    11
    Tutorials:
    6
    Resources:
    18
    This is really nice.. so if I use this method the variable will be locally created but you can use the variable as a normal GUI variable? (in the trigger it is created that is.)
     
  17. -Kobas-

    -Kobas-

    Joined:
    Jan 17, 2010
    Messages:
    5,894
    Resources:
    28
    Icons:
    1
    Tools:
    2
    Maps:
    10
    Spells:
    4
    Template:
    5
    Tutorials:
    6
    Resources:
    28
    Exactly. :)
    And you can use same variable in many triggers. :)

    You can't define arrays like this, compiler will throw error.
     
  18. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,261
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
  19. nhocklanhox6

    nhocklanhox6

    Joined:
    Feb 12, 2012
    Messages:
    343
    Resources:
    28
    Models:
    6
    Spells:
    21
    Tutorials:
    1
    Resources:
    28