GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2009-05-31 16:05:53

brod
Member
From: NY, United States
Registered: 2008-12-14
Posts: 9
Website

map_rooms

After using this a lot, and learning something from torigara over at the GMC, here's an optimization of the script.

Expand/*
**  Usage:
**      map_rooms(ds_map)
**
**  Arguments:
**      ds_map      map to which all rooms are loaded.
**
**  Notes:
**      Fills the map with {key=name, val=index} pairs.
**      To find the maximum number of rooms, it creates an extra
**      room. The name of this room will be added to the map
**      unless a room with the same name already exists.
**
**  Returns:
**      the index of the created room
**
**  GMLscripts.com
*/
{
    var i,ds_map;
    ds_map = argument0
    for (i=room_first;i>=0;i=room_next(i)) {
        if (room_exists(i)) {
            ds_map_add(ds_map,room_get_name(i),i);
        }
    }
}

Does the same thing as the original script, it just doesn't need to create an extra room to accomplish it.

Offline

#2 2009-05-31 19:20:07

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: map_rooms

This actually already came up once:
http://www.gmlscripts.com/forums/viewtopic.php?id=52


Abusing forum power since 1986.

Offline

#3 2009-05-31 21:05:03

brod
Member
From: NY, United States
Registered: 2008-12-14
Posts: 9
Website

Re: map_rooms

Oh. nvm then ^o^

Offline

Board footer

Powered by FluxBB