Re: Opening LOTS of doors
Posted: Fri Feb 14, 2014 10:23 pm
Ahh no, sorry - the above functions are simply definitions that you can then later use.
So, you might have a script_entity called "utils" with the above functions defined...
As long as you have this in your dungeon, you can then use those functions anywhere else to quickly and easily do what you need. So, to poison an entire room - you would do the following;
That's it. The function 'spawn_grid' will take care of doing the work for you. And to open all of the doors in a room, you could use the above like the following;
Note that 'open_all_doors' isn't overly efficient, if you wanted to do a whole floor at once, you could write a different function for that using allEntities instead of entitiesAt.
Hope this helps, let me know if you have any other questions.
So, you might have a script_entity called "utils" with the above functions defined...
Code: Select all
-- Spawn a grid of the same type of entity.
-- @param entityName The entity to spawn.
-- @param level The level on the dungeon to spawn the entities on
-- @param minX The first X coordinate to spawn in
-- @param maxX The last X coordinate to spawn in
-- @param minY The first Y coordinate to spawn in
-- @param maxY The last Y coordinate to spawn in
-- @param facing All entities will be spawned with this facing
--
function spawn_grid(entityName, level, minX, minY, maxX, maxY, facing)
for x=minX, maxX do
for y=minY, maxY do
spawn(entityName, level, x, y, facing);
end
end
end
-- Open all doors in the region between (minX, minY) and (maxX, maxY) on the given floor.
--
function open_all_doors(level, minX, minY, maxX, maxY)
for x = minX, maxX do
for y = minY, maxY do
for e in entitiesAt(level, x, y) do
if ( e.class == "Door" ) then
if ( e:isClosed() ) then
e:open();
end
end
end
end
end
end
Code: Select all
utils.spawn_grid("poison_cloud", 1, 15, 15, 17, 17, 1);
Code: Select all
utils.open_all_doors(1, 15, 15, 17, 17);
Hope this helps, let me know if you have any other questions.