HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[Help] Syntax Checkers Are Arguing

01-24-2008, 02:21 AM#1
Tide-Arc Ephemera
Collapse JASS:
function Trig_Movement_Actions takes nothing returns nothing
    local real xmax = 5120
    local real ymax = 5120
    local real xmin = -5120
    local real ymin = -5120
    local real xran = GetRandomReal(xmax, xmin)
    local real yran = GetRandomReal(yran, ymin)
    local string order = "Amov"
    local unit u = GetFilterUnit()
    local group g
    call GroupEnumUnitsOfPlayer(g, udg_CreepPlayer, null)
    loop
        set u = FirstOfGroup(g)
        call IssuePointOrder(u, order, xran, yran)
    exitwhen u==null
    endloop
endfunction

//===========================================================================
function InitTrig_Movement takes nothing returns nothing
    set gg_trg_Movement = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Movement, 10.00 )
    call TriggerAddAction( gg_trg_Movement, function Trig_Movement_Actions )
endfunction


This is a WEIRD trigger, JassDemo says that it's fine except the World Editor syntax checker is behaving in a mentally challenged fashion.

I have solved the problem but it just seems odd. Any particular reason other than it's the World Editor?

Expand My Solution:

By the way, I know it has a leak or two, but I'm just showing at the moment.

I apologize if this is considered spam.

EDIT!
Just curious, but what's the attack-move order string? Aatk?
01-24-2008, 04:28 AM#2
Tiku
Collapse JASS:
function Trig_Movement_Actions takes nothing returns nothing
    local real xmax = 5120
    local real ymax = 5120
    local real xmin = -5120
    local real ymin = -5120
    local real xran = GetRandomReal(xmax, xmin)
    local real yran = GetRandomReal(yran, ymin)
    local string order = "Amov"
    local unit u = GetFilterUnit()
    local group g = CreateGroup()
    call GroupEnumUnitsOfPlayer(g, udg_CreepPlayer, null)
    loop
        set u = FirstOfGroup(g)
        call IssuePointOrder(u, order, xran, yran)
    exitwhen u==null
    endloop
    call GroupClear(g)
    call DestroyGroup(g)
    set g = null
    set u = null
endfunction

//===========================================================================
function InitTrig_Movement takes nothing returns nothing
    set gg_trg_Movement = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Movement, 10.00 )
    call TriggerAddAction( gg_trg_Movement, function Trig_Movement_Actions )
endfunction

That should fix the leaks...
Hopefully it works :D
01-24-2008, 05:17 AM#3
chobibo
Collapse JASS:
    loop
        set u = FirstOfGroup(g)
        call IssuePointOrder(u, order, xran, yran)
        exitwhen u==null
        call GroupRemoveUnit(g, u) // remove units from the group so it won't loop forever
    endloop
01-24-2008, 06:18 AM#4
tamisrah
Collapse JASS:
    local real yran = GetRandomReal(yran, ymin)

This just shouldn't work, that's the reason for the "mentally challenged behavior of the WE syntax-checker.
You can not refer to undefined variables!

Another thing is that you probably want to get a random number between +5120 & -5120, right?
Than you'll have to switch the max and min values because:
Collapse JASS:
native GetRandomReal takes real lowBound, real highBound returns real
takes first the min value and then the max value.
01-24-2008, 06:52 AM#5
xombie
tamisrah is correct. The first time I went over it I didn't see it I thought you were using all defined variables, but yes you cannot reference a variable in its own declaration.

Collapse JASS:
local real x = x + 5
local real y = y + 2

Doesn't make much sense, does it? Anyways, good job tamisrah.
01-24-2008, 07:40 AM#6
PipeDream
it could make sense because that compiles to
local real y
set y = y + 2
and there could be some sane default like 0.. unfortunately that's not true and so it is in fact completely bogus.
fortunately it turns out you can conservatively do the analysis to prove that code is bogus w.r.t. undefined variables and not get swamped in false positives: http://hilton.gw.oiccam.com/showthread.php?t=89160
01-24-2008, 08:22 AM#7
Tide-Arc Ephemera
Oh the yran did have a small error. I'll look over that.