-- This file takes care of cave biomes noordstar_caves.registered_biomes = {} -- Clean the input and return a valid shape def -- If the input is invalid, return nil local function clean_def(def) if type(def.name) ~= "string" then return nil end if type(def.heat_point) ~= "number" then return nil end if type(def.humidity_point) ~= "number" then return nil end local d = { name = def.name, heat_point = def.heat_point, humidity_point = def.humidity_point, } -- Position if type(def.min_pos) == "table" then d.minp = { x = def.min_pos.x or -1e5, y = def.min_pos.y or -1e5, z = def.min_pos.z or -1e5, } elseif type(def.y_min) == "number" then d.minp = { x = -1e5, y = def.y_min, z = -1e5 } else d.minp = { x = -1e5, y = -1e5, z = -1e5 } end if type(def.max_pos) == "table" then d.maxp = { x = def.max_pos.x or 1e5, y = def.max_pos.y or 1e5, z = def.max_pos.z or 1e5, } elseif type(def.y_max) == "number" then d.maxp = { x = 1e5, y = def.y_max, z = 1e5 } else d.maxp = { x = 1e5, y = 1e5, z = 1e5 } end -- Optional nodes if type(def.node_dust) == "string" then d.node_dust = def.node_dust end if type(def.node_floor) == "string" then d.node_floor = def.node_floor end if type(def.node_wall) == "string" then d.node_wall = def.node_wall end if type(def.node_roof) == "string" then d.node_roof = def.node_roof end if type(def.node_shell) == "string" then d.node_shell = def.node_shell end if type(def.depth_shell) == "number" then d.depth_shell = def.depth_shell else d.depth_shell = 0 end return d end function noordstar_caves.register_biome(def) local d = clean_def(def) if d ~= nil then noordstar_caves.registered_biomes[d.name] = d end end function noordstar_caves.unregister_biome(name) noordstar_caves.registered_biomes[name] = nil end function noordstar_caves.clear_registered_biomes() noordstar_caves.registered_biomes = {} end