From 023d0303c1c01508039c1de0b79c5b86e21cefb1 Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Sat, 4 Jul 2015 12:22:39 +0100 Subject: Code tidy and fixed fruit not dropping --- onion.lua | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'onion.lua') diff --git a/onion.lua b/onion.lua index 745c818..7ea606a 100644 --- a/onion.lua +++ b/onion.lua @@ -8,7 +8,6 @@ minetest.register_craftitem("ethereal:wild_onion_plant", { return farming.place_seed(itemstack, placer, pointed_thing, "ethereal:wild_onion_1") end }) -minetest.register_alias("ethereal:wild_onion_craftingitem", "ethereal:wild_onion_plant") -- Define Onion growth stages local onion_def = { @@ -20,11 +19,17 @@ local onion_def = { buildable_to = true, drop = { items = { - {items = {"ethereal:wild_onion_plant"},rarity=1}, + {items = {"ethereal:wild_onion_plant"}, 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,attached_node=1,onion=1,growing=1,not_in_creative_inventory=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, attached_node = 1, + onion = 1, growing = 1, not_in_creative_inventory = 1 + }, sounds = default.node_sound_leaves_defaults(), } minetest.register_node("ethereal:onion_1", table.copy(onion_def)) @@ -36,14 +41,14 @@ minetest.register_node("ethereal:onion_2", table.copy(onion_def)) onion_def.tiles[1] = "ethereal_wild_onion_3.png" onion_def.groups.onion = 3 onion_def.drop.items[2] = { - items = {"ethereal:wild_onion_plant 2"}, rarity=3 + items = {"ethereal:wild_onion_plant 2"}, rarity = 3 } minetest.register_node("ethereal:onion_3", table.copy(onion_def)) onion_def.tiles[1] = "ethereal_wild_onion_4.png" onion_def.groups.onion = 4 onion_def.drop.items[2] = { - items = {"ethereal:wild_onion_plant 3"}, rarity=3 + items = {"ethereal:wild_onion_plant 3"}, rarity = 3 } minetest.register_node("ethereal:onion_4", table.copy(onion_def)) @@ -51,8 +56,8 @@ onion_def.tiles[1] = "ethereal_wild_onion_5.png" onion_def.groups.onion = 5 onion_def.groups.growing = nil onion_def.drop.items = { - {items = {"ethereal:wild_onion_plant 2"},rarity=1}, - {items = {"ethereal:wild_onion_plant 3"},rarity=2}, + {items = {"ethereal:wild_onion_plant 2"}, rarity = 1}, + {items = {"ethereal:wild_onion_plant 3"}, rarity = 2}, } minetest.register_node("ethereal:onion_5", table.copy(onion_def)) @@ -72,11 +77,11 @@ minetest.register_abm({ end -- check if on wet soil - pos.y = pos.y-1 + pos.y = pos.y - 1 if minetest.get_item_group(minetest.get_node(pos).name, "soil") < 3 then return end - pos.y = pos.y+1 + pos.y = pos.y + 1 -- check light local light = minetest.get_node_light(pos) @@ -86,7 +91,7 @@ minetest.register_abm({ end -- grow - node.name = "ethereal:onion_" .. minetest.get_item_group(node.name, "onion") + 1 + node.name = "ethereal:onion_"..minetest.get_item_group(node.name, "onion") + 1 minetest.set_node(pos, node) end }) @@ -97,7 +102,8 @@ end -- Legacy minetest.register_alias("ethereal:wild_onion_craftingitem", "ethereal:wild_onion_plant") -for i = 1,5 do + +for i = 1, 5 do minetest.register_alias("ethereal:wild_onion_"..i, "ethereal:onion_"..i) end @@ -105,4 +111,4 @@ end minetest.register_alias("ethereal:onion_7", "ethereal:onion_4") minetest.register_alias("ethereal:onion_8", "ethereal:onion_5") minetest.register_alias("ethereal:wild_onion_7", "ethereal:onion_4") -minetest.register_alias("ethereal:wild_onion_8", "ethereal:onion_5") +minetest.register_alias("ethereal:wild_onion_8", "ethereal:onion_5") \ No newline at end of file -- cgit v1.2.3