• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Locals

Status
Not open for further replies.
Level 16
Joined
Mar 3, 2006
Messages
1,564
To declare:

JASS:
function fn takes nothig returns nothing
local unit u
local real r
local integer i
local boolean tf
// in general: local  TYPE VARNAME
endfunction

Note: you can't use locals outside a function

As for removing, you don't need to worry about them they are local. Just remove anything that will leak.
 
Level 10
Joined
Aug 19, 2008
Messages
491
You can't declare locals in MUI. MUI just describes if something can be used by everyone without bugs.
However in Jass you can declare a local variable that can only be accessed by that perticular function.
Like so:
JASS:
function SomeFunction takes integer my_int returns boolean
    local boolean b = true
    local unit some_name = GetTriggerUnit()
    local integer i
    set i = my_int //The function has taken my_int as an argument, look in the function decleration
                   //In this case, my_int is 1 since SomeOtherFunction (below) passed on 1 to this function
    return b //the funcion wanted to return a boolean, so here we do it
endfunction

function SomeOtherFunction takes nothing returns nothing
    call SomeFunction(1)
endfunction

//In general you type "local [type] [name] = [value]" where "= [value]" is optional
 
Status
Not open for further replies.
Top