HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

I Hate Life!!!!!

12-02-2004, 06:36 PM#1
Sicknesslife
Here is why, I have been designing a very simple trigger to help me learn JASS the trigger is as follows. I have read it a 100 times and it seems valid to me but the editor wont compile it it keeps giving me an error (4 actually)


Code:
function Player1Creeps takes nothing returns nothing
    local location TempPoint = GetUnitLoc(gg_unit_hgtw_0006)
    call CreateUnitAtLoc(Player(0),udg_Player1CreepArray[GetRandomInt(0, 3)],TempPoint,3)
    call PolledWait(0.10)
    call CreateUnitAtLoc(Player(0),udg_Player1CreepArray[GetRandomInt(0, 3)],TempPoint,3)
    call PolledWait(0.10)
    call CreateUnitAtLoc(Player(0),udg_Player1CreepArray[GetRandomInt(0, 3)],TempPoint,3)
    local group G = GetUnitsInRangeOfLocAll(100,TempPoint)
    call GroupPointOrder(G,'attack',200,500)
    call DestroyGroup(G)
    call RemoveLocation(TempPoint)
    set TempPoint = null
    set G = null
endfunction

//===========================================================================
function InitTrig_NewCreeps takes nothing returns nothing
    set gg_trg_NewCreeps = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_NewCreeps, 4.00 )
    call TriggerAddAction( gg_trg_NewCreeps, function Player1Creeps )
endfunction

it says: expected a code statement - (for the line below)
Code:
local group G = GetUnitsInRangeOfLocAll(100,TempPoint)

then it gives my errors whenever i try to refrence G, obviously it has a problem with the way I have initialized the variable... any help?
12-02-2004, 07:54 PM#2
Ryude
local location loc=GetUnitLoc(gg_unit_hgtw_0006)
local group g=GetUnitsInRangeOfLocAll(100.00, loc)

Your trying to set a local variable after calling functions. You have to set all local variables before doing anything else.
12-02-2004, 08:01 PM#3
Kolibri
Didn't we already cover this. :)

As Ryude said all declarations of local varibles (eg. local real = 0.0) must be placed at the beginning of the function.

Fixed code:

Code:
function Player1Creeps takes nothing returns nothing
    local location TempPoint = GetUnitLoc(gg_unit_hgtw_0006)
    local group G = GetUnitsInRangeOfLocAll(100,TempPoint)
    call CreateUnitAtLoc(Player(0),udg_Player1CreepArray[GetRandomInt(0, 3)],TempPoint,3)
    call PolledWait(0.10)
    call CreateUnitAtLoc(Player(0),udg_Player1CreepArray[GetRandomInt(0, 3)],TempPoint,3)
    call PolledWait(0.10)
    call CreateUnitAtLoc(Player(0),udg_Player1CreepArray[GetRandomInt(0, 3)],TempPoint,3)    
    call GroupPointOrder(G,'attack',200,500)
    call DestroyGroup(G)
    call RemoveLocation(TempPoint)
    set TempPoint = null
    set G = null
endfunction

//==================================================  =========================
function InitTrig_NewCreeps takes nothing returns nothing
    set gg_trg_NewCreeps = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_NewCreeps, 4.00 )
    call TriggerAddAction( gg_trg_NewCreeps, function Player1Creeps )
endfunction
12-02-2004, 08:45 PM#4
Sicknesslife
yeah we did, sorry. I actually figured it out on my own but I really appreciate you guys taking the time to help
12-02-2004, 10:51 PM#5
Vexorian
World editor gives errors in the wrong way, I recomend you PJASS when you don't know what to do on syntax errors,

http://amai.wc3campaigns.com/pjass.zip

you just need to extract scripts\common.j and scripts\blizzard.j from war3patch.mpq then export your map script to this folder X , copy common.j and blizzard.j to this folder X, copy Pjass.exe there too, now make a link to it using common.j blizzard.j mapscript.j as arguments. And use that link to check errors in the map script