• 🏆 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!

Regions, Rects and JASS, WTF!?

Status
Not open for further replies.
Level 6
Joined
Oct 4, 2008
Messages
263
yeah, so i was working on this trigger, which i wanted to create a random number(between 1 and 7) of regions, and then place them random places on the map. it all appeared so easy until i syntaxed, and it came up with the line 'cannot convert region to rect', on the line where i used the MoveRectToLoc function, trying to move my regions.
now i turn to you, mighty mive community, and ask: "WTH is the difference between a region and a rect, How the hell do i move regions if i cant do that with the moverect function.
oh, and is there any way to add/remove doodads? i cant seem to find any functions to do that?
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Regions are collections of rects.
To make your trigger work it should look something like this:
JASS:
function Lulz takes nothing returns nothing
    local rect r
    local integer i = GetRandomInt(1, 7)
    local integer i2 = 1
    local real x
    local real y
    loop
        exitwhen i2 > i
        set r = Rect(-100., -100., 100., 100.)
        set x = GetRandomReal(GetRectMinX(bj_mapInitialPlayableArea), GetRectMaxX(bj_mapInitialPlayableArea))
        set y = GetRandomReal(GetRectMinY(bj_mapInitialPlayableArea), GetRectMaxY(bj_mapInitialPlayableArea))
        call MoveRectTo(r, x, y)
        set r = null
        set i2 = i2 + 1
    endloop
endfunction
I believe that will work, though I have almost no experience with rects since I almost never use them.

And for your second question: No, there is no way.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Doodads are unmanipulatable via triggers, and merge with the terrain.

A Rect is a rectangual area of the map which consists of 4 default parameters (max X/Y and min X/Y).
A region is an area of the map made up of cells (no idea how big those are) and rects (see above) which do not have to be in contact with one another and can make up any shape.

In GUI, they falsely labled rects as regions which has caused a great deal of confusion for people like you. Thus any standard opperation in GUI that uses a "region" infact uses a rect.

Many natives, like the trigger events, use regions instead of rects, thus a conversion is needed. This is done in GUI via simply making a region, and adding your rect to it.
 
Level 6
Joined
Oct 4, 2008
Messages
263
thanks for the help! i ran it through JassCraft, and it doesnt display any errors.
as for doodads, damnit.
 
Status
Not open for further replies.
Top