System Rectwraps

Azlier

Old World Ghost
Reaction score
461
Rectwraps Bonus Plugin #1 operational.

Anyone have any rect-using systems I could make plugins for?
 

Azlier

Old World Ghost
Reaction score
461
Plugin #1 internalized, gaining efficiency. Also added the .setPathing method, which switches a pathingtype for an entire rectwrap on or off.
 

Azlier

Old World Ghost
Reaction score
461
Added a new method called .iterateThrough. I might use it someday.
 

Azlier

Old World Ghost
Reaction score
461
Update to make .replaceTerrain, .setPathing, and .iterateThrough have much less chance of hitting the op limit. [del]Not even the normal ReplaceTerrain system does that for you :p.[/del] Wait, yes it does. :(
 

Azlier

Old World Ghost
Reaction score
461
At last, I can rest in peace :D. (I'll wake up sooner or later.)
 

Azlier

Old World Ghost
Reaction score
461
Update (How is that possible?!). The .minX and friends properties can now be set, and the rectwrap will conform to them. Also added four more methods.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Ok, i need to play with rects/reg so i've take a look on this script.
I've read it quickly and some things hurt me, but i could be wrong though, you will tell me.

1) Are you sure you recycle the region ?

For me you create a region all the time, or add rects to it.
You could try to use RegionClearRect with GetWorldBounds(), even if in fact you would need to use a rect variable instead of GetWorldBounds, since it creates a new rect at each call.
But i dunno if simply using RemoveRegion/CreateRegion(), instead would be better or not (benchmark ? ...).

2) You create one region for the enter and other for the leave event ?


One for both is enough.

3) When you change the size or whatever of the rect you don't change the eventual region associated to it as well ?

But maybe you don't need, currently i haven't played at all with dynamic regions, only static ones.
 

Azlier

Old World Ghost
Reaction score
461
I'm very sure that the stuff is recycled. And, yes. Excellent point. Exit and enter can share a region. Now I just need to figure out how to do that efficiently.

The replaceTerrain type methods seriously need a rewrite.

>For me you create a region all the time, or add rects to it.

Hmm? I only create the region once, and add the rect once. I only disable triggers when required.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I mean when an instance of a struct is recycled after a destroy, so the region already contains one rect, and you add a new one instead of clear it and add the new rect.

Maybe it would help you or not,you can keep the 2 variables and only one region created.
set handle1 = handle2
 

Azlier

Old World Ghost
Reaction score
461
Err... could you explain that again?

>and you add a new one instead of clear it and add the new rect.

Please... I don't understand that at all.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
JASS:
library Test initializer init uses rectwrap

private function Actions takes nothing returns boolean
    call BJDebugMsg("unit enter region")
    return false
endfunction

private function init takes nothing returns nothing
    local rectwrap s_rect = rectwrap.create(32.,64.,32.,64.)
    local trigger trig = CreateTrigger()
    local unit u = CreateUnit(Player(0),'hpea',0.,0.,0.)
    
    call TriggerAddCondition(trig,Condition(function Actions))
    
    call s_rect.registerEnter(trig)
    
    call TriggerSleepAction(1.)
    
    call BJDebugMsg("move unit")
    call SetUnitPosition(u,50.,50.)
    call SetUnitPosition(u,0.,0.)
    
    call TriggerSleepAction(1.)
    
    call s_rect.destroy()
    set s_rect = rectwrap.create(128.,256.,128.,256.)
    call s_rect.registerEnter(trig)
    
    call BJDebugMsg("move unit, the message 'unit enter region' shouldn't be displayed")
    call SetUnitPosition(u,50.,50.)
    call BJDebugMsg("move unit")
    call SetUnitPosition(u,200.,200.)
    
endfunction

endlibrary


It doesn't work at all, i do something wrong ?
 

Azlier

Old World Ghost
Reaction score
461
Yes. .create takes minX, minY, then maxX and maxY. Treat it exactly like the [lJASS]Rect[/lJASS] native.

So, [lJASS]rectwrap.create(32, 32, 64, 64)[/lJASS] is correct.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Ok really bad mistake, fixed :

JASS:
library Test initializer init uses rectwrap

private function Actions takes nothing returns nothing
    call BJDebugMsg("unit enter region")
endfunction

private function init takes nothing returns nothing
    local rectwrap s_rect = rectwrap.create(32.,32.,64.,64.)
    local trigger trig = CreateTrigger()
    local unit u = CreateUnit(Player(0),'hpea',0.,0.,0.)
    
    call TriggerAddAction(trig,function Actions)
    
    call s_rect.registerEnter(trig)
    
    call TriggerSleepAction(1.)
    
    call BJDebugMsg("move unit")
    call SetUnitPosition(u,50.,50.)
    call SetUnitPosition(u,0.,0.)
    
    call TriggerSleepAction(1.)
    call BJDebugMsg(" ")
    
    call s_rect.destroy()
    set s_rect = rectwrap.create(128.,128.,256.,256.)
    call s_rect.registerEnter(trig)
    
    call BJDebugMsg("move unit, the message 'unit enter region' shouldn't be displayed")
    call SetUnitPosition(u,50.,50.)
    
    call TriggerSleepAction(1.)
    call BJDebugMsg(" ")
    
    call BJDebugMsg("move unit")
    call SetUnitPosition(u,200.,200.) // the message "unit enter in region" isn't showed
    
endfunction

endlibrary


Test the code and you will see what i want mean, i hope.
 

Azlier

Old World Ghost
Reaction score
461
Well, it seems that SetUnitPosition makes enter rect events fire again. How odd!

Nothing I can fix, though. Everything else seems to work perfectly.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Well, it seems that SetUnitPosition makes enter rect events fire again. How odd!

Nothing I can fix, though. Everything else seems to work perfectly.

No, it's nothing about SetUnitPosition, it's because the region isn't cleared, a better way would be to destroy/ create region or use RegionClearRect with the entire map rect.

Also, the last move doesn't fire the trigger, i wouldn't call it "works perfectly" xD
 

Azlier

Old World Ghost
Reaction score
461
Huh. But with my tests, it showed that moving a rect actually changed the region.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top