1. 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
  2. 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 havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Variable Problem

Discussion in 'StarCraft I & II' started by Xodus, Dec 15, 2010.

  1. Xodus

    Xodus

    Joined:
    Apr 9, 2010
    Messages:
    36
    Resources:
    0
    Resources:
    0
    Ok, here's the problem. I just started doing in sc2 editor and have some problems..

    Anyway, here is the trigger. I want simple countdown system but number 9 keeps showing all the time. I know it's because of the event trigger which sets Number_Variable to its initial value every time, but how to override that?


    Number
    Events
    Timer - Every 1.0 seconds of Game Time
    Local Variables
    Number_Variable = 10 <Integer>
    Conditions
    Actions
    Variable - Modify Number_Variable: - 1
    Text Tag - Create a text tag with the text (Text(Number_Variable)) for (All players), using a font size of 24, at (Center of Region 001) and height offset 1.0, initially Visible, and fog of war enforcement set to false
    Text Tag - Show (Last created text tag) for (All players)
    Text Tag - Set the velocity of (Last created text tag) to 1.0 coordinates per second at an angle of 90.0 degrees from horizontal
    Text Tag - Set Duration time for (Last created text tag) to 2.0 seconds
     
  2. Muhahahahaaa

    Muhahahahaaa

    Joined:
    Dec 21, 2006
    Messages:
    496
    Resources:
    1
    Maps:
    1
    Resources:
    1
    use a global variable, i do not know any advantage a local var has.
    btw this is a topic for sc2 editor help zone
     
  3. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    use a global var for this problem

    local var are much better to use for function intern stuff:


    the memory they use get cleaned up afterwards.

    Global Variables will allways use some memory
     
  4. Xodus

    Xodus

    Joined:
    Apr 9, 2010
    Messages:
    36
    Resources:
    0
    Resources:
    0
    sry for missposting...

    i still cant find out how to make damn global variable. -.-
     
  5. xD.Schurke

    xD.Schurke

    Joined:
    Feb 22, 2006
    Messages:
    948
    Resources:
    5
    Maps:
    1
    Spells:
    4
    Resources:
    5
    you create it similar like a trigger, instead of trigger chose global variable ;)
     
  6. Xodus

    Xodus

    Joined:
    Apr 9, 2010
    Messages:
    36
    Resources:
    0
    Resources:
    0
    Wou, that's cool. I c i ll gonna like this sc2 editor.

    ty for help :)
     
  7. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,617
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Locals have the potential to be faster as they do not need as many memory writes as globals.

    For this problem however you definatly will need a global.
     
  8. Darkness-4ever

    Darkness-4ever

    Joined:
    Nov 4, 2007
    Messages:
    763
    Resources:
    0
    Resources:
    0
    Could still use a local variable, only instead of using Every 1.0 seconds event you could use simply Map Initialization, Time Elapsed, or no event and fire it from a different trigger telling it to run. Basically you would just have to use Repeat #(10) times and add a Wait time of 1.0 seconds at the end of the loop (waits in SC2 are far more accurate than those in WC3). Either way works fine though.
     
  9. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,617
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I forgot to add that locals only take up stack space when the function is run rather than globals which take up memory space.

    Thus, locals do not count towards the virtual machine code size limit (next to the instructions that create / manipulate them which get stored in memory) and instead count towards the stack size limit (which is near impossible to reach under normal circamstances unless huge variables or extensive recursive calls occur).

    Globals are prety much the opposite, being allocated in the virtual machine memory and not consuming any stack space at all.

    Do not think any variable is better... They both are equally useful and which gets used depends on the situation. Locals for example can not be retained outside of a function call due to being poped from the stack and lost, so for representing a group of players in team 1 for use throughout your triggers they would be completly usless where as a global perfect for this task.