Cleaning the code
This commit is contained in:
parent
0f6ee94dfe
commit
289d1bc98a
254
init.lua
254
init.lua
@ -190,74 +190,71 @@ minetest.register_node("nsspf:macrolepiota_procera", {
|
|||||||
|
|
||||||
function nsspf_register_mycorrhizalmycelium (name, descr, tree)
|
function nsspf_register_mycorrhizalmycelium (name, descr, tree)
|
||||||
|
|
||||||
minetest.register_node("nsspf:"..name.."_mycelium", {
|
minetest.register_node("nsspf:"..name.."_mycelium", {
|
||||||
description = descr,
|
description = descr,
|
||||||
tiles = {"mycorrhizalmycelium.png"},
|
tiles = {"mycorrhizalmycelium.png"},
|
||||||
groups = {crumbly = 2},
|
groups = {crumbly = 2},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt"},
|
nodenames = {"default:dirt"},
|
||||||
neighbors = {tree},
|
neighbors = {tree},
|
||||||
interval = 30.0,
|
interval = 30.0,
|
||||||
chance = 20,
|
chance = 20,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local flag = 0
|
local flag = 0
|
||||||
for dx = -2,2 do
|
for dx = -2,2 do
|
||||||
for dy = -2,2 do
|
for dy = -2,2 do
|
||||||
for dz = -2,1 do
|
for dz = -2,1 do
|
||||||
local pos1 = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
local pos1 = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
local n = minetest.env:get_node(pos1).name
|
local n = minetest.get_node(pos1).name
|
||||||
if n == "nsspf:amanita_muscaria_mycelium" or n == "nsspf:amanita_phalloides_mycelium" or n == "nsspf:boletus_edulis_mycelium" or n == "nsspf:boletus_satanas_mycelium" then
|
if string.match(n,"mycelium") then -- if the name contains "mycelium" then exit
|
||||||
flag = 1
|
flag = 1
|
||||||
return
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--if no other mycelium have been found:
|
||||||
|
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_mycelium"})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"nsspf:"..name.."_mycelium"},
|
||||||
|
neighbors = {"air"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node)
|
||||||
|
minetest.set_node(pos, {name="default:dirt"})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"default:dirt"},
|
||||||
|
neighbors = {"nsspf:"..name.."_mycelium"},
|
||||||
|
interval = 30.0,
|
||||||
|
chance = 20,
|
||||||
|
action = function(pos, node)
|
||||||
|
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_mycelium"})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"nsspf:"..name.."_mycelium"},
|
||||||
|
neighbors = {"default:dirt_with_grass"},
|
||||||
|
interval = 30.0,
|
||||||
|
chance = 20,
|
||||||
|
action = function(pos, node)
|
||||||
|
local pos1 = {x=pos.x, y=pos.y+2, z=pos.z}
|
||||||
|
local pos2 = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
|
local n = minetest.get_node(pos1).name
|
||||||
|
local nn = minetest.get_node(pos2).name
|
||||||
|
if n== "air" and nn== "default:dirt_with_grass" then
|
||||||
|
minetest.set_node(pos1, {name = "nsspf:"..name})
|
||||||
end
|
end
|
||||||
if flag == 0 then
|
|
||||||
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_mycelium"})
|
|
||||||
end
|
end
|
||||||
end
|
})
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"nsspf:"..name.."_mycelium"},
|
|
||||||
neighbors = {"air"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action =
|
|
||||||
function(pos, node)
|
|
||||||
minetest.set_node(pos, {name="default:dirt"})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"default:dirt"},
|
|
||||||
neighbors = {"nsspf:"..name.."_mycelium"},
|
|
||||||
interval = 30.0,
|
|
||||||
chance = 20,
|
|
||||||
action = function(pos, node)
|
|
||||||
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_mycelium"})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"nsspf:"..name.."_mycelium"},
|
|
||||||
neighbors = {"default:dirt_with_grass"},
|
|
||||||
interval = 30.0,
|
|
||||||
chance = 20,
|
|
||||||
action = function(pos, node)
|
|
||||||
local pos1 = {x=pos.x, y=pos.y+2, z=pos.z}
|
|
||||||
local pos2 = {x=pos.x, y=pos.y+1, z=pos.z}
|
|
||||||
local n = minetest.env:get_node(pos1).name
|
|
||||||
local nn = minetest.env:get_node(pos2).name
|
|
||||||
if n== "air" and nn== "default:dirt_with_grass" then
|
|
||||||
minetest.set_node({x = pos1.x, y = pos1.y, z = pos1.z}, {name = "nsspf:"..name})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -277,84 +274,81 @@ nsspf_register_mycorrhizalmycelium ('morchella_conica','Morchella conica Myceliu
|
|||||||
--tuber
|
--tuber
|
||||||
function nsspf_register_tuber (name, descr, tree)
|
function nsspf_register_tuber (name, descr, tree)
|
||||||
|
|
||||||
minetest.register_node("nsspf:"..name.."_tuber_mycelium", {
|
minetest.register_node("nsspf:"..name.."_tuber_mycelium", {
|
||||||
description = descr,
|
description = descr,
|
||||||
tiles = {"tuber_mycelium.png"},
|
tiles = {"tuber_mycelium.png"},
|
||||||
groups = {crumbly = 2},
|
groups = {crumbly = 2},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt"},
|
nodenames = {"default:dirt"},
|
||||||
neighbors = {tree},
|
neighbors = {tree},
|
||||||
interval = 20.0,
|
interval = 20.0,
|
||||||
chance = 10,
|
chance = 10,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
local flag = 0
|
local flag = 0
|
||||||
for dx = -2,2 do
|
for dx = -2,2 do
|
||||||
for dy = -2,2 do
|
for dy = -2,2 do
|
||||||
for dz = -2,1 do
|
for dz = -2,1 do
|
||||||
local pos1 = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
local pos1 = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
local n = minetest.env:get_node(pos1).name
|
local n = minetest.get_node(pos1).name
|
||||||
if n == "nsspf:tuber_magnatum_pico" or n == "nsspf:tuber_melanosporum" or n == "nsspf:tuber_borchii" or n == "nsspf:terfezia_arenaria" then
|
if n == "nsspf:tuber_magnatum_pico" or n == "nsspf:tuber_melanosporum" or n == "nsspf:tuber_borchii" or n == "nsspf:terfezia_arenaria" then
|
||||||
flag = 1
|
return
|
||||||
return
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_tuber_mycelium"})
|
||||||
if flag == 0 then
|
|
||||||
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_tuber_mycelium"})
|
|
||||||
end
|
end
|
||||||
end
|
})
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"nsspf:"..name.."_tuber_mycelium"},
|
nodenames = {"nsspf:"..name.."_tuber_mycelium"},
|
||||||
neighbors = {"air"},
|
neighbors = {"air"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action =
|
action =
|
||||||
function(pos, node)
|
function(pos, node)
|
||||||
minetest.set_node(pos, {name="nsspf:"..name.."_fungusdirt"})
|
minetest.set_node(pos, {name="nsspf:"..name.."_fungusdirt"})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("nsspf:"..name.."_fruit", {
|
minetest.register_node("nsspf:"..name.."_fruit", {
|
||||||
description = descr.." Fruit",
|
description = descr.." Fruit",
|
||||||
tiles = {"default_dirt.png"},
|
tiles = {"default_dirt.png"},
|
||||||
drop = "nsspf:"..name,
|
drop = "nsspf:"..name,
|
||||||
groups = {crumbly = 3},
|
groups = {crumbly = 3},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt"},
|
nodenames = {"default:dirt"},
|
||||||
neighbors = {"nsspf:"..name.."_tuber_mycelium"},
|
neighbors = {"nsspf:"..name.."_tuber_mycelium"},
|
||||||
interval = 20.0,
|
interval = 20.0,
|
||||||
chance = 10,
|
chance = 10,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_tuber_mycelium"})
|
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_tuber_mycelium"})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("nsspf:"..name, {
|
minetest.register_craftitem("nsspf:"..name, {
|
||||||
description = descr,
|
description = descr,
|
||||||
image = name..".png",
|
image = name..".png",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
minetest.register_craftitem("nsspf:"..name.."_spores", {
|
||||||
description = descr.." Spores",
|
description = descr.." Spores",
|
||||||
image = "spores.png",
|
image = "spores.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"default:dirt"},
|
nodenames = {"default:dirt"},
|
||||||
neighbors = {"nsspf:"..name.."_tuber_mycelium"},
|
neighbors = {"nsspf:"..name.."_tuber_mycelium"},
|
||||||
interval = 30.0,
|
interval = 30.0,
|
||||||
chance = 20,
|
chance = 20,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_fruit"})
|
minetest.set_node({x = pos.x, y = pos.y, z = pos.z}, {name = "nsspf:"..name.."_fruit"})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -547,4 +541,4 @@ minetest.register_abm({
|
|||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
set_fl(pos)
|
set_fl(pos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user