I tried integrating the effect of the admin stick into the map generation code, but it doesn't seem to work at map generation time. I can't use an administrator-only tool manually, as my planned server will be a bit of an anarchy server and will have no administrators.
The problem with placing scematics is that it is a duplication of functionality. Every time an update is made, I have to figure out how to make the same change both in the schematic code and in the minetest.spawn_tree() code. It's hard enough trying to get the minetest.spawn_tree() function alone to play nicely. I can't switch to also using schematic files for saplings because, as demonstrated in minetest_game, schematic files eat nodes. If someone places a schematic-using sapling under another player's locked chest, that locked chest and all its contents will be destroyed. Schematic saplings are far too dangerous to have in a non-PVP-type subgame.
Further testing seems to indicate that this bug happens in map generators v5 and v7, but not v6. I'm not sure why.
My code looks like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_biome({
name = "minetyst:negxo",
node_dust = "minetyst:negxa_bloko",
node_top = "minetyst:tero_kun_negxo",
depth_top = 1,
node_filler = "minetyst:tero",
depth_filler = 3,
node_stone = "minetyst:sxtono_ciankolora",
node_water_top = "minetyst:glacio",
depth_water_top = 2,
node_water = "minetyst:dolcxakva_fonto",
y_min = -31000,
y_max = 31000,
heat_point = 0,
humidity_point = 100,
})
minetest.register_decoration({
deco_type = "simple",
place_on = "minetyst:tero_kun_negxo",
fill_ratio = 0.005,
sidelen = 16,
biomes = {"minetyst:negxo"},
decoration = "minetyst:pinarbido",
})
minetest.register_node("minetyst:pinarbido", {
description = "Pinarba Grajno",
tiles = {"minetyst-pinarbido.png"},
inventory_image = "minetyst-pinsemo.png",
wield_image = "minetyst-pinsemo.png",
drawtype = "plantlike",
paramtype = "light",
is_ground_content = false,
walkable = false,
groups = {attached_node=1, arbido=1},
arbo = {
axiom = "dddTTTTTTff&&RAA",
rules_a = "[^R+R+RR+RR+RRR]G[^f+f+ff+ff+fff+RRR+RRRR+RRRR+RRRRR]G[^f+f+ff+ff+fff+fff+ffff+ffff+fffff+RRRRR+RRRRRR+RRRRRR+RRRRRRR]G[^f+f+ff+ff+fff+fff+ffff+ffff+fffff+fffff+ffffff+ffffff+fffffff]G",
rules_d = "T",
trunk = "minetyst:pinarbo",
leaves = "minetyst:pinarba_folioj",
leaves2 = "minetyst:strobilo",
leaves2_chance = 10,
angle = 90,
iterations = 2,
random_level = 1,
trunk_type = "single",
fruit_chance = 0,
fruit = "minetyst:negxo"
},
})
minetest.register_on_generated(function(minimumo, maksimumo, semo)
local arbidoj = minetest.find_nodes_in_area(minimumo, maksimumo, "group:arbido")
for elemento,koordinatoj in pairs(arbidoj) do
local arbido = minetest.get_node(koordinatoj)
minetest.remove_node(koordinatoj)
if minetest.get_node({x=koordinatoj.x,y=koordinatoj.y+1,z=koordinatoj.z}).name == "minetyst:negxa_bloko" then
minetest.remove_node({x=koordinatoj.x,y=koordinatoj.y+1,z=koordinatoj.z})
end
minetest.spawn_tree(koordinatoj, minetest.registered_nodes[arbido.name].arbo)
end
end)
The code is a bit hard to read, but basically, it uses simple decorations to place saplings, then finds all the saplings with minetest.find_nodes_in_area(), and causes them all to grow by removing the sapling, removing the snow node (placed as a dust) on top of the sapling, then calling minetest.spawn_tree() at the location the sapling used to be.