code tweaks

This commit is contained in:
TenPlus1 2020-02-14 11:13:49 +00:00
parent f639917a98
commit 2b5decbc50
1 changed files with 26 additions and 20 deletions

View File

@ -2,7 +2,6 @@
bonemeal = {} bonemeal = {}
local path = minetest.get_modpath("bonemeal") local path = minetest.get_modpath("bonemeal")
local table_insert = table.insert
local min, max, random = math.min, math.max, math.random local min, max, random = math.min, math.max, math.random
@ -91,7 +90,9 @@ local deco = {
} }
----- local functions --
-- local functions
--
-- particles -- particles
@ -261,11 +262,7 @@ local function check_soil(pos, nodename, strength)
local pos2, nod, def local pos2, nod, def
-- loop through soil -- loop through soil
for _,n in pairs(dirt) do for _, n in pairs(dirt) do
pos2 = n
pos2.y = pos2.y + 1
if random(5) == 5 then if random(5) == 5 then
if decor and #decor > 0 then if decor and #decor > 0 then
@ -281,6 +278,10 @@ local function check_soil(pos, nodename, strength)
end end
end end
pos2 = n
pos2.y = pos2.y + 1
if nod and nod ~= "" then if nod and nod ~= "" then
def = minetest.registered_nodes[nod] def = minetest.registered_nodes[nod]
def = def and def.place_param2 or 0 def = def and def.place_param2 or 0
@ -302,7 +303,7 @@ end
function bonemeal:add_sapling(list) function bonemeal:add_sapling(list)
for n = 1, #list do for n = 1, #list do
table_insert(saplings, list[n]) saplings[#saplings + 1] = list[n]
end end
end end
@ -313,7 +314,7 @@ end
function bonemeal:add_crop(list) function bonemeal:add_crop(list)
for n = 1, #list do for n = 1, #list do
table_insert(crops, list[n]) crops[#crops + 1] = list[n]
end end
end end
@ -333,11 +334,11 @@ function bonemeal:add_deco(list)
if list[l][1] == deco[n][1] then if list[l][1] == deco[n][1] then
-- adding grass types -- adding grass types
for _,extra in pairs(list[l][2]) do for _, extra in pairs(list[l][2]) do
if extra ~= "" then if extra ~= "" then
for _,entry in pairs(deco[n][2]) do for _, entry in pairs(deco[n][2]) do
if extra == entry then if extra == entry then
extra = false extra = false
@ -347,16 +348,16 @@ function bonemeal:add_deco(list)
end end
if extra then if extra then
table_insert(deco[n][2], extra) deco[n][2][#deco[n][2] + 1] = extra
end end
end end
-- adding decoration types -- adding decoration types
for _,extra in ipairs(list[l][3]) do for _, extra in ipairs(list[l][3]) do
if extra ~= "" then if extra ~= "" then
for __,entry in pairs(deco[n][3]) do for __, entry in pairs(deco[n][3]) do
if extra == entry then if extra == entry then
extra = false extra = false
@ -366,7 +367,7 @@ function bonemeal:add_deco(list)
end end
if extra then if extra then
table_insert(deco[n][3], extra) deco[n][3][#deco[n][3] + 1] = extra
end end
end end
@ -376,7 +377,7 @@ function bonemeal:add_deco(list)
end end
if list[l] then if list[l] then
table_insert(deco, list[l]) deco[#deco + 1] = list[l]
end end
end end
end end
@ -400,7 +401,7 @@ function bonemeal:set_deco(list)
end end
if list[l] then if list[l] then
table_insert(deco, list[l]) deco[#deco + 1] = list[l]
end end
end end
end end
@ -461,7 +462,9 @@ function bonemeal:on_use(pos, strength, node)
end end
----- items --
-- items
--
-- mulch (strength 1) -- mulch (strength 1)
@ -568,7 +571,10 @@ minetest.register_craftitem("bonemeal:gelatin_powder", {
}) })
--- crafting recipes --
-- crafting recipes
--
-- gelatin powder -- gelatin powder
minetest.register_craft({ minetest.register_craft({
@ -636,7 +642,7 @@ minetest.override_item("default:dirt", {
items = {"default:dirt"} items = {"default:dirt"}
} }
} }
}, }
}) })