summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorh-v-smacker <hans-von-smacker+github@gmail.com>2018-05-07 16:11:08 +0300
committerh-v-smacker <hans-von-smacker+github@gmail.com>2018-05-07 16:11:08 +0300
commitd14339069d6cee29ad74e7d9fd50c69b6fb2b4ec (patch)
tree51a4f0f1d0cc17aa6bd76ec742137e4ebf29f037
parentfc4a6a44ebfff75cbdf0a4b62b63d7b8b5f7eacc (diff)
parentdd422b609164b338c4a68166b78a1d7d2d9e5250 (diff)
merge upstream
-rw-r--r--README.md1
-rw-r--r--api.txt8
-rw-r--r--init.lua30
3 files changed, 24 insertions, 15 deletions
diff --git a/README.md b/README.md
index 37a84f3..3258629 100644
--- a/README.md
+++ b/README.md
@@ -29,5 +29,6 @@ Changelog:
- 0.7 - Can be used on papyrus and cactus now, added coral recipe, api addition
- 0.8 - Added support for farming redo's new garlic, pepper and onion crops
- 0.9 - Added support for farming redo's pea and beetroot crops, checks for place_param
+- 1.0 - add_deco() now adds to existing item list while set_deco() replaces item list (thanks h-v-smacker)
Lucky Blocks: 5
diff --git a/api.txt b/api.txt
index e399bdc..d2eddc2 100644
--- a/api.txt
+++ b/api.txt
@@ -59,19 +59,19 @@ which allows to decrease the frequency of decoration emergence, if needed.
e.g.
bonemeal:add_deco({
- {"default:dirt_with_dry_grass", {"default:dry_grass_1", ""},
+ {"default:dirt_with_dry_grass", {"default:dry_grass_1", ""},
{"flowers:rose", "flowers:viola"} }
})
Thus, add_deco() always adds (to) a definition, and never overrides. To discard an existing
definiton in favor of the new one, use
-
+
bonemeal:set_deco({
{ dirt_node, {grass_node_list}, {decor_node_list} }
})
This command will set decoration for a given dirt type, fully replacing any existing definition.
-
+
Global ON_USE Function
----------------------
@@ -93,4 +93,4 @@ Final Words
===========
I hope this guide helps you add your own plants so you can grow them quickly
-with the items included. Please check the mods.lua for more examples.
+with the items included. Please check the mods.lua for more examples. \ No newline at end of file
diff --git a/init.lua b/init.lua
index 35526f8..1bb3917 100644
--- a/init.lua
+++ b/init.lua
@@ -295,61 +295,68 @@ end
function bonemeal:add_deco(list)
for l = 1, #list do
-
+
for n = 1, #deco do
-- update existing entry
if list[l][1] == deco[n][1] then
-
+
-- adding grass types
for _,extra in ipairs(list[l][2]) do
+
if extra ~= "" then
+
for __,entry in ipairs(deco[n][2]) do
+
if extra == entry then
extra = false
break
end
end
end
+
if extra then
table.insert(deco[n][2], extra)
end
end
-
+
-- adding decoration types
for _,extra in ipairs(list[l][3]) do
+
if extra ~= "" then
+
for __,entry in ipairs(deco[n][3]) do
+
if extra == entry then
extra = false
break
end
end
end
+
if extra then
table.insert(deco[n][3], extra)
end
end
-
+
list[l] = false
break
end
-
end
-
+
if list[l] then
table.insert(deco, list[l])
end
-
end
end
+
-- definitively set a decration scheme
-- this function will either add a new entry as is, or replace the existing one
function bonemeal:set_deco(list)
for l = 1, #list do
-
+
for n = 1, #deco do
-- replace existing entry
@@ -360,14 +367,14 @@ function bonemeal:set_deco(list)
break
end
end
-
+
if list[l] then
table.insert(deco, list[l])
end
-
end
end
+
-- global on_use function for bonemeal
function bonemeal:on_use(pos, strength, node)
@@ -455,6 +462,7 @@ minetest.register_craftitem("bonemeal:mulch", {
end,
})
+
-- bonemeal (strength 2)
minetest.register_craftitem("bonemeal:bonemeal", {
description = S("Bone Meal"),
@@ -588,4 +596,4 @@ local path = minetest.get_modpath("bonemeal")
dofile(path .. "/mods.lua")
dofile(path .. "/lucky_block.lua")
-print (S("[bonemeal] loaded"))
+print (S("[bonemeal] loaded")) \ No newline at end of file