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?
 
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.
 
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.
 
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.
Back
Top