1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

what are variables for?

Discussion in 'Triggers & Scripts' started by vlekje5, Sep 6, 2012.

  1. vlekje5

    vlekje5

    Joined:
    Dec 1, 2010
    Messages:
    255
    Resources:
    0
    Resources:
    0
    hello folks,
    i've been experimenting with the trigger editor but i can't get out how to use that variables, i can't get out making them work and and getting them to do something
    they have like arrays? (i think )
    idk what to put in ,

    thanks.
     
  2. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
  3. vlekje5

    vlekje5

    Joined:
    Dec 1, 2010
    Messages:
    255
    Resources:
    0
    Resources:
    0
  4. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,188
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    A variable points to a unique area of memory capable of holding the type specified for persistant storage. When compiled the variable is translated to an address which makes up part of an instruction.

    JASS is semi-interpreted so resolves addresses in real time using a hashtable and the variable name (why it is so slow).
     
  5. rulerofiron99

    rulerofiron99

    Joined:
    Jul 10, 2006
    Messages:
    3,129
    Resources:
    14
    Maps:
    4
    Spells:
    9
    Tutorials:
    1
    Resources:
    14
    You seem to have misread the question. Here, let me quote it for you:
     
  6. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,188
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    You seem to have misread my answer...

    You use them to interact with memory allowing you to store data for use at a later time. In the case of globals this memory is from the program heap while in the case of locals this memory is from the thread stack.
     
  7. muzzel

    muzzel

    Joined:
    Jun 27, 2008
    Messages:
    1,303
    Resources:
    2
    JASS:
    1
    Wurst:
    1
    Resources:
    2
    most retarded answer ever, srsly. He clearly didnt understand a single word -


    Variables are used to store any kind of value to access it later, they have a name that is used to identify them. Lets say you want to create a spell that summons 15 units over a period of time. Then you start a timer or use a periodic event to create a unit each 2 seconds. To make sure you stop after you have 15 units, you can use a variable which holds the current number of units.
    Like this (pseudocode):

    Code (Text):

    initialization:
        set variable i to 0

    every 2 seconds:
        if i is smaller 15 then
            create unit
            increase i by 1
        end
     
    There are different types of variables, the one i just used is an integer (stores numbers without decimal point), there are variables for units, specialeffects, strings, boolean (true/false), and much more.
     
  8. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,188
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Atleast I bothered to mention local variables, something you clearly skipped out despite them being far more useful than global variables when programming in real life. Even in JASS they are very useful.
     
  9. muzzel

    muzzel

    Joined:
    Jun 27, 2008
    Messages:
    1,303
    Resources:
    2
    JASS:
    1
    Wurst:
    1
    Resources:
    2
    Im not sure if ur trolling or just dumb. Plz help me out here :vw_wtf:

    You cannot talk about the existance of global and local variables without mentioning their scope. Also ur just confusing him like heck.
     
  10. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,188
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Which is what I did. Program heap is shared between all threads of a program. Stack is unique to each thread of a program and is altered in frames that are generated when a function is called and poped when the function returns.

    A stack is a first in first out queue. Think of it as a pile of paper on a desk where you place more paper on top when adding to the stack and take paper off the top when removing from the stack.

    By telling him facts? I admit some of them are more generic than just WC3 but in the long term he will find them much more useful than knowing how JASS (a rather bad scripting language) does something.
     
  11. muzzel

    muzzel

    Joined:
    Jun 27, 2008
    Messages:
    1,303
    Resources:
    2
    JASS:
    1
    Wurst:
    1
    Resources:
    2
    no need to explain it to me, im 100% aware of how variables work

    what ur saying is completely true, but it doesnt help him. When someone tries to explain something to you that you dont know at all, he wont use the formal definition but a more simple way explanation. He has to understand the basic purpose of variables, later he can learn about how they work in detail.
     
  12. vlekje5

    vlekje5

    Joined:
    Dec 1, 2010
    Messages:
    255
    Resources:
    0
    Resources:
    0
    i think got evry single detail now xD ya guys don't need to fight for that
    i currently can't use world editor but when i'm back i'm gonna experiment with it starting with easy stuff like the timer stop thing and if that works out i'm on the track;
    thanks you guys u'r both awnsers helped and filled up eachother

    +1 for both