-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MapGen: Dungeons: add some bricks, stone & mossy cooble into walls. C…
…loses #1140
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
59
mods/lord/World/Generation/buildings/src/dungeons/walls.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |