| 04-18-2004, 03:00 AM | #1 |
im making a trigger and i want to change all of its variables to local instead of globals, so all i do is define the locals and then get rid of the udg_ in front of all the instances of the trigger, but it doesnt work. and it works fine when theyre globals. |
| 04-18-2004, 04:06 AM | #2 |
local [type] [name] Make sure you define it, you can do this by: local [type] [name] = [definition by default] Is this what you are looking for? |
| 04-18-2004, 04:09 AM | #3 |
huh... no i did heres exactly what i have local location Frozenfeetpoint = GetSpellTargetLoc() |
| 04-18-2004, 08:31 AM | #4 |
All local variables must be declared first in a function. This would work: Code:
function niceFunction takes nothing returns nothing local integer niceVar = 9*6 call doSomething( niceVar ) endfunction Code:
function badFunction takes nothing returns nothing local integer niceVar = 9*6 call doSomething( niceVar ) local string badVar = "This is to late, must be above the call statement." endfunction |
| 04-18-2004, 02:42 PM | #5 |
it was called first. and I know how to make locals i have already have 1 in this trig and like a bunch in others. thats what i think jass is most usefull for ;) keeping the var box thing clean. edit: oh and ill post my code in a little. im not on my comp right now. edit2: ok, its the kind of error where wc3 doesnt load it. Code:
function Trig_Frozen_Feet_ON_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00W' ) ) then
return false
endif
return true
endfunction
function Trig_Frozen_Feet_ON_Func005Func003001 takes nothing returns boolean
return ( DistanceBetweenPoints(GetUnitLoc(GetSpellAbilityUnit()), Frozenfeetpoint) <= 50.00 )
endfunction
function Trig_Frozen_Feet_ON_Actions takes nothing returns nothing
local location Frozenfeetpoint = GetSpellTargetLoc()
local integer i = 1
local real array speedbonus
local real speedretain = GetUnitMoveSpeed(GetSpellAbilityUnit())
set speedbonus[1] = 100
set speedbonus[2] = 125
set speedbonus[3] = 150
set speedbonus[4] = 175
set speedbonus[5] = 200
set Frozenfeetpoint = GetSpellTargetLoc()
//set udg_Frozenfeetpoint = GetSpellTargetLoc() i enable this when im using globals and it works fine
call TriggerSleepAction( 1.00 )
call SetUnitMoveSpeed( GetSpellAbilityUnit(), ( GetUnitMoveSpeed(GetSpellAbilityUnit()) + speedbonus[GetUnitAbilityLevel(GetSpellAbilityUnit(), 'A00W')] ) )
call SetUnitInvulnerable( GetSpellAbilityUnit(), true )
call SetUnitVertexColor(GetSpellAbilityUnit(), 183, 255, 255, 255)
loop
exitwhen i > 100
call IssuePointOrderLocBJ( GetSpellAbilityUnit(), "move", Frozenfeetpoint )
call SelectUnitRemove( GetSpellAbilityUnit() )
if ( Trig_Frozen_Feet_ON_Func005Func003001() ) then
set i = 100
else
call DoNothing( )
endif
call SetUnitAnimation( GetSpellAbilityUnit(), "Stand" )
call TriggerSleepAction( 0.01 )
set i = i + 1
endloop
call SetUnitVertexColor(GetSpellAbilityUnit(), 255, 255, 255, 255)
call SetUnitMoveSpeed( GetSpellAbilityUnit(), speedretain)
set i = 1
endfunction
//===========================================================================
function InitTrig_Frozen_Feet_ON takes nothing returns nothing
set gg_trg_Frozen_Feet_ON = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Frozen_Feet_ON, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Frozen_Feet_ON, Condition( function Trig_Frozen_Feet_ON_Conditions ) )
call TriggerAddAction( gg_trg_Frozen_Feet_ON, function Trig_Frozen_Feet_ON_Actions )
endfunction |
| 04-18-2004, 06:10 PM | #6 |
You will probably start to hate locals when I tell you this: Code:
function Trig_Frozen_Feet_ON_Func005Func003001 takes nothing returns boolean
return ( DistanceBetweenPoints(GetUnitLoc(GetSpellAbilityUnit()), Frozenfeetpoint) <= 50.00 )
endfunctionHow about replacing Code:
if ( Trig_Frozen_Feet_ON_Func005Func003001() ) then
set i = 100
else
call DoNothing( )
endifCode:
if ( DistanceBetweenPoints(GetUnitLoc(GetSpellAbilityUn it()), Frozenfeetpoint) <= 50.00 ) then
set i = 100
endifYou might also want to consider rewriting Code:
function Trig_Frozen_Feet_ON_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A00W' ) ) then
return false
endif
return true
endfunctionCode:
function Trig_Frozen_Feet_ON_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == 'A00W' )
endfunction |
| 04-18-2004, 10:00 PM | #7 |
no, not at all locals are still cool ;) its prolly better to have it in the main function anyways so its more organized :\ or maybe its more one..ness like eh... Thanks :D |
