HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

vJass Region Trouble

09-02-2009, 08:49 PM#1
deathreaper945
I was just messing around with vJass, and I was wondering how you create region/rect and checks if unit enters it, and it gets transported instantly. However, I have found that one function that crashes with error 0x0000005.

Here's my vJass code:
Collapse JASS:
scope Shops initializer Init

    globals
        rect bset = Rect(20288.0, -24480.0, 20480.0, -24320.0)
        rect bsex = Rect(-27040.0 , -29184.0 , -26912.0 , -28928.0)
        rect bsin = Rect(-26656.0, -29088.0, -26592.0, -29024.0)
        rect bsout = Rect(20416.0, -24288.0, 20480.0, -24224.0)
        region bsetr = CreateRegion()
        region bsexr = CreateRegion()
        region bsinr = CreateRegion()
        region bsoutr = CreateRegion()
    endglobals

    private function Cond_bi takes nothing returns boolean
        return GetOwningPlayer(GetEnteringUnit()) != Player(1)
    endfunction
    
    private function Cond_bo takes nothing returns boolean
        return GetOwningPlayer(GetEnteringUnit()) != Player(1)
    endfunction
    
    private function Action_bi takes nothing returns nothing     
         call SetUnitPosition(GetEnteringUnit(), GetRectCenterX(bsin), GetRectCenterY(bsin))
         call DisplayTextToPlayer(GetOwningPlayer(GetEnteringUnit()), 0, 0, "Blacksmith Shop")
    endfunction
    
    private function Action_bo takes nothing returns nothing
       call SetUnitPosition(GetEnteringUnit(), GetRectCenterX(bsout), GetRectCenterY(bsout))
       call DisplayTextToPlayer(GetOwningPlayer(GetEnteringUnit()), 0, 0, "City")
    endfunction

    private function Init takes nothing returns nothing
    local trigger bi = CreateTrigger()
    local trigger bo = CreateTrigger()
    local trigger t1i = CreateTrigger()
    local trigger t1o = CreateTrigger()
    
    call RegionAddRect(bsinr, bsin)
    call RegionAddRect(bsoutr, bsout)
    call RegionAddRect(bsetr, bset)
    call RegionAddRect(bsexr, bsex)
    call TriggerRegisterEnterRegion(bi, bsetr, null)
    call TriggerRegisterEnterRegion(bo, bsexr, null)
    
    call TriggerAddCondition(bi, Condition(function Cond_bi))
    call TriggerAddCondition(bo, Condition(function Cond_bo))
    
    call TriggerAddAction(bi, function Action_bi)
    call TriggerAddAction(bo, function Action_bo)
    
    set bi = null
    set bo = null
    set t1i = null
    set t1o = null
    endfunction 
endscope

Quote:
call RegionAddRect(bsinr, bsin)
From what I observed, these calls are the cause of the crashes, and I don't know what to do.

Also, the map is insanely huge as well.
09-02-2009, 11:09 PM#2
Michael Peppers
My bet is on these lines...
Collapse JASS:
        region bsetr = CreateRegion()
        region bsexr = CreateRegion()
        region bsinr = CreateRegion()
        region bsoutr = CreateRegion()
if I remember correctly, you can't use parameters as those in a global declaration, you should use CreateRegion() in the Init function instead, and using region yourregion = null in the global declaration... try, but I'm not sure...
09-02-2009, 11:28 PM#3
GetTriggerUnit-
Quote:
Originally Posted by Michael Peppers
My bet is on these lines...
Collapse JASS:
        region bsetr = CreateRegion()
        region bsexr = CreateRegion()
        region bsinr = CreateRegion()
        region bsoutr = CreateRegion()
if I remember correctly, you can't use parameters as those in a global declaration, you should use CreateRegion() in the Init function instead, and using region yourregion = null in the global declaration... try, but I'm not sure...


This man speaks the truth, god bless him.
09-03-2009, 12:09 AM#4
deathreaper945
Thanks! That worked. I searched through lot of Jass and vJass tutorials for region/rect part and I couldn't find it. I was wondering how region were created.

Someone should make a tutorial for region and rect in Jass. Anyhow, thanks again Michael Peppers
09-03-2009, 12:16 AM#5
Michael Peppers
Quote:
Originally Posted by deathreaper945
Thanks! That worked. I searched through lot of Jass and vJass tutorials for region/rect part and I couldn't find it. I was wondering how region were created.

Someone should make a tutorial for region and rect in Jass. Anyhow, thanks again Michael Peppers

No problem, I like to help if I can

Quote:
Originally Posted by GetTriggerUnit-
This man speaks the truth, god bless him.
Thanks... BTW, you scare me...
09-03-2009, 12:35 AM#6
deathreaper945
At first, it didn't work after I fixed the CreateRegion() thing, found out that you can't set rect(x,y,xx,yy) as well on the global. Something for me to remember now :P
09-03-2009, 12:46 AM#7
GetTriggerUnit-
Quote:
Originally Posted by Michael Peppers


Thanks... BTW, you scare me...

ORLY?

Please use this parse:

Quote:
Phone Number:
Adress:
Street:
City:
Country:
State(If u.s.a):

!
09-03-2009, 12:58 AM#8
Michael Peppers
Quote:
Originally Posted by deathreaper945
At first, it didn't work after I fixed the CreateRegion() thing, found out that you can't set rect(x,y,xx,yy) as well on the global. Something for me to remember now :P

Ah, yes, now I remember, those things are functions (that give values, but still...) and in the global block you can only declare values.

Quote:
Originally Posted by GetTriggerUnit-
Please use this parse:

Quote:
Phone Number:
Adress:
Street:
City:
Country:
State(If u.s.a):

!

Don't be angry if I don't :D
09-03-2009, 01:12 AM#9
deathreaper945
Quote:
Originally Posted by Michael Peppers
Ah, yes, now I remember, those things are functions (that give values, but still...) and in the global block you can only declare values.
Ahh, I get it now! Thanks again! lol. I never knew that you can't use functions in globals..

Edit: I just thought of something, if you don't null it, wouldn't it build over time, like stacking it up each time the trigger executes?
09-03-2009, 04:11 PM#10
deathreaper945
Quote:
Originally Posted by deathreaper945
Edit: I just thought of something, if you don't null it, wouldn't it build over time, like stacking it up each time the trigger executes?

I apologize for the double post, but editing post doesn't bump the post. :(