summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.lua1
-rw-r--r--polebean.lua267
-rw-r--r--textures/crops_beanpole_base.pngbin0 -> 344 bytes
-rw-r--r--textures/crops_beanpole_plant_base_1.pngbin0 -> 347 bytes
-rw-r--r--textures/crops_beanpole_plant_base_2.pngbin0 -> 480 bytes
-rw-r--r--textures/crops_beanpole_plant_base_3.pngbin0 -> 560 bytes
-rw-r--r--textures/crops_beanpole_plant_base_4.pngbin0 -> 637 bytes
-rw-r--r--textures/crops_beanpole_plant_base_5.pngbin0 -> 707 bytes
-rw-r--r--textures/crops_beanpole_plant_base_6.pngbin0 -> 800 bytes
-rw-r--r--textures/crops_beanpole_plant_top_1.pngbin0 -> 431 bytes
-rw-r--r--textures/crops_beanpole_plant_top_2.pngbin0 -> 603 bytes
-rw-r--r--textures/crops_beanpole_plant_top_3.pngbin0 -> 666 bytes
-rw-r--r--textures/crops_beanpole_plant_top_4.pngbin0 -> 743 bytes
-rw-r--r--textures/crops_beanpole_top.pngbin0 -> 341 bytes
-rw-r--r--textures/crops_green_bean.pngbin0 -> 299 bytes
-rw-r--r--textures/crops_green_bean_seed.pngbin0 -> 379 bytes
16 files changed, 268 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 90fcc87..5e1439f 100644
--- a/init.lua
+++ b/init.lua
@@ -17,5 +17,6 @@ dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/melon.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/corn.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/tomato.lua")
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/potato.lua")
+dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/polebean.lua")
minetest.log("action", "[crops] loaded.")
diff --git a/polebean.lua b/polebean.lua
new file mode 100644
index 0000000..7bea392
--- /dev/null
+++ b/polebean.lua
@@ -0,0 +1,267 @@
+
+--[[
+
+Copyright (C) 2015 - Auke Kok <sofar@foo-projects.org>
+
+"crops" is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1
+of the license, or (at your option) any later version.
+
+--]]
+
+local interval = crops_interval
+local chance = crops_chance
+
+minetest.register_craft({
+ output = "crops:beanpoles",
+ recipe = {
+ {'', '', ''},
+ {'default:stick', '', 'default:stick'},
+ {'default:stick', '', 'default:stick'},
+ }
+})
+
+minetest.register_craftitem("crops:green_bean", {
+ description = "Green Bean",
+ inventory_image = "crops_green_bean.png",
+ on_use = minetest.item_eat(1)
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "crops:green_bean_seed",
+ recipe = { "crops:green_bean" }
+})
+
+local function crops_beanpole_on_dig(pos, node, digger)
+ local bottom
+ local bottom_n
+ local top
+ local top_n
+ local drops = {}
+
+ if node.name == "crops:beanpole_base" or
+ node.name == "crops:beanpole_plant_base_1" or
+ node.name == "crops:beanpole_plant_base_2" or
+ node.name == "crops:beanpole_plant_base_3" or --grown tall enough for top section
+ node.name == "crops:beanpole_plant_base_4" or --flowering
+ node.name == "crops:beanpole_plant_base_5" or --ripe
+ node.name == "crops:beanpole_plant_base_6" --harvested
+ then
+ bottom = pos
+ bottom_n = node
+ top = { x = pos.x, y = pos.y + 1, z = pos.z }
+ top_n = minetest.get_node(top)
+ elseif node.name == "crops:beanpole_top" or
+ node.name == "crops:beanpole_plant_top_1" or
+ node.name == "crops:beanpole_plant_top_2" or --flowering
+ node.name == "crops:beanpole_plant_top_3" or --ripe
+ node.name == "crops:beanpole_plant_top_4" --harvested
+ then
+ top = pos
+ top_n = node
+ bottom = { x = pos.x, y = pos.y - 1, z = pos.z }
+ bottom_n = minetest.get_node(bottom)
+ else
+ -- ouch, this shouldn't happen
+ print("beanpole on_dig falsely attached to: " .. pos.x .. "," .. pos.y .. "," .. pos.z)
+ return
+ end
+
+ if bottom_n.name == "crops:beanpole_base" and top_n.name == "crops:beanpole_top" then
+ -- bare beanpole
+ table.insert(drops, "crops:beanpoles")
+ minetest.remove_node(bottom)
+ minetest.remove_node(top)
+ elseif (
+ bottom_n.name == "crops:beanpole_plant_base_1" or
+ bottom_n.name == "crops:beanpole_plant_base_2" or
+ bottom_n.name == "crops:beanpole_plant_base_3" or
+ bottom_n.name == "crops:beanpole_plant_base_4"
+ ) and (
+ top_n.name == "crops:beanpole_top" or
+ top_n.name == "crops:beanpole_plant_top_1" or
+ top_n.name == "crops:beanpole_plant_top_2"
+ ) then
+ -- non-ripe
+ for i = 1,4 do
+ table.insert(drops, "default:stick")
+ end
+ minetest.set_node(bottom, { name = "crops:beanpole_base"})
+ minetest.set_node(top, { name = "crops:beanpole_top"})
+ elseif bottom_n.name == "crops:beanpole_plant_base_5" and top_n.name == "crops:beanpole_plant_top_3" then
+ -- ripe beanpole
+ for i = 1,math.random(3,7) do
+ table.insert(drops, "crops:green_bean")
+ end
+ minetest.set_node(bottom, { name = "crops:beanpole_plant_base_6"})
+ minetest.set_node(top, { name = "crops:beanpole_plant_top_4"})
+ elseif bottom_n.name == "crops:beanpole_plant_base_6" and top_n.name == "crops:beanpole_plant_top_4" then
+ -- harvested beans
+ for i = 1,math.random(3,4) do
+ table.insert(drops, "default:stick")
+ end
+ minetest.remove_node(bottom)
+ minetest.remove_node(top)
+ else
+ -- ouch, this shouldn't happen
+ print("beanpole on_dig can't handle blocks at to: " .. bottom.x .. "," .. bottom.y .. "," .. bottom.z .. " and " .. top.x .. "," .. top.y .. "," .. top.z)
+ print("removing a " .. node.name .. " at " .. pos.x .. "," .. pos.y .. "," .. pos.z)
+ minetest.remove_node(pos)
+ return
+ end
+
+ core.handle_node_drops(pos, drops, digger)
+end
+
+minetest.register_node("crops:beanpole_base", {
+ description = "",
+ drawtype = "plantlike",
+ tiles = { "crops_beanpole_base.png" },
+ use_texture_alpha = true,
+ walkable = true,
+ sunlight_propagates = true,
+ paramtype = "light",
+ groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },
+ drop = {},
+ sounds = default.node_sound_leaves_defaults(),
+
+ on_dig = crops_beanpole_on_dig,
+})
+
+minetest.register_node("crops:beanpole_top", {
+ description = "",
+ drawtype = "plantlike",
+ tiles = { "crops_beanpole_top.png" },
+ use_texture_alpha = true,
+ walkable = true,
+ sunlight_propagates = true,
+ paramtype = "light",
+ groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },
+ drop = {},
+ sounds = default.node_sound_leaves_defaults(),
+
+ on_dig = crops_beanpole_on_dig,
+})
+
+minetest.register_node("crops:beanpoles", {
+ description = "beanpoles",
+ inventory_image = "crops_beanpole_top.png",
+ wield_image = "crops_beanpole_top.png",
+ tiles = { "crops_beanpole_base.png" },
+ drawtype = "plantlike",
+ sunlight_propagates = true,
+ use_texture_alpha = true,
+ paramtype = "light",
+ groups = { snappy=3,flammable=3,flora=1,attached_node=1 },
+ drop = {},
+ sounds = default.node_sound_leaves_defaults(),
+
+ on_place = function(itemstack, placer, pointed_thing)
+ local under = minetest.get_node(pointed_thing.under)
+ if minetest.get_item_group(under.name, "soil") <= 1 then
+ return
+ end
+ local top = { x = pointed_thing.above.x, y = pointed_thing.above.y + 1, z = pointed_thing.above.z }
+ if not minetest.get_node(top).name == "air" then
+ return
+ end
+ minetest.set_node(pointed_thing.above, {name="crops:beanpole_base"})
+ minetest.set_node(top, {name="crops:beanpole_top"})
+ if not minetest.setting_getbool("creative_mode") then
+ itemstack:take_item()
+ end
+ return itemstack
+ end
+})
+
+minetest.register_craftitem("crops:green_bean_seed", {
+ description = "green bean seed",
+ inventory_image = "crops_green_bean_seed.png",
+ wield_image = "crops_green_bean_seed.png",
+
+ on_place = function(itemstack, placer, pointed_thing)
+ local under = minetest.get_node(pointed_thing.under)
+ if under.name == "crops:beanpole_base" then
+ minetest.set_node(pointed_thing.under, {name="crops:beanpole_plant_base_1"})
+ elseif under.name == "crops:beanpole_top" then
+ local below = { x = pointed_thing.under.x, y = pointed_thing.under.y - 1, z = pointed_thing.under.z }
+ if minetest.get_node(below).name == "crops:beanpole_base" then
+ minetest.set_node(below, {name="crops:beanpole_plant_base_1"})
+ else
+ return
+ end
+ else
+ return
+ end
+ if not minetest.setting_getbool("creative_mode") then
+ itemstack:take_item()
+ end
+ return itemstack
+ end
+})
+
+for stage = 1,6 do
+minetest.register_node("crops:beanpole_plant_base_" .. stage, {
+ description = "green bean plant",
+ tiles = { "crops_beanpole_plant_base_" .. stage .. ".png" },
+ drawtype = "plantlike",
+ sunlight_propagates = true,
+ use_texture_alpha = true,
+ paramtype = "light",
+ walkable = false,
+ groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },
+ drop = {},
+ sounds = default.node_sound_leaves_defaults(),
+
+ on_dig = crops_beanpole_on_dig
+})
+end
+
+for stage = 1,4 do
+minetest.register_node("crops:beanpole_plant_top_" .. stage, {
+ description = "green bean plant",
+ tiles = { "crops_beanpole_plant_top_" .. stage .. ".png" },
+ drawtype = "plantlike",
+ sunlight_propagates = true,
+ use_texture_alpha = true,
+ paramtype = "light",
+ walkable = true,
+ groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },
+ drop = {},
+ sounds = default.node_sound_leaves_defaults(),
+
+ on_dig = crops_beanpole_on_dig
+})
+end
+
+minetest.register_abm({
+ nodenames = { "crops:beanpole_plant_base_1", "crops:beanpole_plant_base_2", "crops:beanpole_plant_base_3", "crops:beanpole_plant_base_4" },
+ interval = interval,
+ chance = chance,
+ neighbors = { "group:soil" },
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ if minetest.get_node_light(pos, nil) < 13 then
+ return
+ end
+ if node.name == "crops:beanpole_plant_base_1" then
+ minetest.set_node(pos, { name = "crops:beanpole_plant_base_2"})
+ elseif node.name == "crops:beanpole_plant_base_2" then
+ minetest.set_node(pos, { name = "crops:beanpole_plant_base_3"})
+ elseif node.name == "crops:beanpole_plant_base_3" then
+ local apos = {x = pos.x, y = pos.y + 1, z = pos.z}
+ local above = minetest.get_node(apos)
+ if above.name == "crops:beanpole_top" then
+ minetest.set_node(apos, { name = "crops:beanpole_plant_top_1" })
+ elseif above.name == "crops:beanpole_plant_top_1" then
+ minetest.set_node(pos, { name = "crops:beanpole_plant_base_4" })
+ minetest.set_node(apos, { name = "crops:beanpole_plant_top_2" })
+ end
+ elseif node.name == "crops:beanpole_plant_base_4" then
+ local apos = {x = pos.x, y = pos.y + 1, z = pos.z}
+ minetest.set_node(pos, { name = "crops:beanpole_plant_base_5" })
+ minetest.set_node(apos, { name = "crops:beanpole_plant_top_3" })
+ end
+ end
+})
diff --git a/textures/crops_beanpole_base.png b/textures/crops_beanpole_base.png
new file mode 100644
index 0000000..ae8ffde
--- /dev/null
+++ b/textures/crops_beanpole_base.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_base_1.png b/textures/crops_beanpole_plant_base_1.png
new file mode 100644
index 0000000..de79e10
--- /dev/null
+++ b/textures/crops_beanpole_plant_base_1.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_base_2.png b/textures/crops_beanpole_plant_base_2.png
new file mode 100644
index 0000000..10b6d52
--- /dev/null
+++ b/textures/crops_beanpole_plant_base_2.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_base_3.png b/textures/crops_beanpole_plant_base_3.png
new file mode 100644
index 0000000..3b841b4
--- /dev/null
+++ b/textures/crops_beanpole_plant_base_3.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_base_4.png b/textures/crops_beanpole_plant_base_4.png
new file mode 100644
index 0000000..6ffecc5
--- /dev/null
+++ b/textures/crops_beanpole_plant_base_4.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_base_5.png b/textures/crops_beanpole_plant_base_5.png
new file mode 100644
index 0000000..e5f09ec
--- /dev/null
+++ b/textures/crops_beanpole_plant_base_5.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_base_6.png b/textures/crops_beanpole_plant_base_6.png
new file mode 100644
index 0000000..514be64
--- /dev/null
+++ b/textures/crops_beanpole_plant_base_6.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_top_1.png b/textures/crops_beanpole_plant_top_1.png
new file mode 100644
index 0000000..7d4904e
--- /dev/null
+++ b/textures/crops_beanpole_plant_top_1.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_top_2.png b/textures/crops_beanpole_plant_top_2.png
new file mode 100644
index 0000000..4e99731
--- /dev/null
+++ b/textures/crops_beanpole_plant_top_2.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_top_3.png b/textures/crops_beanpole_plant_top_3.png
new file mode 100644
index 0000000..a7914b4
--- /dev/null
+++ b/textures/crops_beanpole_plant_top_3.png
Binary files differ
diff --git a/textures/crops_beanpole_plant_top_4.png b/textures/crops_beanpole_plant_top_4.png
new file mode 100644
index 0000000..9937b8b
--- /dev/null
+++ b/textures/crops_beanpole_plant_top_4.png
Binary files differ
diff --git a/textures/crops_beanpole_top.png b/textures/crops_beanpole_top.png
new file mode 100644
index 0000000..0b6a9d0
--- /dev/null
+++ b/textures/crops_beanpole_top.png
Binary files differ
diff --git a/textures/crops_green_bean.png b/textures/crops_green_bean.png
new file mode 100644
index 0000000..0f792d8
--- /dev/null
+++ b/textures/crops_green_bean.png
Binary files differ
diff --git a/textures/crops_green_bean_seed.png b/textures/crops_green_bean_seed.png
new file mode 100644
index 0000000..ea2d087
--- /dev/null
+++ b/textures/crops_green_bean_seed.png
Binary files differ