+can we randomly place .mts files on the floor of a dimension?
yeah, its how all of the trees is placed in the modintroduce the biomes by dimension
if you are placing a mrs when the area is generating, it will be overwritten by other nodes, so make it as a node/ore instead that are placed after the area is done.
Code: Select all
-- a tree ore
minetest.register_node("multidimensions:just_a_mts", {})
-- place the schematic on the node when its loaded
minetest.register_lbm({
name = "multidimensions:lbm_name",
run_at_every_load = true,
nodenames = {"multidimensions:just_a_mts"},
action = function(pos, node)
minetest.set_node(pos, {name = "air"})
minetest.place_schematic({x=pos.x,y=pos.y,z=pos.z}, minetest.get_modpath("default") .. "/schematics/apple_tree.mts", "random", {}, true)
end,
})
multidimensions.register_dimension("name_of_dim",{
--ores spawned on the ground
ground_ores = {
["multidimensions:just_a_mts"]= 2000 -- chance to place
},
-- example biomes
-- snow when heat is <30 ... >30 grass <70 ... dry >70
self = {
dirt_with_snow = "default:dirt_with_snow"
dirt_with_grass = "default:dirt_with_grass"
dirt_with_dry_grass = "default:dirt_with_dry_grass"
},
on_generate=function(self,data,id,area,x,y,z) --hundreds of thousands comparisons are made in this function,
if data[id] == self.grass then -- data[id] = current / active node
if self.heat <= 30 then --cold / snow ... (heat is returned by minetest.get_heat(minp) from the api)
data[id] = self.dirt_with_snow
elseif self.heat >= 30 and self.heat <= 70 then -- middle / grass
data[id] = dirt_with_grass
elseif self.heat >= 70 then -- hot / dry
data[id] = dirt_with_dry_grass
else
return
end
return data
end
end,
})
EDITED made it easyer in 2.2