HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help, Please!

05-22-2007, 06:00 PM#1
Pinzu
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:

Collapse 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
Earth-Fury
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.
Collapse JASS:
function Example takes nothing returns nothing
    local unit MyUnitVariable
endfunction
When the function is called (used), the variable will be "created". When the function returns, the variable will be out of scope, and stop existing. Example:
Collapse 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
CommanderZ
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
Silvenon
Hmmm, strange request, but here:

Collapse 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
Pinzu
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
Silvenon
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:
every think must be a Function that dosn't work? THX ANYWAY!
???
05-22-2007, 07:12 PM#7
Pinzu
Quote:
???
Sorry I don't know what came into me, it has been removed and reedited..
05-22-2007, 09:24 PM#8
Silvenon
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)

Hidden information:
event = when you make a trigger in GUI that has an event, convert it to JASS and at the bottom you'll see something like PLAYER_EVENT_EFFECT (this event probably doesn't exist, but this is how it looks like)
player = well, you probably know that, it can be Players(0-12), Neutral Hostile and Passive
widget = anything on the map that has a life bar (I usually use units)
unit = you probably know this
destructable = in wc3, except in JASS, it's called destructible, so I'm confused......anyways example destructable is a tree
item = any item from item section in unit palette
ability = ability that a hero has, for example Thunder Clap
buff = this results a tiny icon in the unit's status, for example when it is stunned, it will show a stun icon "this unit is stunned....."
force = I think this is a group of players
group = a group of units
trigger = a trigger :P
triggercondition = not exactly sure
triggeraction = not exactly sure
timer = a timer that can call a function when expires, it can be one-shot or repeative
location = a point that consists of to coordinates, x and y
region = it can consist of rects
rect = similar to regions, but I'm not exactly sure, in GUI both rects and regions are called regions
boolexpr = a pointer to a boolean value, a function, for example GUI has pick every unit in range matching (this is the example of boolexpr usage)
sound = a sound, internal or external (there are some in Sound Editor)
conditionfunc = not sure, but I think it has something to do with boolexprs....
filterfunc = same as conditionfunc, boolexprs can be Filter or Condition, there isn't any difference, I think
unitpool = forgot what it was
itempool = same as unitpool
race = human, undead, night elf, or orc, though I don't know what it looks like.....
alliancetype = AI field, I think, and I don't do AI :)
racepreference = I have no idea
gamestate = I have no idea
igamestate = I have no idea
fgamestate = I have no idea
playerstate = I have no idea
playerscore = I have no idea
playergameresult = I have no idea
unit state = it can be current/max mana/life of a unit (example life: UNIT_STATE_LIFE)
aidifficulty = AI
eventid = dunno
gameevent = not sure, an event type I think
playerevent = same
playerunitevent = same
limitop = I'm dying to know this
widgetevent = not sure, an event type I think
dialogevent = same
unittype = a type of unit, for example footman


EDIT: Hey, don't jump all at once.......
05-23-2007, 07:34 PM#9
Pinzu
haha, ok custom scripts are just fine for me then :P
05-24-2007, 05:48 PM#10
Silvenon
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