diff options
author | TenPlus1 <kinsellaja@yahoo.com> | 2015-07-04 12:22:39 +0100 |
---|---|---|
committer | TenPlus1 <kinsellaja@yahoo.com> | 2015-07-04 12:22:39 +0100 |
commit | 023d0303c1c01508039c1de0b79c5b86e21cefb1 (patch) | |
tree | 74f54ea2dba1181cf58a9c4e1876cd1acaca3ad6 /fishing.lua | |
parent | 2bc7406c9a2112eba39e91c304dab74699093c4d (diff) |
Code tidy and fixed fruit not dropping
Diffstat (limited to 'fishing.lua')
-rw-r--r-- | fishing.lua | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/fishing.lua b/fishing.lua index 810d3b2..6be1ce7 100644 --- a/fishing.lua +++ b/fishing.lua @@ -12,6 +12,13 @@ minetest.register_craftitem("ethereal:fish_cooked", { on_use = minetest.item_eat(5), }) +minetest.register_craft({ + type = "cooking", + output = "ethereal:fish_cooked", + recipe = "ethereal:fish_raw", + cooktime = 2, +}) + -- Sashimi (Thanks to Natalia Grosner for letting me use the sashimi image) minetest.register_craftitem("ethereal:sashimi", { description = "Sashimi", @@ -36,38 +43,8 @@ minetest.register_craftitem("ethereal:worm", { minetest.register_craftitem("ethereal:fishing_rod", { description = "Fishing Rod", inventory_image = "fishing_rod.png", --- stack_max = 1, - liquids_pointable = true, }) --- Fishing Rod (Baited) -minetest.register_craftitem("ethereal:fishing_rod_baited", { - description = "Baited Fishing Rod", - inventory_image = "fishing_rod_baited.png", - wield_image = "fishing_rod_wield.png", - stack_max = 1, - liquids_pointable = true, - on_use = function (itemstack, user, pointed_thing) - - if pointed_thing.type ~= "node" then return end - - local node = minetest.get_node(pointed_thing.under) - if (node.name == "default:water_source" - or node.name == "default:river_water_source") - and math.random(1, 100) < 5 then - local inv = user:get_inventory() - if inv:room_for_item("main", {name="ethereal:fish_raw"}) then - inv:add_item("main", {name="ethereal:fish_raw"}) - return {name="ethereal:fishing_rod"} - else - minetest.chat_send_player(user:get_player_name(), "Inventory full, your Fish Got Away!") - end - end - - end, -}) - --- Fishing Rod minetest.register_craft({ output = "ethereal:fishing_rod", recipe = { @@ -85,17 +62,36 @@ minetest.register_craft({ } }) --- Cooking Fish -minetest.register_craft({ - type = "cooking", - output = "ethereal:fish_cooked", - recipe = "ethereal:fish_raw", - cooktime = 2, +-- Fishing Rod (Baited) +minetest.register_craftitem("ethereal:fishing_rod_baited", { + description = "Baited Fishing Rod", + inventory_image = "fishing_rod_baited.png", + wield_image = "fishing_rod_wield.png", + stack_max = 1, + liquids_pointable = true, + on_use = function (itemstack, user, pointed_thing) + + if pointed_thing.type ~= "node" then return end + + local node = minetest.get_node_or_nil(pointed_thing.under) + if node then node = node.name else return end + + if (node == "default:water_source" + or node == "default:river_water_source") + and math.random(1, 100) < 5 then + local inv = user:get_inventory() + if inv:room_for_item("main", {name = "ethereal:fish_raw"}) then + inv:add_item("main", {name = "ethereal:fish_raw"}) + return {name = "ethereal:fishing_rod"} + else + minetest.chat_send_player(user:get_player_name(), "Inventory full, Fish Got Away!") + end + end + end, }) --- Baiting Fishing Rod minetest.register_craft({ type = "shapeless", output = "ethereal:fishing_rod_baited", recipe = {"ethereal:fishing_rod", "ethereal:worm"}, -}) +})
\ No newline at end of file |