- Joined
- Jan 3, 2008
- Messages
- 8
Hi,
Is it better to use a global, udg_RevSpoot(integerA), for example,
or "local it" everywhere I need it?
Here is what i used and the two options :
A custom script:
Fisrt option (globals):
Second option (locals):
The fact is that i used much udg_SpootRevive(intA) in much triggers so it may be better use it than "local it" in every trigger.
Is it better to use a global, udg_RevSpoot(integerA), for example,
or "local it" everywhere I need it?
Here is what i used and the two options :
A custom script:
JASS:
function PlayerSlotState takes nothing returns boolean
return ( GetPlayerSlotState(GetEnumPlayer()) == PLAYER_SLOT_STATE_PLAYING )
endfunction
Fisrt option (globals):
JASS:
function Create_n000 takes nothing returns nothing
if ( PlayerSlotState() ) then
call CreateNUnitsAtLoc( 1, 'n000', GetEnumPlayer(), udg_SpootStart[GetConvertedPlayerId(GetEnumPlayer())], 270.0 )
endif
endfunction
function Create_ncop takes nothing returns nothing
if ( PlayerSlotState() ) then
call CreateNUnitsAtLoc( 1, 'ncop', GetEnumPlayer(), udg_SpootRevive[GetConvertedPlayerId(GetEnumPlayer())], 270.0 )
endif
endfunction
function Trig_Time_elapsed_010_Actions takes nothing returns nothing
call ForForce( udg_Team1, function Create_n000 )
call ForForce( udg_Team1, function Create_ncop )
call ForForce( udg_Team2, function Create_n000 )
call ForForce( udg_Team2, function Create_ncop )
endfunction
//===========================================================================
function InitTrig_Time_elapsed_010 takes nothing returns nothing
set gg_trg_Time_elapsed_010 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Time_elapsed_010, 0.18 )
call TriggerAddAction( gg_trg_Time_elapsed_010, function Trig_Time_elapsed_010_Actions )
endfunction
Second option (locals):
JASS:
function Create_n000 takes nothing returns nothing
local integer a
local integer b
local location array SS
set SS[2] = GetRectCenter(gg_rct_Respawn_Blu)
set SS[3] = GetRectCenter(gg_rct_Respawn_Teal)
set SS[4] = GetRectCenter(gg_rct_Respawn_Viola)
set SS[5] = GetRectCenter(gg_rct_Respawn_Giallo)
set SS[6] = GetRectCenter(gg_rct_Respawn_Orange)
set SS[8] = GetRectCenter(gg_rct_Respawn_Pink)
set SS[9] = GetRectCenter(gg_rct_Respawn_Grey)
set SS[10] = GetRectCenter(gg_rct_Respawn_Celeste)
set SS[11] = GetRectCenter(gg_rct_Respawn_DarkGreen)
set SS[12] = GetRectCenter(gg_rct_Respawn_Brown)
if ( PlayerSlotState() ) then
call CreateNUnitsAtLoc( 1, 'n000', GetEnumPlayer(), SS[GetConvertedPlayerId(GetEnumPlayer())], 270.0 )
endif
set a = 2
set b = 12
loop
a > b
set SS[a] = null
set a = a + 1
endloop
endfunction
function Create_ncop takes nothing returns nothing
local integer a
local integer b
local location array SS
set SS[2] = GetRectCenter(gg_rct_Start_Blu)
set SS[3] = GetRectCenter(gg_rct_Start_Teal)
set SS[4] = GetRectCenter(gg_rct_Start_Giallo)
set SS[6] = GetRectCenter(gg_rct_Start_Orange)
set SS[8] = GetRectCenter(gg_rct_Start_Pink)
set SS[9] = GetRectCenter(gg_rct_Start_Grey)
set SS[10] = GetRectCenter(gg_rct_Start_Celeste)
set SS[11] = GetRectCenter(gg_rct_Start_DarkGreen)
set SS[12] = GetRectCenter(gg_rct_Start_Brown)
if ( PlayerSlotState() ) then
call CreateNUnitsAtLoc( 1, 'ncop', GetEnumPlayer(), SS[GetConvertedPlayerId(GetEnumPlayer())], 270.0 )
endif
set a = 2
set b = 12
loop
a > b
set SS[a] = null
set a = a + 1
endloop
endfunction
function Trig_Time_elapsed_010_Actions takes nothing returns nothing
call ForForce( udg_Team1, function Create_n000 )
call ForForce( udg_Team1, function Create_ncop )
call ForForce( udg_Team2, function Create_n000 )
call ForForce( udg_Team2, function Create_ncop )
endfunction
//===========================================================================
function InitTrig_Time_elapsed_010 takes nothing returns nothing
set gg_trg_Time_elapsed_010 = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Time_elapsed_010, 0.18 )
call TriggerAddAction( gg_trg_Time_elapsed_010, function Trig_Time_elapsed_010_Actions )
endfunction
The fact is that i used much udg_SpootRevive(intA) in much triggers so it may be better use it than "local it" in every trigger.
Last edited: