Skip to content

Commit

Permalink
Mount Gen: refactoring: rename map.lua and return class `mountgen.gen…
Browse files Browse the repository at this point in the history
…erator.Node`. Relates to #1906
  • Loading branch information
alek13 committed Jan 7, 2025
1 parent dde16a6 commit e01dde9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions mods/lord/World/mountgen/src/generator.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
local math_floor, math_ceil, math_tan, table_insert, id
= math.floor, math.ceil, math.tan, table.insert, minetest.get_content_id

local Node = require('generator.Node')


local stone_id = id("default:stone")
local air_id = id("air")

Expand Down Expand Up @@ -124,12 +127,12 @@ mountgen.mountgen = function(top, config)
data[i] = stone_id
elseif global_y == height then
if can_place_dirt(data[i], stone_id) then
local top_node = mountgen.top_node({ x = global_x, y = global_y, z = global_z }, config)
local top_node = Node.get_coverage({ x = global_x, y = global_y, z = global_z }, config)
data[i] = id(top_node)
end
elseif global_y == height + 1 then
if can_place_plant(data[i], air_id) then
local upper_node = mountgen.upper_node({ x = global_x, y = global_y, z = global_z },
local upper_node = Node.get_plant({ x = global_x, y = global_y, z = global_z },
config)
if upper_node ~= nil then
data[i] = id(upper_node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ local function get_sapling(pos)
end


mountgen.top_node = function(pos, config)
--- @class mountgen.generator.Node
local Node = {}

function Node.get_coverage(pos, config)
local place_snow = false
local sl = config.SNOW_LINE - math_random(0, config.SNOW_LINE_RAND)
if pos.y >= sl then
Expand All @@ -41,7 +44,7 @@ mountgen.top_node = function(pos, config)
end
end

mountgen.upper_node = function(pos, config)
function Node.get_plant(pos, config)
if pos.y >= config.SNOW_LINE - config.SNOW_LINE_RAND then
return nil
end
Expand All @@ -59,3 +62,6 @@ mountgen.upper_node = function(pos, config)

return nil
end


return Node
1 change: 0 additions & 1 deletion mods/lord/World/mountgen/src/mountgen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mountgen = {}
require('algorithms.cone')
require('algorithms.diamond_square')
require('generator')
require('map')
require('ui')


Expand Down

0 comments on commit e01dde9

Please sign in to comment.