| 05-22-2007, 06:00 PM | #1 |
Cansome one give me a or any one else that reads this thread a quick lesson in Local Variables. Because i can't find them any where. - Couldd you give me a list of them? - Tell me how to work with them? - Do i need a special notice in any one of them? - Does local variabels leak? (You don't need to answer on every thing, just tell me what you know ) Like this: JASS:local unit local item local integer local trigger etz.. It's very needed for my map, because I dont like global variables. ![]() |
| 05-22-2007, 06:29 PM | #2 |
You seem to be not understanding what a variable is.. let alone the differance between a local and a global. JASS lesson time! JASS (or custrom script) is a function-based language. Functions only have one "scope", the global scope. (what this means is functions are declared in one area, the "root" of the script. Most forms of indentation highlight this by indenting a functions contents, but not the declirations) Functions take values, do stuff, then retrun. (even if they return nothing) Variables, on the other hand, hold data. The data they contain can change, but the type of data can not. (you can't store a string in an integer variable.) Variables have two scopes: global, and local. Global variables are declared at the top of the map, and can be used anywhere. They maintain the data they hold untill it is explicity changed, or the map ends. Local variables, on the other hand, are declared at the top of functions. They are local to the function they are declared in, and cannot be used outside of it. JASS:function Example takes nothing returns nothing local unit MyUnitVariable endfunction JASS:function B takes nothing returns nothing local integer h = i // Wrong. i does not exist anymore. local integer p = MyGlobalInt // This is ok, because its a global variable, and thus exists everywhere. endfunction function A takes nothing returns nothing local integer i = 10 set MyGlobalInt = i call B() endfunction Now lets discuss types in further detail. local integer i = 10 This declares a local variable named "i", and gives it the value 10. i is an integer, which means a number without a decimal point. Integers can be above or below zero. Lets look at some other types: local string s = "A string of text" Simple enogh. local real r = 12.341 Reals are numbers with a decimal point local boolean b = false Booleans hold true or false. local unit u Now for the complex part. There is a type called "handle". All types except boolean, real, integer, string, and code are sub-types of handle. What that means is any function that takes a handle can take any type that is a sub-type of handle. it also means all the types are related. For a list of handle sub-types, i suggest you read: http://jass.sourceforge.net/doc/api/index.shtml You may also find some of the JASS tutorials in the tutorial section of this site to be of use. |
| 05-22-2007, 06:30 PM | #3 |
Hmm, another "Pls help" thread :( Otherwise, ...you work in GUI, don't you? Then you need WEU or you must use custom script. Search Tutorials section, there is a tut exactly like this. |
| 05-22-2007, 06:58 PM | #4 |
Hmmm, strange request, but here: JASS:local event local player local widget local unit local destructable local item local ability local buff local force local group local trigger local triggercondition local triggeraction local timer local location local region local rect local boolexpr local sound local conditionfunc local filterfunc local unitpool local itempool local race local alliancetype local racepreference local gamestate local igamestate local fgamestate local playerstate local playerscore local playergameresult local unitstate local aidifficulty local eventid local gameevent local playerevent local playerunitevent local unitevent local limitop local widgetevent local dialogevent local unittype local gamespeed local gamedifficulty local gametype local mapflag local mapvisibility local mapsetting local mapdensity local mapcontrol local playerslotstate local volumegroup local camerafield local camerasetup local playercolor local placement local startlocprio local raritycontrol local blendmode local texmapflags local effect local weathereffect local effecttype local terraindeformation local fogstate local fogmodifier local dialog local button local quest local questitem local defeatcondition local timerdialog local leaderboard local multiboard local multiboarditem local trackable local gamecache local version local itemtype local texttag local attacktype local damagetype local weapontype local soundtype local lightning local pathingtype local image local ubersplat EDIT: WTF??? When I read this thread, he was asking for all local variable types, and know this.......I'm totally confused |
| 05-22-2007, 06:59 PM | #5 |
THX Earth-Fury, but i did already know the most I'll check the links you posted. THX Silvernon! but there is one problem... I only know about 65% of these locals.. The rest I can't understand.. But now I have them and I take a biger step into JASS. Some explenation would be needed.. ![]() |
| 05-22-2007, 07:08 PM | #6 | |
http://world-editor-tutorials.thehel...php?view=28292 Somewhere here, you have a section about local variables And when I was replying your thread, it only said something like: "can you post all locals?", it appears you've edited it Quote:
|
| 05-22-2007, 07:12 PM | #7 | |
Quote:
![]() |
| 05-22-2007, 09:24 PM | #8 | |
Heh, to be honest, I think you understand more types than I do, I started writing, but then I realized you said 65% and that means more than me :) hey people, this is a good thread to clear the meanings of all local types here! Please write here as much as you know, as I too would want to clear them out (I will finish my list later)
EDIT: Hey, don't jump all at once....... |
| 05-23-2007, 07:34 PM | #9 |
haha, ok custom scripts are just fine for me then :P |
| 05-24-2007, 05:48 PM | #10 |
Yeah :) It seems that everybody is ignoring what I said, but later they'll realize what a genius idea it was and then they'll be sorry |
