Added the possibility to plant the spores

pull/3/head
npx 2017-01-04 15:32:40 +01:00
parent 38495f2b9b
commit 803f9a4d8e
1 changed files with 56 additions and 15 deletions

View File

@ -1,3 +1,32 @@
function place_spore(itemstack, placer, pointed_thing, name, topoint, soilblock)
local pt = pointed_thing
-- check if pointing at a node
if not pt or pt.type ~= "node" then
return
end
local under = minetest.get_node(pt.under)
local uu = {x=pt.under.x, y=pt.under.y-1, z=pt.under.z}
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
end
-- if not protected then add node and remove 1 item from the itemstack
if not minetest.is_protected(pt.under, placer:get_player_name()) then
if (under.name == topoint) and (minetest.get_node(uu).name == soilblock) then
minetest.set_node(uu, {name = name})
minetest.sound_play("default_place_node", {pos = uu, gain = 1.0})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
end
end
minetest.register_node("nsspf:boletus_edulis", {
description = "Boletus edulis",
drawtype = "mesh",
@ -486,6 +515,9 @@ function nsspf_register_mycorrhizalmycelium (name, descr, tree, int, ch)
minetest.register_craftitem("nsspf:"..name.."_spores", {
description = descr.." Spores",
image = "spores.png",
on_place = function(itemstack, placer, pointed_thing)
return place_spore(itemstack, placer, pointed_thing, "nsspf:"..name.."_mycelium",tree, "default:dirt")
end,
})
minetest.register_abm({
@ -641,6 +673,9 @@ function nsspf_register_tuber (name, descr, tree, int, ch, gnam)
minetest.register_craftitem("nsspf:"..name.."_spores", {
description = descr.." Spores",
image = "spores.png",
on_place = function(itemstack, placer, pointed_thing)
return place_spore(itemstack, placer, pointed_thing, "nsspf:"..name.."_mycelium",tree, "default:dirt")
end,
})
minetest.register_abm({
@ -1264,6 +1299,9 @@ function nsspf_register_saprotrophicground (name, descr, int, ch)
minetest.register_craftitem("nsspf:"..name.."_spores", {
description = descr.." Spores",
image = "spores.png",
on_place = function(itemstack, placer, pointed_thing)
return place_spore(itemstack, placer, pointed_thing, "nsspf:"..name.."_mycelium","default:dirt_with_grass", "default:dirt")
end,
})
minetest.register_abm({
@ -1697,6 +1735,9 @@ function nsspf_register_snowbankfungi (name, descr, int, ch)
minetest.register_craftitem("nsspf:"..name.."_spores", {
description = descr.." Spores",
image = "spores.png",
on_place = function(itemstack, placer, pointed_thing)
return place_spore(itemstack, placer, pointed_thing, "nsspf:"..name.."_mycelium","default:dirt_with_snow", "default:dirt")
end,
})
minetest.register_abm({