• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Regions, rects, what and why?

Status
Not open for further replies.
I can't find this one on google.

Region is used to trigger events, rects are used to store coordinates, but in order for the region to trigger the event, the region must be defined with a rect.

So I used RegionAddRect... but can I use RemoveRect or SetRect to something else so that I don't waste a rect on each region? Like if I do...
JASS:
function setthis takes nothing returns nothing
   local rect r = Rect(-100, 345, -1, 800) // edit: haha, region r :P
   call RegionAddRect(Super, r )
   call RemoveRect(r)
   set r = null
endfunction
Does removing the rect undo the RegionAddRect command?

Also, can I use RegionAddRect twice to add two different rects and both rects trigger a unit entry event using the same region?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Well you're defining region r but constructing it with Rect() so it will probably give a syntax error.

I know what you mean though, let me check.

Yes, you can remove the rect while still having the region be used to trigger an event (and it works properly). Once the rect has been added to the region, it can be destroyed immediately, it seems that regions store all of the necessary information when a rect is added to them.
 
A rect is basically a square-region on the map that has 4 points. It is a square that covers land. (Or well, it might not be exactly square if you make it via triggers, huh. Then just assume it is a quadrilateral)

The objects made using the Region Palette are actually rects. The reason why regions are used at all is because they are used for events while rects aren't. (However, this can be solved by creating a region, adding the rect to the region, and then registering the event for that region) I believe regions also allow you to add cells. Rects are a bit more versatile though.
 
Status
Not open for further replies.
Top