Skip to content

Commit

Permalink
MapGen: Dungeons: add some bricks, stone & mossy cooble into walls. C…
Browse files Browse the repository at this point in the history
…loses #1140
  • Loading branch information
alek13 committed Dec 11, 2023
1 parent 73671fd commit e06e2dd
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mods/lord/World/Generation/buildings/src/dungeons.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

local dwarf_tomb = require('dungeons.dwarf_tomb')
local walls = require('dungeons.walls')


minetest.register_on_dungeon_generated(function(minp, maxp, data, area, room_centers)
minetest.register_on_dungeon_generated(function(minp, maxp, data, area, room_centers, rooms_walls)
dwarf_tomb.on_dungeon_generated(minp, maxp, data, area, room_centers)
walls.on_dungeon_generated(minp, maxp, data, area, room_centers, rooms_walls)
end)
59 changes: 59 additions & 0 deletions mods/lord/World/Generation/buildings/src/dungeons/walls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
local pairs, math_random, id
= pairs, math.random, minetest.get_content_id


local c_air = id("air")

local c_side_wall_blocks = {
id("default:cobble"),
id("default:mossycobble"),
id("default:stone"),
id("default:stonebrick"),
id("default:stonebrick"),
}
local c_wall_blocks = {
north = c_side_wall_blocks,
south = c_side_wall_blocks,
west = c_side_wall_blocks,
east = c_side_wall_blocks,
floor = {
id("default:cobble"),
id("default:mossycobble"),
id("default:mossycobble"),
id("default:stonebrick"),
},
ceiling = {
id("default:cobble"),
id("default:mossycobble"),
id("default:stone"),
id("default:stonebrick"),
},
}

--- @param wall_type string one of "north", "south", "west", "east", "floor", "ceiling"
--- @param data table
--- @param area VoxelArea
local function fill_wall(wall_type, start_pos, end_pos, data, area)
local wall_blocks = c_wall_blocks[wall_type]
for x = start_pos.x, end_pos.x do
for y = start_pos.y, end_pos.y do
for z = start_pos.z, end_pos.z do
if (data[area:index(x, y, z)] ~= c_air) then
data[area:index(x, y, z)] = wall_blocks[math_random(#wall_blocks)]
end
end
end
end
end

return {
on_dungeon_generated = function(minp, maxp, data, area, room_centers, rooms_walls)
for i, room_center in pairs(room_centers) do
-- data[area:indexp(room_center)] = id("default:torch")

for wall_type, wall in pairs(rooms_walls[i]) do
fill_wall(wall_type, wall.start_pos, wall.end_pos, data, area)
end
end
end
}

0 comments on commit e06e2dd

Please sign in to comment.