• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Problem with defining rect arrays.

Status
Not open for further replies.
Level 4
Joined
Feb 2, 2009
Messages
71
I get an errormessage on this line:
JASS:
set reg = RegionAddRect(reg, Sandbox)
Cannot convert nothing to region.

It seems like it reads that Condition before the Sandbox[0-11] is defined, but after it is declared.
Is there any way to define the rects before Conditions are read?

JASS:
globals
    rect array Sandbox [11]
    real array SandboxCenterX [11]
    real array SandboxCenterY [11]
    force TeamWest
    force TeamEast
endglobals

scope setVariables initializer setThis
    private function setThis takes nothing returns nothing
        local integer i = 0
//-----------------
//    Set Sandbox Rects
//-----------------
        set Sandbox[0] = gg_rct_SandBoxP1
        set Sandbox[1] = gg_rct_SandBoxP2
        set Sandbox[2] = gg_rct_SandBoxP3
        set Sandbox[3] = gg_rct_SandBoxP4
        set Sandbox[4] = gg_rct_SandBoxP5
        set Sandbox[5] = gg_rct_SandBoxP6
        set Sandbox[6] = gg_rct_SandBoxP7
        set Sandbox[7] = gg_rct_SandBoxP8
        set Sandbox[8] = gg_rct_SandBoxP9
        set Sandbox[9] = gg_rct_SandBoxP10
        set Sandbox[10] = gg_rct_SandBoxP11
        set Sandbox[11] = gg_rct_SandBoxP12
        
//-----------------
//    Set Team Sandbox Rects
//-----------------
        set i = 0
        loop
            exitwhen i > 11 
            set SandboxCenterX[i] = GetRectCenterX(Sandbox[i])
            set SandboxCenterY[i] = GetRectCenterY(Sandbox[i])
            set i = i + 1
        endloop
    endfunction
endscope

scope easyMove initializer Init
    private function Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local location loc = GetOrderPointLoc()
        call IssueImmediateOrder(u, "stop")
        call SetUnitPositionLoc(u, loc)
        
        call RemoveLocation(loc)
        set u = null
        set loc = null
    endfunction
    
    private function Conditions takes nothing returns boolean
        local integer p = GetPlayerId(GetTriggerPlayer())
        local region reg = CreateRegion()
        local boolean result
        set reg = RegionAddRect(reg, Sandbox)
        set result = ( (GetUnitAbilityLevel(GetTriggerUnit(), 'Sand') > 0) and IsPointInRegion(reg, GetOrderPointX(), GetOrderPointY()) )
        call RemoveRegion(reg)
        set reg = null
        return result
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger Trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( Trig, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
        call TriggerAddCondition( Trig, Condition( function Conditions ) )
        call TriggerAddAction( Trig, function Actions )
    endfunction
endscope
 
Level 14
Joined
Nov 23, 2008
Messages
187
Watch your syntax:

JASS:
native RegionAddRect takes region whichRegion, rect r returns nothing

so you have to change that:
JASS:
set reg = RegionAddRect(reg, Sandbox)

to this:
JASS:
call RegionAddRect(reg, Sandbox)

And why just not to put function setThis in easyMove scope (and, of course, put call setThis() into Init function)?
 
Level 4
Joined
Feb 2, 2009
Messages
71
*blushing*
...that was maybe the stupidest mistake I've made haha. It returns nothing.
Well thank you anyway.

And why just not to put function setThis in easyMove scope (and, of course, put call setThis() into Init function)?
Because easyMove will be used very frequently in my map, and setThis only needs to be run once.
I thought it would spare me some cpu.

EDIT: Nevermind, I think I got it now. Thank you again!
 
Status
Not open for further replies.
Top