set local or no to set

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

Post Reply
Equal
Newcomer
Posts: 8
Joined: February 18th, 2007, 10:26 pm
Location: Germany
Contact:

set local or no to set

Post by Equal »

Hi there ... so

i just wanna know if it matters:


function Trig_asfd_Actions takes nothing returns nothing
local unit toteEinheit = GetDyingUnit()
call TriggerSleepAction( 20.00 )
call ReviveHeroLoc( toteEinheit, GetRectCenter(GetPlayableMapRect()), false )
endfunction


in the local line the

local unit toteEinheit = GetDyingUnit()


so does it matters if i write it so or so:

set local unit toteEinheit = GetDyingUnit()

or is it ok to write it without the set cuz i define it at begining?

pls some help
10 X =
User avatar
Totti_8
S.M.B. Creator
Posts: 84
Joined: January 20th, 2007, 11:32 am
Location: Germany
Contact:

Post by Totti_8 »

Its:

local unit toteEinheit = GetDyingUnit()
Equal
Newcomer
Posts: 8
Joined: February 18th, 2007, 10:26 pm
Location: Germany
Contact:

Post by Equal »

so when i use the "set" ?

a example would be nice.
thx for HELP :)
10 X =
User avatar
Aero
Forum Staff
Posts: 830
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Post by Aero »

Never use "set" in your local variable declarations

The only time you use "set" is if the variable can potentially be altered beause of a condition OR you're nullifying it:

ex:
function example takes nothing returns nothing
local integer i = 1
if (Condition) then
set i = i*1.2
else
set i = i*1.5
endif
endfunction
Equal
Newcomer
Posts: 8
Joined: February 18th, 2007, 10:26 pm
Location: Germany
Contact:

Post by Equal »

wow thx thats what i just wanna know ^^ great , ...

ehm jeah i have another question (not rili one)

why does i need endfunction if i have return and it will never reach the end ?
or does it jump from return instantly to endfunction so i need it anyway?
10 X =
User avatar
Aero
Forum Staff
Posts: 830
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Post by Aero »

Are you talking about

function x takes nothing returns boolean
return(_______)
endfunction

?
Equal
Newcomer
Posts: 8
Joined: February 18th, 2007, 10:26 pm
Location: Germany
Contact:

Post by Equal »

no i was talking about if i write :

function x takes nothing returns boolean
return(_______)

------------------------------------------------------

is the same as i write
function x takes nothing returns boolean
return(_______)
endfunction

......
but after time ^^ and learning i just get it that the endfunktion is a needed
part of it so just forget it ^^ and THX
10 X =
User avatar
Aero
Forum Staff
Posts: 830
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Post by Aero »

You need to have an endfunction because when the script compiles it will looks like this

function xxx takes nothing returns boolean
return(________)
function yyy takes nothing return nothing

And then the game doesn't know what to do with the function because it doesn't "end"

It's like trying to loop without putting an 'endloop' ...it just doesn't work O.o
Post Reply