From 16cc62a1d4d7c02a84b2ddc1538f5e81404b415c Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sun, 5 Jul 2015 10:54:18 +0100 Subject: [PATCH] Code tidy and tweak --- beanpole.lua | 90 ++++++++++++++++++++++++++--------------- blueberry.lua | 40 ++++++++++++------- cocoa.lua | 55 +++++++++++++++++-------- coffee.lua | 53 ++++++++++++++---------- compatibility.lua | 2 +- corn.lua | 77 +++++++++++++++++++++++------------ cotton.lua | 90 +++++++++++++++++++++++++---------------- cucumber.lua | 38 +++++++++++------- donut.lua | 2 +- grass.lua | 6 +-- hoes.lua | 10 ++--- init.lua | 36 +++++++++++------ mapgen.lua | 9 ++--- melon.lua | 60 ++++++++++++++++++---------- potato.lua | 42 +++++++++++-------- pumpkin.lua | 100 +++++++++++++++++++++++++++++++++------------- raspberry.lua | 40 ++++++++++++------- rhubarb.lua | 33 +++++++++------ soil.lua | 22 +++++----- statistics.lua | 4 +- sugar.lua | 3 +- tomato.lua | 72 +++++++++++++++++++++------------ wheat.lua | 90 +++++++++++++++++++++++++---------------- 23 files changed, 622 insertions(+), 352 deletions(-) diff --git a/beanpole.lua b/beanpole.lua index 8cdfaf3..f9ba132 100644 --- a/beanpole.lua +++ b/beanpole.lua @@ -44,19 +44,28 @@ minetest.register_node("farming:beanpole", { sunlight_propagates = true, drop = { items = { - {items = {'farming:beanpole'},rarity=1}, + {items = {'farming:beanpole'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), on_place = function(itemstack, placer, pointed_thing) local nod = minetest.get_node_or_nil(pointed_thing.under) - if nod and minetest.get_item_group(nod.name, "soil") < 2 then return end - local top = {x=pointed_thing.above.x, y=pointed_thing.above.y+1, z=pointed_thing.above.z} + if nod and minetest.get_item_group(nod.name, "soil") < 2 then + return + end + local top = { + x = pointed_thing.above.x, + y = pointed_thing.above.y + 1, + z = pointed_thing.above.z + } nod = minetest.get_node_or_nil(top) if nod and nod.name ~= "air" then return end - minetest.set_node(pointed_thing.above, {name="farming:beanpole"}) + minetest.set_node(pointed_thing.above, {name = "farming:beanpole"}) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end @@ -85,11 +94,14 @@ minetest.register_node("farming:beanpole_1", { sunlight_propagates = true, drop = { items = { - {items = {'farming:beanpole'},rarity=1}, + {items = {'farming:beanpole'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=3,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 3, not_in_creative_inventory = 1, + attached_node = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -103,11 +115,14 @@ minetest.register_node("farming:beanpole_2", { sunlight_propagates = true, drop = { items = { - {items = {'farming:beanpole'},rarity=1}, + {items = {'farming:beanpole'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -121,11 +136,14 @@ minetest.register_node("farming:beanpole_3", { sunlight_propagates = true, drop = { items = { - {items = {'farming:beanpole'},rarity=1}, + {items = {'farming:beanpole'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -140,35 +158,40 @@ minetest.register_node("farming:beanpole_4", { sunlight_propagates = true, drop = { items = { - {items = {'farming:beanpole'},rarity=1}, + {items = {'farming:beanpole'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Green Bean growth does not have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:beanpole_5", { drawtype = "plantlike", tiles = {"farming_beanpole_5.png"}, visual_scale = 1.45, paramtype = "light", - waving = 1, walkable = false, buildable_to = true, sunlight_propagates = true, drop = { items = { - {items = {'farming:beanpole'},rarity=1}, - {items = {'farming:beans 3'},rarity=1}, - {items = {'farming:beans 2'},rarity=2}, - {items = {'farming:beans 2'},rarity=3}, + {items = {'farming:beanpole'}, rarity = 1}, + {items = {'farming:beans 3'}, rarity = 1}, + {items = {'farming:beans 2'}, rarity = 2}, + {items = {'farming:beans 2'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -184,12 +207,15 @@ minetest.register_node("farming:beanbush", { sunlight_propagates = true, drop = { items = { - {items = {'farming:beans 1'},rarity=1}, - {items = {'farming:beans 1'},rarity=2}, - {items = {'farming:beans 1'},rarity=3}, + {items = {'farming:beans 1'}, rarity = 1}, + {items = {'farming:beans 1'}, rarity = 2}, + {items = {'farming:beans 1'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory=1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/blueberry.lua b/blueberry.lua index 6b3422d..f785c23 100644 --- a/blueberry.lua +++ b/blueberry.lua @@ -32,12 +32,14 @@ minetest.register_node("farming:blueberry_1", { tiles = {"farming_blueberry_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -50,8 +52,11 @@ minetest.register_node("farming:blueberry_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -64,12 +69,15 @@ minetest.register_node("farming:blueberry_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Blueberry growth does not have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:blueberry_4", { drawtype = "plantlike", @@ -79,15 +87,17 @@ minetest.register_node("farming:blueberry_4", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:blueberries 2'},rarity=1}, - {items = {'farming:blueberries'},rarity=2}, - {items = {'farming:blueberries'},rarity=3}, + {items = {'farming:blueberries 2'}, rarity = 1}, + {items = {'farming:blueberries'}, rarity = 2}, + {items = {'farming:blueberries'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory=1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/cocoa.lua b/cocoa.lua index 0c76f26..c6e4b19 100644 --- a/cocoa.lua +++ b/cocoa.lua @@ -22,7 +22,7 @@ function place_cocoa(itemstack, placer, pointed_thing, plantname) end -- add the node and remove 1 item from the itemstack - minetest.add_node(pt.above, {name=plantname}) + minetest.add_node(pt.above, {name = plantname}) if not minetest.setting_getbool("creative_mode") then itemstack:take_item() end @@ -85,11 +85,17 @@ minetest.register_node("farming:cocoa_1", { walkable = true, drop = { items = { - {items = {'farming:cocoa_beans 1'},rarity=2}, + {items = {'farming:cocoa_beans 1'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,growing=1}, + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} + }, + groups = { + snappy = 3, flammable = 2, plant = 1, growing = 1, + not_in_creative_inventory=1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -100,11 +106,17 @@ minetest.register_node("farming:cocoa_2", { walkable = true, drop = { items = { - {items = {'farming:cocoa_beans 1'},rarity=1}, + {items = {'farming:cocoa_beans 1'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,growing=1}, + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} + }, + groups = { + snappy = 3, flammable = 2, plant = 1, growing = 1, + not_in_creative_inventory=1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -117,12 +129,18 @@ minetest.register_node("farming:cocoa_3", { walkable = true, drop = { items = { - {items = {'farming:cocoa_beans 2'},rarity=1}, - {items = {'farming:cocoa_beans 1'},rarity=2}, + {items = {'farming:cocoa_beans 2'}, rarity = 1}, + {items = {'farming:cocoa_beans 1'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1}, + selection_box = { + type = "fixed", + fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3} + }, + groups = { + snappy = 3, flammable = 2, plant = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -144,10 +162,15 @@ minetest.register_abm({ else return end - if minetest.get_node(pos).name == "air" and minetest.get_node_light(pos) > 12 then --- print ("COCOA", pos.x, pos.y, pos.z) - minetest.set_node(pos,{name="farming:cocoa_"..tostring(math.random(1,3))}) - end + local nod = minetest.get_node_or_nil(pos) + if nod then nod = nod.name else return end + if nod == "air" + and minetest.get_node_light(pos) > 12 then +-- print ("COCOA", pos.x, pos.y, pos.z) + minetest.set_node(pos, { + name = "farming:cocoa_"..tostring(math.random(1, 3)) + }) + end end, -}) +}) \ No newline at end of file diff --git a/coffee.lua b/coffee.lua index a0d15cf..19c3f7f 100644 --- a/coffee.lua +++ b/coffee.lua @@ -27,7 +27,7 @@ minetest.register_node("farming:drinking_cup", { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.25, 0.25} }, - groups = {vessel=1,dig_immediate=3,attached_node=1}, + groups = {vessel = 1, dig_immediate = 3, attached_node = 1}, sounds = default.node_sound_glass_defaults(), }) @@ -58,7 +58,7 @@ minetest.register_node("farming:coffee_cup", { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.25, 0.25} }, - groups = {vessel=1,dig_immediate=3,attached_node=1}, + groups = {vessel = 1, dig_immediate = 3, attached_node = 1}, on_use = minetest.item_eat(2, "farming:drinking_cup"), sounds = default.node_sound_glass_defaults(), }) @@ -99,7 +99,7 @@ minetest.register_node("farming:coffee_cup_hot", { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.25, 0.25} }, - groups = {vessel=1,dig_immediate=3,attached_node=1}, + groups = {vessel = 1, dig_immediate = 3, attached_node = 1}, on_use = minetest.item_eat(3, "farming:drinking_cup"), sounds = default.node_sound_glass_defaults(), }) @@ -111,12 +111,14 @@ minetest.register_node("farming:coffee_1", { tiles = {"farming_coffee_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -129,8 +131,11 @@ minetest.register_node("farming:coffee_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -143,8 +148,11 @@ minetest.register_node("farming:coffee_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -157,12 +165,15 @@ minetest.register_node("farming:coffee_4", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Coffee growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth doesn not have growing group so abm never checks these minetest.register_node("farming:coffee_5", { drawtype = "plantlike", @@ -172,15 +183,17 @@ minetest.register_node("farming:coffee_5", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:coffee_beans 2'},rarity=1}, - {items = {'farming:coffee_beans 2'},rarity=2}, - {items = {'farming:coffee_beans 2'},rarity=3}, + {items = {'farming:coffee_beans 2'}, rarity = 1}, + {items = {'farming:coffee_beans 2'}, rarity = 2}, + {items = {'farming:coffee_beans 2'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory=1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/compatibility.lua b/compatibility.lua index a875d9b..708b54e 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -94,4 +94,4 @@ minetest.register_alias("farming_plus:tomato_3", "farming:tomato_6") minetest.register_alias("farming_plus:tomato", "farming:tomato_8") -- Weed -minetest.register_alias("farming:weed", "default:grass_2") +minetest.register_alias("farming:weed", "default:grass_2") \ No newline at end of file diff --git a/corn.lua b/corn.lua index e29c578..dcb0833 100644 --- a/corn.lua +++ b/corn.lua @@ -58,8 +58,11 @@ minetest.register_node("farming:corn_1", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -71,8 +74,11 @@ minetest.register_node("farming:corn_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -85,8 +91,11 @@ minetest.register_node("farming:corn_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -99,8 +108,11 @@ minetest.register_node("farming:corn_4", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -108,12 +120,16 @@ minetest.register_node("farming:corn_5", { drawtype = "plantlike", tiles = {"farming_corn_5.png"}, paramtype = "light", + waving = 1, sunlight_propagates = true, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -122,12 +138,16 @@ minetest.register_node("farming:corn_6", { tiles = {"farming_corn_6.png"}, visual_scale = 1.45, paramtype = "light", + waving = 1, sunlight_propagates = true, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -136,22 +156,25 @@ minetest.register_node("farming:corn_7", { tiles = {"farming_corn_7.png"}, visual_scale = 1.45, paramtype = "light", + waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:corn'},rarity=1}, - {items = {'farming:corn'},rarity=2}, - {items = {'farming:corn'},rarity=3}, + {items = {'farming:corn'}, rarity = 1}, + {items = {'farming:corn'}, rarity = 2}, + {items = {'farming:corn'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Corn growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth doesn not have growing group so abm never checks these minetest.register_node("farming:corn_8", { drawtype = "plantlike", @@ -161,15 +184,17 @@ minetest.register_node("farming:corn_8", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:corn 2'},rarity=1}, - {items = {'farming:corn 2'},rarity=2}, - {items = {'farming:corn 2'},rarity=2}, + {items = {'farming:corn 2'}, rarity = 1}, + {items = {'farming:corn 2'}, rarity = 2}, + {items = {'farming:corn 2'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/cotton.lua b/cotton.lua index f7d307f..1edbd3a 100644 --- a/cotton.lua +++ b/cotton.lua @@ -19,7 +19,7 @@ minetest.register_node("farming:seed_cotton", { paramtype2 = "wallmounted", walkable = false, sunlight_propagates = true, - selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, + selection_box = farming.select, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1") end, @@ -51,12 +51,14 @@ minetest.register_node("farming:cotton_1", { tiles = {"farming_cotton_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -65,12 +67,14 @@ minetest.register_node("farming:cotton_2", { tiles = {"farming_cotton_2.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -83,8 +87,11 @@ minetest.register_node("farming:cotton_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -97,8 +104,11 @@ minetest.register_node("farming:cotton_4", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -112,11 +122,14 @@ minetest.register_node("farming:cotton_5", { buildable_to = true, drop = { items = { - {items = {"farming:seed_cotton"},rarity=1}, + {items = {"farming:seed_cotton"}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -129,12 +142,15 @@ minetest.register_node("farming:cotton_6", { buildable_to = true, drop = { items = { - {items = {"farming:cotton"},rarity=1}, - {items = {"farming:cotton"},rarity=2}, + {items = {"farming:cotton"}, rarity = 1}, + {items = {"farming:cotton"}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -147,18 +163,21 @@ minetest.register_node("farming:cotton_7", { buildable_to = true, drop = { items = { - {items = {"farming:cotton"},rarity=1}, - {items = {"farming:cotton"},rarity=2}, - {items = {"farming:seed_cotton"},rarity=1}, - {items = {"farming:seed_cotton"},rarity=2}, + {items = {"farming:cotton"}, rarity = 1}, + {items = {"farming:cotton"}, rarity = 2}, + {items = {"farming:seed_cotton"}, rarity = 1}, + {items = {"farming:seed_cotton"}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Define last stage of Cotton growth separate and without growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:cotton_8", { drawtype = "plantlike", @@ -169,15 +188,18 @@ minetest.register_node("farming:cotton_8", { buildable_to = true, drop = { items = { - {items = {"farming:string"},rarity=1}, - {items = {"farming:string"},rarity=2}, - {items = {"farming:string"},rarity=3}, - {items = {"farming:seed_cotton"},rarity=1}, - {items = {"farming:seed_cotton"},rarity=2}, - {items = {"farming:seed_cotton"},rarity=3}, + {items = {"farming:string"}, rarity = 1}, + {items = {"farming:string"}, rarity = 2}, + {items = {"farming:string"}, rarity = 3}, + {items = {"farming:seed_cotton"}, rarity = 1}, + {items = {"farming:seed_cotton"}, rarity = 2}, + {items = {"farming:seed_cotton"}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/cucumber.lua b/cucumber.lua index 4301890..6a1bbab 100644 --- a/cucumber.lua +++ b/cucumber.lua @@ -17,12 +17,14 @@ minetest.register_node("farming:cucumber_1", { drawtype = "plantlike", tiles = {"farming_cucumber_1.png"}, paramtype = "light", - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -34,8 +36,11 @@ minetest.register_node("farming:cucumber_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -47,12 +52,15 @@ minetest.register_node("farming:cucumber_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Cucumber growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:cucumber_4", { drawtype = "plantlike", @@ -61,14 +69,16 @@ minetest.register_node("farming:cucumber_4", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:cucumber'},rarity=1}, - {items = {'farming:cucumber 2'},rarity=2}, + {items = {'farming:cucumber'}, rarity = 1}, + {items = {'farming:cucumber 2'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/donut.lua b/donut.lua index 6dc385a..1b49848 100644 --- a/donut.lua +++ b/donut.lua @@ -42,4 +42,4 @@ minetest.register_craft({ {'default:apple'}, {'farming:donut'}, } -}) +}) \ No newline at end of file diff --git a/grass.lua b/grass.lua index e3d1b6c..04a66a8 100644 --- a/grass.lua +++ b/grass.lua @@ -7,7 +7,7 @@ for i=1,5 do drop = { max_items = 1, items = { - {items = {'farming:seed_wheat'},rarity = 5}, + {items = {'farming:seed_wheat'}, rarity = 5}, {items = {'default:grass_1'}}, } }, @@ -21,8 +21,8 @@ minetest.override_item("default:junglegrass", { drop = { max_items = 1, items = { - {items = {'farming:seed_cotton'},rarity = 8}, + {items = {'farming:seed_cotton'}, rarity = 8}, {items = {'default:junglegrass'}}, } }, -}) +}) \ No newline at end of file diff --git a/hoes.lua b/hoes.lua index cd00f5e..3a2d107 100644 --- a/hoes.lua +++ b/hoes.lua @@ -55,7 +55,7 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses) return end - local p = {x=pt.under.x, y=pt.under.y+1, z=pt.under.z} + local p = {x = pt.under.x, y = pt.under.y + 1, z = pt.under.z} local above = minetest.get_node(p) -- return if any of the nodes is not registered @@ -75,9 +75,9 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses) end -- turn the node into soil, wear out item and play sound - minetest.set_node(pt.under, {name="farming:soil"}) - minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5,}) - itemstack:add_wear(65535/(uses-1)) + minetest.set_node(pt.under, {name = "farming:soil"}) + minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5}) + itemstack:add_wear(65535/(uses - 1)) return itemstack end @@ -147,4 +147,4 @@ farming.register_hoe(":farming:hoe_diamond", { {"", "group:stick"}, {"", "group:stick"}, } -}) +}) \ No newline at end of file diff --git a/init.lua b/init.lua index 32b4894..03fc451 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,5 @@ --[[ - Minetest Farming Redo Mod 1.20 (20th May 2015) + Minetest Farming Redo Mod 1.20 (5th July 2015) by TenPlus1 NEW growing routine by prestidigitator ]] @@ -8,6 +8,10 @@ farming = {} farming.mod = "redo" farming.path = minetest.get_modpath("farming") farming.hoe_on_use = default.hoe_on_use +farming.select = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5} +} farming.DEBUG = false -- farming.DEBUG = {} -- Uncomment to turn on profiling code/functions @@ -38,7 +42,6 @@ if farming.DEBUG then timer_avg.."µs/run") print("Total farming time: "..dt.."µs") end -else end local statistics = dofile(farming.path.."/statistics.lua") @@ -68,7 +71,7 @@ dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility -- Utility Functions local time_speed = tonumber(minetest.setting_get("time_speed")) or 72 -local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60/time_speed) or nil +local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or nil local function clamp(x, min, max) return (x < min and min) or (x > max and max) or x @@ -214,7 +217,12 @@ local function reg_plant_stages(plant_name, stage, force_last) local ns = reg_plant_stages(plant_name, stage + 1, true) local stages_left = (ns and { ns.name, unpack(ns.stages_left) }) or {} - stages = { plant_name = plant_name, name = node_name, stage = stage, stages_left = stages_left } + stages = { + plant_name = plant_name, + name = node_name, + stage = stage, + stages_left = stages_left + } if #stages_left > 0 then local old_constr = node_def.on_construct @@ -237,7 +245,12 @@ local function reg_plant_stages(plant_name, stage, force_last) }) end elseif force_last then - stages = { plant_name = plant_name, name = node_name, stage = stage, stages_left = {} } + stages = { + plant_name = plant_name, + name = node_name, + stage = stage, + stages_left = {} + } else return nil end @@ -378,7 +391,6 @@ if farming.DEBUG then end end - -- Place Seeds on Soil function farming.place_seed(itemstack, placer, pointed_thing, plantname) @@ -393,7 +405,7 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname) local above = minetest.get_node(pt.above) -- check if pointing at the top of the node - if pt.above.y ~= pt.under.y+1 then + if pt.above.y ~= pt.under.y + 1 then return end @@ -420,7 +432,6 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname) end end - -- Function to register plants (for compatibility) farming.register_plant = function(name, def) @@ -450,7 +461,7 @@ farming.register_plant = function(name, def) paramtype2 = "wallmounted", walkable = false, sunlight_propagates = true, - selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, + selection_box = farming.select, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, mname .. ":"..pname.."_1") end @@ -489,7 +500,7 @@ farming.register_plant = function(name, def) 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},}, + selection_box = farming.select, groups = g, sounds = default.node_sound_leaves_defaults(), }) @@ -503,8 +514,7 @@ end --[[ Cotton (example, is already registered in cotton.lua) farming.register_plant("farming:cotton", { - description = "Cotton seed", + description = "Cotton2 seed", inventory_image = "farming_cotton_seed.png", steps = 8, -}) ---]] +})]] \ No newline at end of file diff --git a/mapgen.lua b/mapgen.lua index 995d07c..b93c2d0 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -9,7 +9,7 @@ local function register_plant(name, min, max, spawnby, num) noise_params = { offset = 0, scale = 0.006, - spread = {x=100, y=100, z=100}, + spread = {x = 100, y = 100, z = 100}, seed = 329, octaves = 3, persist = 0.6 @@ -38,9 +38,8 @@ function farming.register_mgv6_decorations() register_plant("beanbush", 18, 35, "", -1) end --- enable in mapgen v6 only +-- enable in v6 mapgen only -local mg_params = minetest.get_mapgen_params() -if mg_params.mgname == "v6" then +if minetest.get_mapgen_params().mgname == "v6" then farming.register_mgv6_decorations() -end +end \ No newline at end of file diff --git a/melon.lua b/melon.lua index e680456..77b2390 100644 --- a/melon.lua +++ b/melon.lua @@ -33,12 +33,14 @@ minetest.register_node("farming:melon_1", { tiles = {"farming_melon_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -47,12 +49,14 @@ minetest.register_node("farming:melon_2", { tiles = {"farming_melon_2.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -65,8 +69,11 @@ minetest.register_node("farming:melon_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -79,8 +86,11 @@ minetest.register_node("farming:melon_4", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -93,8 +103,11 @@ minetest.register_node("farming:melon_5", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -105,8 +118,11 @@ minetest.register_node("farming:melon_6", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -117,12 +133,15 @@ minetest.register_node("farming:melon_7", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Melon growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:melon_8", { --drawtype = "nodebox", @@ -130,12 +149,11 @@ minetest.register_node("farming:melon_8", { tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"}, paramtype = "light", walkable = true, - is_ground_content = true, drop = { items = { - {items = {'farming:melon_slice 9'},rarity=1}, + {items = {'farming:melon_slice 9'}, rarity = 1}, } }, - groups = {snappy=1,oddly_breakable_by_hand=1,flammable=2,plant=1}, + groups = {snappy = 1, oddly_breakable_by_hand = 1, flammable = 2, plant = 1}, sounds = default.node_sound_wood_defaults(), -}) +}) \ No newline at end of file diff --git a/potato.lua b/potato.lua index 9d4a4a7..fb13d99 100644 --- a/potato.lua +++ b/potato.lua @@ -35,8 +35,11 @@ minetest.register_node("farming:potato_1", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -49,8 +52,11 @@ minetest.register_node("farming:potato_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -62,19 +68,21 @@ minetest.register_node("farming:potato_3", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:potato'},rarity=1}, - {items = {'farming:potato'},rarity=3}, + {items = {'farming:potato'}, rarity = 1}, + {items = {'farming:potato'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Potato growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:potato_4", { drawtype = "plantlike", @@ -84,14 +92,16 @@ minetest.register_node("farming:potato_4", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:potato 2'},rarity=1}, - {items = {'farming:potato 3'},rarity=2}, + {items = {'farming:potato 2'}, rarity = 1}, + {items = {'farming:potato 3'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory=1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/pumpkin.lua b/pumpkin.lua index 5339290..60f0175 100644 --- a/pumpkin.lua +++ b/pumpkin.lua @@ -3,11 +3,18 @@ minetest.register_node("farming:pumpkin", { description = "Pumpkin", - tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png"}, - groups = {choppy=1,oddly_breakable_by_hand=1,flammable=2,plant=1}, + tiles = { + "farming_pumpkin_top.png", + "farming_pumpkin_top.png", + "farming_pumpkin_side.png" + }, + groups = { + choppy = 1, oddly_breakable_by_hand = 1, + flammable = 2, plant = 1 + }, drop = { items = { - {items = {'farming:pumpkin_slice 9'},rarity=1}, + {items = {'farming:pumpkin_slice 9'}, rarity = 1}, } }, sounds = default.node_sound_wood_defaults(), @@ -41,9 +48,16 @@ minetest.register_craft({ -- Jack 'O Lantern minetest.register_node("farming:jackolantern", { description = "Jack 'O Lantern", - tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_off.png"}, + tiles = { + "farming_pumpkin_top.png", + "farming_pumpkin_top.png", + "farming_pumpkin_side.png", + "farming_pumpkin_side.png", + "farming_pumpkin_side.png", + "farming_pumpkin_face_off.png" + }, paramtype2 = "facedir", - groups = {choppy=1,oddly_breakable_by_hand=1,flammable=2}, + groups = {choppy = 1, oddly_breakable_by_hand = 1, flammable = 2}, sounds = default.node_sound_wood_defaults(), on_punch = function(pos, node, puncher) node.name = "farming:jackolantern_on" @@ -53,10 +67,17 @@ minetest.register_node("farming:jackolantern", { minetest.register_node("farming:jackolantern_on", { description = "Jack 'O Lantern", - tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_on.png"}, - light_source = 14, + tiles = { + "farming_pumpkin_top.png", + "farming_pumpkin_top.png", + "farming_pumpkin_side.png", + "farming_pumpkin_side.png", + "farming_pumpkin_side.png", + "farming_pumpkin_face_on.png" + }, + light_source = default.LIGHT_MAX - 1, paramtype2 = "facedir", - groups = {choppy=1,oddly_breakable_by_hand=1,flammable=2}, + groups = {choppy = 1, oddly_breakable_by_hand = 1, flammable = 2}, sounds = default.node_sound_wood_defaults(), drop = "farming:jackolantern", on_punch = function(pos, node, puncher) @@ -110,8 +131,11 @@ minetest.register_node("farming:pumpkin_1", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -124,8 +148,11 @@ minetest.register_node("farming:pumpkin_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory =1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -138,8 +165,11 @@ minetest.register_node("farming:pumpkin_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -152,8 +182,11 @@ minetest.register_node("farming:pumpkin_4", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -166,8 +199,11 @@ minetest.register_node("farming:pumpkin_5", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -179,8 +215,11 @@ minetest.register_node("farming:pumpkin_6", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -191,12 +230,15 @@ minetest.register_node("farming:pumpkin_7", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Pumpkin growth does not have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:pumpkin_8", { drawtype = "plantlike", @@ -204,13 +246,15 @@ minetest.register_node("farming:pumpkin_8", { paramtype = "light", walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:pumpkin_slice 9'},rarity=1}, + {items = {'farming:pumpkin_slice 9'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_defaults(), -}) +}) \ No newline at end of file diff --git a/raspberry.lua b/raspberry.lua index 48eea25..b202f60 100644 --- a/raspberry.lua +++ b/raspberry.lua @@ -34,12 +34,14 @@ minetest.register_node("farming:raspberry_1", { tiles = {"farming_raspberry_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -52,8 +54,11 @@ minetest.register_node("farming:raspberry_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -66,12 +71,15 @@ minetest.register_node("farming:raspberry_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Raspberry growth does not have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:raspberry_4", { drawtype = "plantlike", @@ -81,15 +89,17 @@ minetest.register_node("farming:raspberry_4", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:raspberries 2'},rarity=1}, - {items = {'farming:raspberries'},rarity=2}, - {items = {'farming:raspberries'},rarity=3}, + {items = {'farming:raspberries 2'}, rarity = 1}, + {items = {'farming:raspberries'}, rarity = 2}, + {items = {'farming:raspberries'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/rhubarb.lua b/rhubarb.lua index 37bd401..1f1f404 100644 --- a/rhubarb.lua +++ b/rhubarb.lua @@ -32,12 +32,14 @@ minetest.register_node("farming:rhubarb_1", { tiles = {"farming_rhubarb_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -50,12 +52,15 @@ minetest.register_node("farming:rhubarb_2", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Rhubarb growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:rhubarb_3", { drawtype = "plantlike", @@ -65,15 +70,17 @@ minetest.register_node("farming:rhubarb_3", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:rhubarb 2'},rarity=1}, - {items = {'farming:rhubarb'},rarity=2}, - {items = {'farming:rhubarb'},rarity=3}, + {items = {'farming:rhubarb 2'}, rarity = 1}, + {items = {'farming:rhubarb'}, rarity = 2}, + {items = {'farming:rhubarb'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/soil.lua b/soil.lua index 1c2c57c..b8f3001 100644 --- a/soil.lua +++ b/soil.lua @@ -3,8 +3,7 @@ minetest.register_node("farming:soil", { description = "Soil", tiles = {"farming_soil.png", "default_dirt.png"}, drop = "default:dirt", - is_ground_content = true, - groups = {crumbly=3, not_in_creative_inventory=1, soil=2}, + groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 2}, sounds = default.node_sound_dirt_defaults(), }) @@ -16,8 +15,7 @@ minetest.register_node("farming:soil_wet", { description = "Wet Soil", tiles = {"farming_soil_wet.png", "farming_soil_wet_side.png"}, drop = "default:dirt", - is_ground_content = true, - groups = {crumbly=3, not_in_creative_inventory=1, soil=3}, + groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 3}, sounds = default.node_sound_dirt_defaults(), }) minetest.register_alias("farming:desert_sand_soil_wet", "farming:soil_wet") @@ -29,13 +27,17 @@ minetest.register_abm({ chance = 4, action = function(pos, node) - local nn = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name + pos.y = pos.y + 1 + local nn = minetest.get_node_or_nil(pos) + pos.y = pos.y - 1 + + if nn then nn = nn.name else return end -- what's on top of soil, if solid/not plant change soil to dirt if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].walkable and minetest.get_item_group(nn, "plant") == 0 then - minetest.set_node(pos, {name="default:dirt"}) + minetest.set_node(pos, {name = "default:dirt"}) return end @@ -47,12 +49,12 @@ minetest.register_abm({ -- check if there is water nearby and change soil accordingly if minetest.find_node_near(pos, 3, {"group:water"}) then if node.name == "farming:soil" then - minetest.set_node(pos, {name="farming:soil_wet"}) + minetest.set_node(pos, {name = "farming:soil_wet"}) end elseif node.name == "farming:soil_wet" then - minetest.set_node(pos, {name="farming:soil"}) + minetest.set_node(pos, {name = "farming:soil"}) elseif node.name == "farming:soil" then - minetest.set_node(pos, {name="default:dirt"}) + minetest.set_node(pos, {name = "default:dirt"}) end end, -}) +}) \ No newline at end of file diff --git a/statistics.lua b/statistics.lua index aaa4f51..265ccb3 100644 --- a/statistics.lua +++ b/statistics.lua @@ -16,7 +16,7 @@ erf = function(x) if x == 0 then return 0; end local xSq = x * x local aXSq = A * xSq - local v = math.sqrt(1.0 - math.exp(-xSq * (B + aXSq)/(1.0 + aXSq))) + local v = math.sqrt(1.0 - math.exp(-xSq * (B + aXSq) / (1.0 + aXSq))) return (x > 0 and v) or -v end @@ -147,4 +147,4 @@ statistics.poisson = function(lambda, max) return poisson(lambda, max) end -return statistics +return statistics \ No newline at end of file diff --git a/sugar.lua b/sugar.lua index 15bd9fa..efc92ef 100644 --- a/sugar.lua +++ b/sugar.lua @@ -11,5 +11,4 @@ minetest.register_craft({ cooktime = 3, output = "farming:sugar 2", recipe = "default:papyrus", -}) - +}) \ No newline at end of file diff --git a/tomato.lua b/tomato.lua index 3ec20f7..99c091a 100644 --- a/tomato.lua +++ b/tomato.lua @@ -18,12 +18,14 @@ minetest.register_node("farming:tomato_1", { tiles = {"farming_tomato_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -32,12 +34,14 @@ minetest.register_node("farming:tomato_2", { tiles = {"farming_tomato_2.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -50,8 +54,11 @@ minetest.register_node("farming:tomato_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -64,8 +71,11 @@ minetest.register_node("farming:tomato_4", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -78,8 +88,11 @@ minetest.register_node("farming:tomato_5", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -92,8 +105,11 @@ minetest.register_node("farming:tomato_6", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -104,19 +120,21 @@ minetest.register_node("farming:tomato_7", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:tomato'},rarity=1}, - {items = {'farming:tomato'},rarity=3}, + {items = {'farming:tomato'}, rarity = 1}, + {items = {'farming:tomato'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Carrot growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:tomato_8", { drawtype = "plantlike", @@ -125,14 +143,16 @@ minetest.register_node("farming:tomato_8", { waving = 1, walkable = false, buildable_to = true, - is_ground_content = true, drop = { items = { - {items = {'farming:tomato 3'},rarity=1}, - {items = {'farming:tomato 3'},rarity=2}, + {items = {'farming:tomato 3'}, rarity = 1}, + {items = {'farming:tomato 3'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file diff --git a/wheat.lua b/wheat.lua index 1222cf6..d2bad0d 100644 --- a/wheat.lua +++ b/wheat.lua @@ -22,7 +22,7 @@ minetest.register_node("farming:seed_wheat", { paramtype2 = "wallmounted", walkable = false, sunlight_propagates = true, - selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, + selection_box = farming.select, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:wheat_1") end, @@ -41,7 +41,7 @@ minetest.register_node("farming:straw", { description = "Straw", tiles = {"farming_straw.png"}, is_ground_content = false, - groups = {snappy=3, flammable=4}, + groups = {snappy = 3, flammable = 4}, sounds = default.node_sound_leaves_defaults(), }) @@ -96,12 +96,14 @@ minetest.register_node("farming:wheat_1", { tiles = {"farming_wheat_1.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing=1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -110,12 +112,14 @@ minetest.register_node("farming:wheat_2", { tiles = {"farming_wheat_2.png"}, paramtype = "light", sunlight_propagates = true, - waving = 1, walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -128,8 +132,11 @@ minetest.register_node("farming:wheat_3", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -142,8 +149,11 @@ minetest.register_node("farming:wheat_4", { walkable = false, buildable_to = true, 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,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -157,12 +167,15 @@ minetest.register_node("farming:wheat_5", { buildable_to = true, drop = { items = { - {items = {'farming:wheat'},rarity=2}, - {items = {'farming:seed_wheat'},rarity=2}, + {items = {'farming:wheat'}, rarity = 2}, + {items = {'farming:seed_wheat'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -176,12 +189,15 @@ minetest.register_node("farming:wheat_6", { buildable_to = true, drop = { items = { - {items = {'farming:wheat'},rarity=2}, - {items = {'farming:seed_wheat'},rarity=1}, + {items = {'farming:wheat'}, rarity = 2}, + {items = {'farming:seed_wheat'}, rarity = 1}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) @@ -195,18 +211,21 @@ minetest.register_node("farming:wheat_7", { buildable_to = true, drop = { items = { - {items = {'farming:wheat'},rarity=1}, - {items = {'farming:wheat'},rarity=3}, - {items = {'farming:seed_wheat'},rarity=1}, - {items = {'farming:seed_wheat'},rarity=3}, + {items = {'farming:wheat'}, rarity = 1}, + {items = {'farming:wheat'}, rarity = 3}, + {items = {'farming:seed_wheat'}, rarity = 1}, + {items = {'farming:seed_wheat'}, rarity = 3}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1,growing=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1, growing = 1 + }, sounds = default.node_sound_leaves_defaults(), }) --- Last stage of Wheat growth doesnnot have growing=1 so abm never has to check these +-- Last stage of growth does not have growing group so abm never checks these minetest.register_node("farming:wheat_8", { drawtype = "plantlike", @@ -217,13 +236,16 @@ minetest.register_node("farming:wheat_8", { buildable_to = true, drop = { items = { - {items = {'farming:wheat'},rarity=1}, - {items = {'farming:wheat'},rarity=2}, - {items = {'farming:seed_wheat'},rarity=1}, - {items = {'farming:seed_wheat'},rarity=2}, + {items = {'farming:wheat'}, rarity = 1}, + {items = {'farming:wheat'}, rarity = 2}, + {items = {'farming:seed_wheat'}, rarity = 1}, + {items = {'farming:seed_wheat'}, rarity = 2}, } }, - selection_box = {type = "fixed",fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},}, - groups = {snappy=3,flammable=2,plant=1,not_in_creative_inventory=1,attached_node=1}, + selection_box = farming.select, + groups = { + snappy = 3, flammable = 2, plant = 1, attached_node = 1, + not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), -}) +}) \ No newline at end of file