Added Green Beans and improved growing plants

master
Infinatum 2015-08-31 22:20:58 +01:00
parent 7d5e6da985
commit 82eaba6d6b
35 changed files with 399 additions and 91 deletions

View File

@ -30,6 +30,10 @@ dofile(minetest.get_modpath("farm_test").."/mod_files/sweet_corn.lua")
print("Farm_test: Loading 'root-plant.lua'")
dofile(minetest.get_modpath("farm_test").."/mod_files/root-plant.lua")
print("Beer_test: Loading 'green_beans.lua'")
dofile(minetest.get_modpath("farm_test").."/mod_files/green_beans.lua")
print("")
print("###########################################################")
print("Beer_Test has loaded successfully ")

357
mod_files/green_beans.lua Normal file
View File

@ -0,0 +1,357 @@
--======================--
-- Items --
--======================--
minetest.register_craftitem("farm_test:green_bean", {
description = "Green bean",
inventory_image = "farm_test_green_bean.png",
})
--======================--
-- Crafts --
--======================--
--[[
minetest.register_craft({
output = "farm_test:seed_green_bean",
recipe = {
{"farm_test:red_green_bean"},
}
})
]]--
--======================--
-- Plants --
--======================--
-----------------------
-- green_beanes growing --
-----------------------
-- green_bean --
--
-- Place seeds
--
local function place_seed(itemstack, placer, pointed_thing, plantname)
local pt = pointed_thing
-- check if pointing at a node
if not pt then
return
end
if pt.type ~= "node" then
return
end
local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)
-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
return
end
if not minetest.registered_nodes[above.name] then
return
end
-- check if pointing at the top of the node
if pt.above.y ~= pt.under.y+1 then
return
end
-- check if you can replace the node above the pointed node
if not minetest.registered_nodes[above.name].buildable_to then
return
end
-- check if pointing at soil
if minetest.get_item_group(under.name, "soil") <= 1 then
return
end
-- add the node and remove 1 item from the itemstack
minetest.add_node(pt.above, {name=plantname})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end
minetest.register_craftitem("farm_test:seed_green_bean", {
description = "Green Bean Seed",
inventory_image = "farm_test_green_bean_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return place_seed(itemstack, placer, pointed_thing, "farm_test:green_bean_1")
end,
})
for i=1,8 do
local drop = {
items = {
--{items = {'farm_test:yellow_green_bean'},rarity=18-i},
--{items = {'farm_test:yellow_green_bean'},rarity=27-i*2},
{items = {'farm_test:green_green_bean'},rarity=9-i},
{items = {'farm_test:green_green_bean'},rarity=18-i*2},
{items = {'farm_test:green_green_bean'},rarity=27-i*3},
}
}
minetest.register_node("farm_test:green_bean_"..i, {
drawtype = "plantlike",
tiles = {"farm_test_green_bean_"..i..".png"},
paramtype = "light",
walkable = false,
buildable_to = true,
is_ground_content = true,
drop = drop,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
groups = {snappy=3,flammable=2,plant=1,green_bean=i,not_in_creative_inventory=1,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
end
minetest.register_abm({
nodenames = {"group:green_bean"},
neighbors = {"group:soil"},
interval = 80,
chance = 2,
action = function(pos, node)
-- return if already full grown
if minetest.get_item_group(node.name, "green_bean") == 8 then
return
end
-- check if on wet soil
pos.y = pos.y-1
local n = minetest.get_node(pos)
if minetest.get_item_group(n.name, "soil") < 3 then
return
end
pos.y = pos.y+1
-- check light
if not minetest.get_node_light(pos) then
return
end
if minetest.get_node_light(pos) < 13 then
return
end
-- grow
local height = minetest.get_item_group(node.name, "green_bean") + 1
minetest.set_node(pos, {name="farm_test:green_bean_"..height})
end
})
-- green_beans 9 and 9a --
minetest.register_node("farm_test:green_bean_9", {
description = "farm_test:green_bean_9",
paramtype = "light",
walkable = false,
drop = "farm_test:green_green_bean",
drawtype = "nodebox",
paramtype2 = "facedir",
tiles = {"farm_test_plant_green_bean.png"},
groups = {chopspy=2, oddly_breakable_by_hand=3, flammable=2, plant=1},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{-0.1, 0.5, -0.1, 0.1, -0.5, 0.1}
},
},
node_box = {
type = "fixed",
fixed = {
{-0.1, -0.5, -0.1, 0.1, 0.5, 0.1}, -- side f
{-0.4, -0.5, 0.2, 0.4, 0.5, 0.2}, -- side f
{-0.4, -0.5, -0.2, 0.4, 0.5, -0.2}, -- side f
{-0.2, -0.5, 0.4, -0.2, 0.5, -0.4}, -- side f
{0.2, -0.5, 0.4, 0.2, 0.5, -0.4}, -- side f
{-0.1, -0.5, -0.1, 0.1, 0.5, 0.1}, -- side f
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}, -- side f
},
},
})
minetest.register_node("farm_test:green_bean_9a", {
description = "farm_test:green_bean_9a",
paramtype = "light",
walkable = false,
drop = "farm_test:green_green_bean",
drawtype = "nodebox",
paramtype2 = "facedir",
tiles = {"farm_test_plant_green_bean.png^farm_test_plant_green_bean_flower.png"},
groups = {chopspy=2, oddly_breakable_by_hand=3, flammable=2, plant=1},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{-0.1, 0.5, -0.1, 0.1, -0.5, 0.1}
},
},
node_box = {
type = "fixed",
fixed = {
{-0.1, -0.5, -0.1, 0.1, 0.5, 0.1}, -- side f
{-0.4, -0.5, 0.2, 0.4, 0.5, 0.2}, -- side f
{-0.4, -0.5, -0.2, 0.4, 0.5, -0.2}, -- side f
{-0.2, -0.5, 0.4, -0.2, 0.5, -0.4}, -- side f
{0.2, -0.5, 0.4, 0.2, 0.5, -0.4}, -- side f
{-0.1, -0.5, -0.1, 0.1, 0.5, 0.1}, -- side f
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}, -- side f
},
},
})
minetest.register_node("farm_test:green_bean_9b", {
description = "farm_test:green_bean_9b",
paramtype = "light",
walkable = false,
drop = "farm_test:green_bean",
drawtype = "nodebox",
paramtype2 = "facedir",
tiles = {"farm_test_plant_green_bean.png^farm_test_plant_green_bean_crop.png"},
groups = {chopspy=2, oddly_breakable_by_hand=3, flammable=2, plant=1},
sounds = default.node_sound_wood_defaults(),
selection_box = {
type = "fixed",
fixed = {
{-0.1, 0.5, -0.1, 0.1, -0.5, 0.1}
},
},
node_box = {
type = "fixed",
fixed = {
{-0.1, -0.5, -0.1, 0.1, 0.5, 0.1}, -- side f
{-0.4, -0.5, 0.2, 0.4, 0.5, 0.2}, -- side f
{-0.4, -0.5, -0.2, 0.4, 0.5, -0.2}, -- side f
{-0.2, -0.5, 0.4, -0.2, 0.5, -0.4}, -- side f
{0.2, -0.5, 0.4, 0.2, 0.5, -0.4}, -- side f
{-0.1, -0.5, -0.1, 0.1, 0.5, 0.1}, -- side f
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}, -- side f
},
},
on_punch = function(pos, node, puncher)
local tool = puncher:get_wielded_item():get_name()
if tool and tool == "" then
node.name = "farm_test:green_bean_9"
minetest.env:set_node(pos, node)
puncher:get_inventory():add_item("main", ItemStack("farm_test:green_bean"))
end
end
})
-- Grow Plant --
-- grow green_beans on plant --
-- farming:add_plant("farm_test:green_bean_8", {"farm_test:green_bean_9"}, 80, 20)
-- Regrowing green_beans when picked --
-- old crappy code --
--[[ ]]--
minetest.register_abm({
nodenames = {"farm_test:green_bean_8"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:green_bean_9"})
end,
})
minetest.register_abm({
nodenames = {"farm_test:green_bean_9"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:green_bean_9a"})
end,
})
minetest.register_abm({
nodenames = {"farm_test:green_bean_9a"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:green_bean_9b"})
end,
})
--[[ ]]--
-- grow up up and away!--
minetest.register_abm({
nodenames = {"farm_test:green_bean_9a"},
neighbors = {"farming:soil_wet"},
interval = 50,
chance = 20,
action = function(pos, node)
pos.y = pos.y-1
local name = minetest.get_node(pos).name
if name == "farming:soil_wet" or name == "default:dirt_with_grass" or name == "farming:soil" or name == "default:dirt" then
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "farm_test:green_bean_9a" and height < 2 do
height = height+1
pos.y = pos.y+1
end
if height < 4 then
if minetest.get_node(pos).name == "farm_test:growing_rope_down" then
minetest.set_node(pos, {name="farm_test:green_bean_9"})
end
end
end
end,
})
-------=============================================[--]--
print("Farm_test: farm_test.lua [ok]")

View File

@ -2,6 +2,9 @@
-- Plants --
--======================--
------------------------
-- sweetcorn growing --
------------------------
@ -12,7 +15,9 @@ inventory_image = "farm_test_sweet_corn_seed.png",
steps = 8,
minlight = 13,
maxlight = LIGHT_MAX,
fertility = {"grassland"}
})
@ -81,45 +86,26 @@ minetest.register_node("farm_test:sweet_corn_tassel", {
-- switch plant stages --
minetest.register_abm({
nodenames = {"farm_test:sweet_corn_8", "farm_test:sweet_corn_9"},
nodenames = {"farm_test:sweet_corn_8"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node)
pos.y = pos.y+1
local nn = minetest.get_node(pos).name
pos.y = pos.y-1
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
minetest.set_node(pos, {name="farm_test:sweet_corn_8"})
end
-- check if there is air nearby
if minetest.find_node_near(pos, 5, {"air"}) then
if node.name == "farm_test:sweet_corn_8" then
minetest.set_node(pos, {name="farm_test:sweet_corn_9"})
end
end
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:sweet_corn_9"})
end,
})
minetest.register_abm({
nodenames = {"farm_test:sweet_corn_9", "farm_test:sweet_corn_9a"},
nodenames = {"farm_test:sweet_corn_9"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node)
pos.y = pos.y+1
local nn = minetest.get_node(pos).name
pos.y = pos.y-1
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
minetest.set_node(pos, {name="farm_test:sweet_corn_9"})
end
-- check if there is air nearby
if minetest.find_node_near(pos, 5, {"air"}) then
if node.name == "farm_test:sweet_corn_9" then
minetest.set_node(pos, {name="farm_test:sweet_corn_9a"})
end
end
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:sweet_corn_9a"})
end,
})
-- grow up up and away!--
minetest.register_abm({

View File

@ -6,11 +6,13 @@
minetest.register_craftitem("farm_test:red_tomato", {
description = "Red Tomato",
inventory_image = "farm_test_tomato_red.png",
on_use = minetest.item_eat(2),
})
minetest.register_craftitem("farm_test:green_tomato", {
description = "Green Tomato",
inventory_image = "farm_test_tomato_green.png",
on_use = minetest.item_eat(1),
})
--======================--
@ -160,7 +162,7 @@ minetest.register_abm({
end
})
-- oars 9 and 9a --
-- tomatos 9 and 9a --
minetest.register_node("farm_test:tomato_9", {
description = "farm_test:tomato_9",
@ -269,85 +271,44 @@ minetest.register_node("farm_test:tomato_9c", {
--[[ ]]--
minetest.register_abm({
nodenames = {"farm_test:tomato_8", "farm_test:tomato_9"},
nodenames = {"farm_test:tomato_8"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node)
pos.y = pos.y+1
local nn = minetest.get_node(pos).name
pos.y = pos.y-1
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
minetest.set_node(pos, {name="farm_test:tomato_8"})
end
-- check if there is air nearby
if minetest.find_node_near(pos, 5, {"air"}) then
if node.name == "farm_test:tomato_8" then
minetest.set_node(pos, {name="farm_test:tomato_9"})
end
end
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:tomato_9"})
end,
})
minetest.register_abm({
nodenames = {"farm_test:tomato_9", "farm_test:tomato_9a"},
interval = 30,
chance = 50,
action = function(pos, node)
pos.y = pos.y+1
local nn = minetest.get_node(pos).name
pos.y = pos.y-1
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
minetest.set_node(pos, {name="farm_test:tomato_9"})
end
-- check if there is air nearby
if minetest.find_node_near(pos, 5, {"air"}) then
if node.name == "farm_test:tomato_9" then
minetest.set_node(pos, {name="farm_test:tomato_9a"})
end
end
end,
})
minetest.register_abm({
nodenames = {"farm_test:tomato_9b", "farm_test:tomato_9c"},
nodenames = {"farm_test:tomato_9"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node)
pos.y = pos.y+1
local nn = minetest.get_node(pos).name
pos.y = pos.y-1
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
minetest.set_node(pos, {name="farm_test:tomato_9b"})
end
-- check if there is air nearby
if minetest.find_node_near(pos, 5, {"air"}) then
if node.name == "farm_test:tomato_9b" then
minetest.set_node(pos, {name="farm_test:tomato_9c"})
end
end
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:tomato_9a"})
end,
})
minetest.register_abm({
nodenames = {"farm_test:tomato_9c", "farm_test:tomato_9"},
nodenames = {"farm_test:tomato_9b"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node)
pos.y = pos.y+1
local nn = minetest.get_node(pos).name
pos.y = pos.y-1
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable then
minetest.set_node(pos, {name="farm_test:tomato_9c"})
end
-- check if there is air nearby
if minetest.find_node_near(pos, 5, {"air"}) then
if node.name == "farm_test:tomato_9c" then
minetest.set_node(pos, {name="farm_test:tomato_9"})
end
end
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:tomato_9c"})
end,
})
minetest.register_abm({
nodenames = {"farm_test:tomato_9c"},
neighbors = {"air"},
interval = 15,
chance = 5,
action = function(pos, node, active_object_count, active_object_count_wider)
minetest.set_node(pos, {name = "farm_test:tomato_9"})
end,
})
--[[ ]]--

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 337 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B