[Script] Fill void with walls
Posted: Tue Nov 11, 2014 8:34 pm
Hi all!
If one tries different elevations in a forest, or in a beach scenario, one immediately finds that - differently to what happens with dungeons and mines, for example - zones with different elevations are not automatically filled (there is no "forest wall" as there is a "dungeon wall"; I mean, there is, but it is not "vertical"!); thus, if one wants to make zones with different elevations using outdoor tiles, one has to build the walls one by one: a rather difficult task (is the facing correct? the elevation? etc.).
I've therefore written the following code which "fills in the blanks", adding "dungeon_walls" to compensate for the lack of a beach/forest wall. Just draw a map outdoors with different elevations (set the ceiling to 7 to avoid unpleasant surprises...), either using the beach ground tile, or the forest ground tile (or both), and then connect a pressure plate to the "makeWalls()" function in the script below. Step on the plate, and it's done!
Here are the screenshots of the map, and the rendering before/after stepping on the pressure plate connected to the script



Now, if only it were possible to save a file from the editor to disk, one could create the map, let the script add the walls, save their positions to disk, and copy the file inside dungeon.lua...
Alois
If one tries different elevations in a forest, or in a beach scenario, one immediately finds that - differently to what happens with dungeons and mines, for example - zones with different elevations are not automatically filled (there is no "forest wall" as there is a "dungeon wall"; I mean, there is, but it is not "vertical"!); thus, if one wants to make zones with different elevations using outdoor tiles, one has to build the walls one by one: a rather difficult task (is the facing correct? the elevation? etc.).
I've therefore written the following code which "fills in the blanks", adding "dungeon_walls" to compensate for the lack of a beach/forest wall. Just draw a map outdoors with different elevations (set the ceiling to 7 to avoid unpleasant surprises...), either using the beach ground tile, or the forest ground tile (or both), and then connect a pressure plate to the "makeWalls()" function in the script below. Step on the plate, and it's done!
Code: Select all
function makeWalls()
local map = self.go.map
local inix,finx = 0,31 -- the full map, change as you like
local iniy,finy = 0,31 -- the full map, change as you like
local list = {
"dungeon_wall_01",
"dungeon_wall_02",
}
-- also: local list = {"forest_elevation_edge"}
for x = (inix+1),(finx-1),1 do
for y = (iniy+1),(finy-1),1 do
local tilec = map:getAutomapTile(x,y)
local elevc = map:getElevation(x,y)
if (tilec == 1) or (tilec == 0) then -- 0 and 1 are the automap tiles for beach ground and forest ground
for dir = 0,3,1 do
local dx,dy = getForward(dir)
local tilen = map:getAutomapTile(x+dx,y+dy)
local elevn = map:getElevation(x+dx,y+dy)
if ((tilen == 1) or (tilen == 0)) and (elevc < elevn) then
for elev = elevc,(elevn-1),1 do
local ran = math.random(#list)
spawn(list[ran],party.party.level,x,y,dir,elev)
end
end
end
end
end
end
end



Now, if only it were possible to save a file from the editor to disk, one could create the map, let the script add the walls, save their positions to disk, and copy the file inside dungeon.lua...
Alois
