variables

Official forum of the Wake of Gods mod to Heroes of Might and Magic III.
Pollo2002
Peasant
Peasant
Posts: 96
Joined: 24 Jan 2006

variables

Unread postby Pollo2002 » 17 May 2006, 05:15

Sorry i know i do a lot of questiosn, but i never learn any programming nor anything like that and i want to do some complicated stuff and it's hard to me to learn ERM.

Now ihave to ask about variables.
I use only y variables, flags and v variables because those are the only one i understand, what advantage can i ake of the other variables? specialy x and z that i see used a lot?

User avatar
Fnord
Round Table Knight
Round Table Knight
Posts: 341
Joined: 27 Nov 2005
Location: Victoria, BC, Canada

Re: variables

Unread postby Fnord » 17 May 2006, 05:27

Pollo2002 wrote:Sorry i know i do a lot of questiosn, but i never learn any programming nor anything like that and i want to do some complicated stuff and it's hard to me to learn ERM.

Now ihave to ask about variables.
I use only y variables, flags and v variables because those are the only one i understand, what advantage can i ake of the other variables? specialy x and z that i see used a lot?
x variables are used primarily when you want to pass values into a function. After the FU:P, you can list up to 16 values (or variables), separated by slashes and these will show up as x variables in the function itself. It's just a handy way of getting values in without having to use y- or v variables.

x16 is a special case because it keeps the loop value when you use a function DO loop.

z variables are different from all others because the other variables are numeric variables. z variables hold strings of characters (e.g., hero names, monster names, artifact names, hint text, words, paragraphs etc.) so they're definitely handy if you want to do anything that involves text other than displaying a simple message.

Some other useful variable types are w variables (each hero has its own set of 200 variables so for example, you could set w50 to 1 for any hero that gains some special scripted ability during the game--then just check if the hero's w50 variable is set and execute the code if it is) and y- variables which are like y variables but used for non-Function triggers (and their values carry over into any functions called by those trigger sections).
- Fnord

Pollo2002
Peasant
Peasant
Posts: 96
Joined: 24 Jan 2006

Unread postby Pollo2002 » 17 May 2006, 06:19

Thank you again :) you are always helping me

User avatar
Qurqirish Dragon
Genie
Genie
Posts: 1011
Joined: 06 Jan 2006
Location: Flying the skies of Ohlam

Unread postby Qurqirish Dragon » 17 May 2006, 13:41

Have you read the "ERM for dummies" thread? It was originally done a few years ago, but 99% of the information still works as described. It may help you in your efforts.

(and no, this was NOT just a shameless plug for my old thread :devious: )

Pollo2002
Peasant
Peasant
Posts: 96
Joined: 24 Jan 2006

Unread postby Pollo2002 » 18 May 2006, 07:26

i wanted to tell you that your erm for dummies was the first thing i readed not from here but from the erm help that comes into the wog tools, sorry if i seem like a bad student and ask things you already explained :P
but the variable thing got a little confusing to me. I'm doing scripts and really never now why should i use one variable over other exactly.
what i do is look other scripts that share common things with mine and see what variables they use, so i use those :P, for now that's working just fine.
i generally use v variables if i need to use them in other place, y variables if i need them only in the function and flags when i just need an off on variable that works on several functions. but other than that while i have some idea what they are for, i don't exactly know why. For example i see that people use variables y- and Z- and don't know why they use them exactly even i use them but i don't know why i'm doing it :S just because i see it somehwere else. I don't understand also the e variables but i don't see them used very much

User avatar
Qurqirish Dragon
Genie
Genie
Posts: 1011
Joined: 06 Jan 2006
Location: Flying the skies of Ohlam

Unread postby Qurqirish Dragon » 18 May 2006, 15:04

Pollo2002 wrote: i generally use v variables if i need to use them in other place, y variables if i need them only in the function and flags when i just need an off on variable that works on several functions. but other than that while i have some idea what they are for, i don't exactly know why. For example i see that people use variables y- and Z- and don't know why they use them exactly even i use them but i don't know why i'm doing it :S just because i see it somehwere else. I don't understand also the e variables but i don't see them used very much
y- variables are for temporary values (similar to other y variables), but they will remain unaltered by other function calls within the current function. They are basically "local" variables to a subroutine, while normal y variables are "global". Once the given function ends, however, the y- values are lost.

IIRC, z- variables are to z variables what y variables are to v variables. i.e. they are for temporary storage of text values.

e variables are to store floating-point values. They are not needed very often, as usually things can be scripted better with integer arithmetic. You should only need them if you are going to be using division by relatively large numbers. (for example, to calculate half the experience a hero has, dividing by 2 is fine, but to find one ten-thousanth of it you may want to keep the fractional part)


Return to “Wake of Gods”

Who is online

Users browsing this forum: No registered users and 3 guests