HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Variables Tutorial - Covers Every Variable Type

06-21-2005, 04:21 PM#1
Koga73
Variables:
Ok, so... what is a variable? a variable is a piece of information that is temporarily stored within the ram of a computer. All variables have names, the name of the variable allows for it to be recalled at any time, and allows for the computer to access the correct bit of memory to read. The value of a variable is the information that is stored within it. So, for example:

set intNothing = 4

that would make the variable intNothing (an integer variable type) to be set to 4 within the ram.

Arrays:
Ok, so whats an array? an array is part of a variable. Normally, 1 variable stores or contains 1 value only, an array allows 1 variable to store multiple values. So, imagine an array as a "shelf". Each shelf of the shelf contains different stuff. So, for example:

set intNothing[1] = 7
set intNothing[2] = 3

Now, the above is setting different "slots or shelves" of the variable to different values. So, intNothing[1] can contain one number, where as the second slot [2] can contain a different value. Pretty simple huh.

Simulated Diminsional Arrays:
Now that you got arrays down, lets talk about what a diminsional array is. A diminsional array contains multiple pieces of data much like a normal array does, however is a little more orginized. They r great for if you want to set values for each player x alot of values. So, in programming, we would do something like this:

dim intXY(1 to 10, 1 to 10) as integer
intxy(1,1) = 4
intxy(5,7) = 3

now, wc3 has limitations on diminsional arrays, so we cant quite do it this simply. But imagine diminsional arrays as a "grid" the first number is x, second is y, and u can go to infinite amount of diminsional array sizes. So, 1,1 would b like saying player 1 slot 1, 5,1 would be setting player 5s slot 7 within the array or whatever. To accomplish this in WE, we would use something similar to the following:

set intNothing[(player number x 100) + slot number] = value

ok, now... lets say we want to set player 5s slot 7 to equal 154... plug in the numbers... 5 (player 5) x 100 = 500 then + 7 (slot 7) = 507. So, player 5s slot number 7 is array slot number 507. Simple smile.gif. practice this a bit smile.gif

Ok ok, now for the list of varible Types and explinations:

***Ability - this stores a specifc ability, can be used if you are doing something like if a unit casts an ability, you can set this variable to the ability that the unit cast.

***Attack Type - this stores the type of attack a unit has such as spells, normal pierce, chaos, etc.

***Boolean - boolean expressions are either True or False, so if you want to check if a unit has something or something happend in the game, just set a boolean to True. and then recall and check it with conditions later

***Buff - a buff is something attached to a unit such as POISONED or whatever, this stores buffs.

***Camera Object - this stores a specific camera object created within the camera pallete. So, set your cameras to variables or in an array of camera objects, and u can use a for loop to pan to all in the array.

***Damage Type - this contains types of damage such as normal, divine, magic, etc.

***Destructable - this stores soemthing such as a specific gate or tree used ingame.

***Destructable-Type - this stores a type of destructable rather than a specific one such as a type of gate or a type of tree.

***Defeat Condition - this is used to store defeat conditions when used with quests.

***Dialog - this stores a specic dialog created through a trigger, dialogs r those menus taht you see in maps that "pop up" and u can click a button.

***Dialog Button - this stores the last created or a button created for a dialog menu.

***Floating Text - this stores a specific floating text, normally used with Last Created Floating Text.

***Game Cache - this stores a game cache created for save/loading in SINGLE PLAYER, this doesnt work online.

***Game Speed - this stores the speed of the game, Slowest, Slow, Fast, etc.

***Integer - this stores NEGITIVE AND POSSITIVE WHOLE NUMBERS ONLY! this is probably the most used variable, it stores numbers such as -73, -1, 0, 37, 73, any whole number without decimals.

***Item - this stores a specific item in the map, so if you set ITEM to = a certin key on the map, it will rememvber that specific key, not the type of the key/item.

***Item-Class - This stores the class of an item such as Permant, Charged, Artifact, etc.

***Item-Type - this stores a type of an item such as key or something similar, but a type, not a specific key or item.

***Leaderboard - this stores a leaderboard created ingame, a leaderboard is the little list at the top left that contains all player names or what you want it to say, and vales that coorespond.

***Multiboard - same thing as a leaderboard basically, xcpt with multiboards, multis can contain any text and multiple values whereas leaderboards cannot.

***Order - this stores an order such as an order givin like Stop, Attack, Attack-Ground, Hold, etc.

***Player - this stores a specific player, so i could set player = player 3 - teal.

***Player Color - Pretty simple, a color of a player such as teal or red.

***Player Group - this stores multiple players, you can use the player group actions to add players into the variable.

***Point - this is one of the more useful variables id say, it stores a specific point on the map, so, it could store a position of a unit, a spot of where a region is located, etc.

***Quest - this stores a specific quest that is created with triggers.

***Quest Requirement - this stores a requirement for a quest that was created.

***Race - this stores a race of a player such as Human, Ord, Undead, NE.

***Real - this is the saem as an integer, except this can contain decimals, so this can store any number, such as 3.14, 73.2, -65.07, etc. However, it is recommend that you use integers whenever possible, real values take up more space within ram.

***Region - this stores a specific region that was created with the region pallete.

***Sound - this stores a sound created inside the sound editor.

***Special Effect - this stores a special effect, it is normally used with Last Created Special Effect, this action is great for attaching special effects to units, setting it to a variable, then later, removeing the special efect by using the variable.

***Lightning - this stores a lightning special effect created, basically saem as above.

***String - a string contains text, so "dasdagrftr3434" could be saved into a string variable, and recalled later. These are VERY useful!

***Tech-Type - this stores a type of upgrade such as barrage, animal war training, iron plating, etc.

***Terrian Deformation - this stores an enviornmental actions terrian deformation or change, use this after you make a transformation and set it to the last created terrain deformation.

***Timer - this sets a varible to a timer created with the CountDown Timer actions. This is needed if you want another trigger to run when the event - TIMER EXPIRES happens, set your EXPIREING TIMER in the event to the timer stored in this variable.

***Timer Window - this contains the window that the timer is stored in. pretty simple.

***Trigger - this stores a specific trigger, its mainly used to set the variable first, then when you perform a TRIGGER action, you can turn off - VARIABLE rather than setting a specific trigger.

***Unit - this stores a specific unit on the map.

***Combat Sound - this stores a sound of attack such as METAL LIGHT CHOP, METAL HEAVY HIT, etc.

***Unit Group - this stores multiple units into a variable, so all can be manipulated at once, use the UNIT GROUP actions with this to put untis into the variable and manipulate them.

***Unit-Type this is the type of a unit, this is used alot in maps such as tds when you need to set each level to a different enemy type, then later, you can spawn the type within the variable.

***Visibility Modifer - this will store the last created visibility modifer made with the visiblilty actions, its great for destroying the visibility later ingame.

***Weather Effect - this stores weather effects such as rain, fog, snow, etc.

***Effect Type - This is used to set the effect type of a spell or attack. This is set to things such as Effect Art, Targert Art, Caster Art, etc.

***Sound Type - this sets the varialbe to Effect Sound, or Effect Sound Looped of a targeted sound.

Thats all the variables in the World Editor as of patch v1.17, please make sure to practice often!