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

what are variables for?

Status
Not open for further replies.
Level 9
Joined
Dec 1, 2010
Messages
346
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.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
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).
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
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).

You seem to have misread the question. Here, let me quote it for you:
what are variables for?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
what are variables for?
A variable points to a unique area of memory capable of holding the type specified for persistant storage.
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.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
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).
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.

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

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
You cannot talk about the existance of global and local variables without mentioning their scope.
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.
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.

Also ur just confusing him like heck.
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.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
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.
no need to explain it to me, im 100% aware of how variables work

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.
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.
 
Level 9
Joined
Dec 1, 2010
Messages
346
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
 
Status
Not open for further replies.
Top