summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-01-15 20:54:28 +0000
committerTenPlus1 <kinsellaja@yahoo.com>2017-01-15 20:54:28 +0000
commitcce0337b1c238ae307e2119b4fa98e857cfce552 (patch)
tree0b2d888fabd9ee18be1d9ba54e5fe8400b495263
parentbd092c080bcc6b297a8841b76fa77427484f875d (diff)
Code tweak and tidy
-rw-r--r--init.lua205
-rw-r--r--mods.lua12
2 files changed, 109 insertions, 108 deletions
diff --git a/init.lua b/init.lua
index 78f8ce0..c88891c 100644
--- a/init.lua
+++ b/init.lua
@@ -1,72 +1,7 @@
bonemeal = {}
--- bone item
-minetest.register_craftitem("bonemeal:bone", {
- description = "Bone",
- inventory_image = "bonemeal_bone.png",
-})
-
--- bonemeal recipes
-minetest.register_craft({
- type = "shapeless",
- output = "bonemeal:bonemeal 2",
- recipe = {"bonemeal:bone"},
-})
-
-minetest.register_craft({
- type = "shapeless",
- output = "bonemeal:bonemeal 4",
- recipe = {"bones:bones"},
-})
-
--- have animalmaterials found, craft bone into bonemeal
-if minetest.get_modpath("animalmaterials") then
-
- minetest.register_craft({
- type = "shapeless",
- output = "bonemeal:bonemeal 2",
- recipe = {"animalmaterials:bone"},
- })
-end
-
--- add bones to dirt
-minetest.override_item("default:dirt", {
- drop = {
- max_items = 1,
- items = {
- {
- items = {"bonemeal:bone", "default:dirt"},
- rarity = 30,
- },
- {
- items = {"default:dirt"},
- }
- }
- },
-})
-
-
--- particles
-local function particle_effect(pos)
-
- minetest.add_particlespawner({
- amount = 4,
- time = 0.15,
- minpos = pos,
- maxpos = pos,
- minvel = {x = -1, y = 2, z = -1},
- maxvel = {x = 1, y = 4, z = 1},
- minacc = {x = -1, y = -1, z = -1},
- maxacc = {x = 1, y = 1, z = 1},
- minexptime = 1,
- maxexptime = 1,
- minsize = 1,
- maxsize = 3,
- texture = "bonemeal_particle.png",
- })
-end
-
+----- crops
-- default crops
local crops = {
@@ -85,6 +20,7 @@ function bonemeal:add_crop(list)
end
end
+----- plants
-- default plants
local plants = {
@@ -108,6 +44,7 @@ function bonemeal:add_plant(list)
end
end
+----- saplings
-- special pine check for snow
local function pine_grow(pos)
@@ -141,9 +78,31 @@ function bonemeal:add_sapling(list)
end
end
+----- functions
+
+-- particles
+local function particle_effect(pos)
+
+ minetest.add_particlespawner({
+ amount = 4,
+ time = 0.15,
+ minpos = pos,
+ maxpos = pos,
+ minvel = {x = -1, y = 2, z = -1},
+ maxvel = {x = 1, y = 4, z = 1},
+ minacc = {x = -1, y = -1, z = -1},
+ maxacc = {x = 1, y = 1, z = 1},
+ minexptime = 1,
+ maxexptime = 1,
+ minsize = 1,
+ maxsize = 3,
+ texture = "bonemeal_particle.png",
+ })
+end
+
--- moretrees specific function
-local function more_tree(pos, object)
+-- tree type check
+local function grow_tree(pos, object)
if type(object) == "table" and object.axiom then
-- grow L-system tree
@@ -211,7 +170,7 @@ local function check_sapling(pos, nodename)
-- check if we can grow sapling
if can_grow then
particle_effect(pos)
- more_tree(pos, saplings[n][2])
+ grow_tree(pos, saplings[n][2])
return
end
end
@@ -280,35 +239,7 @@ local function check_soil(pos, nodename)
end
end
-
--- growing routine
-local function growth(pointed_thing)
-
- local pos = pointed_thing.under
- local node = minetest.get_node(pos)
-
- -- return if nothing there
- if node.name == "ignore" then
- return
- end
-
- -- check for tree growth if pointing at sapling
- if minetest.get_item_group(node.name, "sapling") > 0 then
-
- check_sapling(pos, node.name)
-
- return
- end
-
- -- check for crop growth
- check_crops(pos, node.name)
-
- -- grow grass and flowers
- if minetest.get_item_group(node.name, "soil") > 0 then
- check_soil(pos, node.name)
- end
-end
-
+----- items
-- bonemeal item
minetest.register_craftitem("bonemeal:bonemeal", {
@@ -317,24 +248,82 @@ minetest.register_craftitem("bonemeal:bonemeal", {
on_use = function(itemstack, user, pointed_thing)
- if pointed_thing.type == "node" then
+ -- did we point at a node?
+ if pointed_thing.type ~= "node" then
+ return
+ end
- -- Check if node protected
- if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
- return
- end
+ -- is area protected?
+ if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
+ return
+ end
- if not minetest.setting_getbool("creative_mode") then
- itemstack:take_item()
- end
+ -- take item if not in creative
+ if not minetest.setting_getbool("creative_mode") then
+ itemstack:take_item()
+ end
- growth(pointed_thing)
+ -- get position and node
+ local pos = pointed_thing.under
+ local node = minetest.get_node(pos)
- return itemstack
+ -- return if nothing there
+ if node.name == "ignore" then
+ return
end
+
+ -- check for tree growth if pointing at sapling
+ if minetest.get_item_group(node.name, "sapling") > 0 then
+ check_sapling(pos, node.name)
+ return
+ end
+
+ -- check for crop growth
+ check_crops(pos, node.name)
+
+ -- grow grass and flowers
+ if minetest.get_item_group(node.name, "soil") > 0 then
+ check_soil(pos, node.name)
+ end
+
+ return itemstack
end,
})
+-- bone item
+minetest.register_craftitem("bonemeal:bone", {
+ description = "Bone",
+ inventory_image = "bonemeal_bone.png",
+})
+
+-- bonemeal recipes
+minetest.register_craft({
+ type = "shapeless",
+ output = "bonemeal:bonemeal 2",
+ recipe = {"bonemeal:bone"},
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "bonemeal:bonemeal 4",
+ recipe = {"bones:bones"},
+})
+
+-- add bones to dirt
+minetest.override_item("default:dirt", {
+ drop = {
+ max_items = 1,
+ items = {
+ {
+ items = {"bonemeal:bone", "default:dirt"},
+ rarity = 30,
+ },
+ {
+ items = {"default:dirt"},
+ }
+ }
+ },
+})
-- add support for other mods
dofile(minetest.get_modpath("bonemeal") .. "/mods.lua")
diff --git a/mods.lua b/mods.lua
index 14dac4c..c95e34f 100644
--- a/mods.lua
+++ b/mods.lua
@@ -1,4 +1,16 @@
+
+-- craft bones from animalmaterials into bonemeal
+if minetest.get_modpath("animalmaterials") then
+
+ minetest.register_craft({
+ type = "shapeless",
+ output = "bonemeal:bonemeal 2",
+ recipe = {"animalmaterials:bone"},
+ })
+end
+
+
if farming and farming.mod and farming.mod == "redo" then
bonemeal:add_crop({