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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top