Added the possibility to plant the spores
This commit is contained in:
parent
38495f2b9b
commit
803f9a4d8e
41
init.lua
41
init.lua
@ -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", {
|
minetest.register_node("nsspf:boletus_edulis", {
|
||||||
description = "Boletus edulis",
|
description = "Boletus edulis",
|
||||||
drawtype = "mesh",
|
drawtype = "mesh",
|
||||||
@ -486,6 +515,9 @@ function nsspf_register_mycorrhizalmycelium (name, descr, tree, int, ch)
|
|||||||
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
||||||
description = descr.." Spores",
|
description = descr.." Spores",
|
||||||
image = "spores.png",
|
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({
|
minetest.register_abm({
|
||||||
@ -641,6 +673,9 @@ function nsspf_register_tuber (name, descr, tree, int, ch, gnam)
|
|||||||
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
||||||
description = descr.." Spores",
|
description = descr.." Spores",
|
||||||
image = "spores.png",
|
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({
|
minetest.register_abm({
|
||||||
@ -1264,6 +1299,9 @@ function nsspf_register_saprotrophicground (name, descr, int, ch)
|
|||||||
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
||||||
description = descr.." Spores",
|
description = descr.." Spores",
|
||||||
image = "spores.png",
|
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({
|
minetest.register_abm({
|
||||||
@ -1697,6 +1735,9 @@ function nsspf_register_snowbankfungi (name, descr, int, ch)
|
|||||||
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
||||||
description = descr.." Spores",
|
description = descr.." Spores",
|
||||||
image = "spores.png",
|
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({
|
minetest.register_abm({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user