| 01-06-2003, 04:50 AM | #1 |
DigimonKiller's Variable Tutorial by DigimonKiller Written in simple English. Even a 9-year-old can get what I mean. What are Variables? Before you learn about variables, GET UMSWE FIRST FROM WWW.UMSMAPS.COM var¡Pi¡Pa¡Pble adj. Likely to change or vary; subject to variation; changeable. Inconstant; fickle. Biology. Tending to deviate, as from a normal or recognized type; aberrant. Mathematics. Having no fixed quantitative value. n.Something that varies or is prone to variation. Astronomy. A variable star. Mathematics. A quantity capable of assuming any of a set of values. A symbol representing such a quantity. For example, in the expression a^2 + b^2 = c^2, a, b, and c are variables. In WarCraft III, variables are not just integers(a number without a dot, eg. 1337), strings (some text characters(text/numbers/symbols), e.g. "MY NAME IS NOT INSTANTIUS", "I R L33T", "MEH NAME IS BILLY GATE$ AND I AM ONE OF THE CEOS AT MICRO$OFT!!!"), booleans (true/false) or reals (a number with a dot, e.g. 13.37). Besides the 4 variable-types I mentioned above, there are a lot more varaiable-types that can be used as variables. They are: variable type (what can it store) Ability (Hero/Unit Ability) Boolean (True/False) Camera Object (Camera Object) Destructible (specifc destructible) Destructible-type (a type of destructible) Defeat Condition (Defeat Condition) Dialog (Dialog) Dialog Button (Dialog Button) Game Cache (Game Cache) Game Speed (Game Speed) Integer (number without a dot) Item (specifc item) Item-type (a type of item) Leaderboard (Leaderboard) Order (Order) Player (Player) Player Color (Player Colour) Player Group (Player Group) Point (Point) Quest (Quest) Quest Requirement (Quest Requirement) Race (Race) Real (number with a dot) Region (Region) Sound (Sound) Event ID (Event) Special Effect (Special Effect) String (some text) Tech-type (tech-type) Timer (Timer) Timer Window (Timer Window) Trigger (Trigger) Trigger Condition (Trigger Condition) Trigger Action (Trigger Action) Unit (specifc unit) Unit Group (Unit Group) Unit-type (a type of unit) Unit-Targeted Unit Order (Unit-Targeted Unit Order) Ground-Targeted Unit Order (Ground-Targeted Unit Order) Destructible-Targeted Unit Order (Destructible-Targeted Unit Order) Untargeted Unit Order (Untargeted Unit Order) Unit Order (for comparisons) (unit order used for comparisons) Visiblity Modifier (Visiblity Modifier) Special Effect (Special Effect) Variables are "special boxes" that can hold only one type of "things". e.g. You don't wash your clothes with a oven and cook food with a dishwasher. e.g. If you make a integer varaiable with the name "pie" = 3.14 Then later in your triggers you can use "pie" instead of 3.14 because you defined that "pie" equals to 3.14 Arrays are just like variables, they are "boxes" with "drawers", but all the "drawers" can only hold one type of data. If the variable is set to store integers, all the "drawers" of the variable must store integers. You can add as many drawers as you want in an array variable. |
| 01-30-2003, 02:20 AM | #2 |
Guest | Anyone who has a mathematical education should know what a variable is (y=mx+b and so on). It's called algebra. Just relate that to words. george=jim*bob+joe. |
| 01-30-2003, 04:04 AM | #3 |
actually a variable in programing terms is very diffrent froma variable in math. In math a variable is an unknown factor in programing it's more of a storage for a known that can be changed. A normal variable is like a box with something in it. The name of the variable is the box, and it's value is whats in it. An array is simply a box that can hold numerous things in an orderly fashion. Quite diffrent from math, perhaps you yourself didn't know what a variable was. |
| 01-30-2003, 11:24 PM | #4 |
Guest | Well if I didn't already know what a variable is I think that that explaination is confusing. A variable in math is very simeler to programming. n=120 could be used in programming. But in programming you generally change it to cause something. So for example: you could make a program say: what is your name? what the user types in is the name. So name= Robert William XIX (If that is what the person said.) Now in warcraft you could make it address that person. So (name), how are you? might be So Robert William XIX, how are you? You can let the user set the variable and then you can use the variable later in the game. This is hard to explain. Just don't think of science experiments and variables. Independant variables and dependant variables and so on. That stuff can throw you off if you are thinking in terms of programming. I really only know BASIC so I'm not a real programmer but when you are programming variables are used a lot and can be used dynamically to make your content more interactive and interesting. I'm stating to ramble on here so I'll stop now... |
| 01-31-2003, 01:48 AM | #5 |
If you don't know you math, don't even try making a map! If you really wanna try to learn go ahead but you can't do complicated things without math skills. Using math knowledge for formulas in triggers can create such in depth triggers people wouldn't even believe to be possible. Of course if you going for Footman Madness or such you don't need to much brainpower to pull it off... but if you're going for Footman Madness then I suggest you DONT :D |
| 02-01-2003, 04:11 AM | #6 |
Guest | Yes, algebra is very important in programming. Sometimes you need functions and things like that to pull of certain tricks. I can't actually think of an example right now (at 12:03 AM) but it is true at least in normal programming (not the map editor). |
| 02-07-2003, 02:26 AM | #7 |
A reason to use variables INSTEAD of just numbers, unit types, etc... You can change a variable at any time to affect aLL related functions. For example, lets say I have monster spawners in 100 regions in my map. They spawn between (5-7) footmen. If I want to change any part of this it will cause 2 hours of work for me. But, if I make variables I can change it easy: Spawn (MonMin - MonMax) Monster1 Monmin = 5 Monmax =7 Monster1 = footman So If i want to tweak my map I can just adjust the global value for MonMin, MonMax, etc and not fix every trigger. Or, I can refer to variables with triggers. For example, to make a hard difficulty level, I can just add a vote and then [set MonMin = Monmin + 2] and the game just became harder. Neat huh? |
| 02-07-2003, 04:17 AM | #8 |
Eh theres a thing you didn't mention Parent and daughter type varaibles. Parent Type varaibles like handle are extended by daughter type variable. You can always put a daughter type varaible into a Parent Variable expression, but you can't put a parent type into a daughter. Confused? Lets go back to math as all you bastards in this thread seem to love it, but lets goto geometry. Remember your4 sided polygon? Well of them the basic types of symatry of angle and lengths are the Square, the Rectangle, the Rhombus and the Parallelogram. A square is a rhombus and its also a rectange. A rhombus and a rectangle are both types of Parallelograms. Yet not all Parallelograms are rectangles, nor are they types of rhombus. So how does this relate to variables? A UnitID/DoodadId/ItemID is a Type, a Type is an Integer.* A unit/Doodad/Item is a handle. A function/trigger is a Code. So why do I care? With the exception of the first example listed in custom Text (YES CUSTOM TEXT DUN DUN DUN) you can exploit some things. *The first example is actually kind of wierd there all just integers the game doesn't care if you use an apropriate value so you can put in for the item to create as -56890648 the game won't care it won't generate the item though. Putting an ItemId in a create a Unit statement won't make an item either. But you can save all of them as an integer and it wouldn't care in the slightest bit. I exploit this often. First when doing handle/code specific actions you don't need to actually use handle or code type varaibles. This is a good thing let me tell you as the stupid var window doesn't naturally have them listed. You can simply put in a unit for a handle varaible, or a function for a code type. But the real exploit comes here. As a return value in a function header it can say its going to return unit, but actually act as a handle. This leads too cooky results as this handle will be treated as a unit. You can have a replace function label the second unit as some unit it gets a from a function, it checks and sees this function does indeed return a unit...but what if...you return an Item? It'll do it...Creepy. My axeraider became...a treasure chest? go enjoy the knowledge of the quirks of jass codedom. |
| 02-10-2003, 03:03 AM | #9 |
Guest | What is the point in this thread if everybody here knows what variables are? |
| 02-10-2003, 08:39 PM | #10 |
visit the Official War3 forum Do a search atleast 8 Questions about what varriables are should appear, we hear at Wc3campaigns like covering our bases!!! So we add it primitively, and I'm sure this question has been asked atleast once before. |
