From a9939b8e4bd870021da37dbfc4191ed6545dd176 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 1 Feb 2017 15:56:40 +0100 Subject: [PATCH] Add wear to some fished items --- mods/mcl_fishing/init.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mods/mcl_fishing/init.lua b/mods/mcl_fishing/init.lua index b9336731f..2c9cce436 100644 --- a/mods/mcl_fishing/init.lua +++ b/mods/mcl_fishing/init.lua @@ -11,6 +11,7 @@ minetest.register_tool("mcl_fishing:fishing_rod", { if string.find(node.name, "mcl_core:water") then local itemname local itemcount = 1 + local itemwear = 0 local r = math.random(1, 100) if r <= 85 then -- Fish @@ -30,12 +31,13 @@ minetest.register_tool("mcl_fishing:fishing_rod", { if r <= 10 then itemname = "mcl_core:bowl" elseif r <= 12 then - -- TODO: Damaged itemname = "mcl_fishing:fishing_rod" + itemwear = math.random(6554, 65535) -- 10%-100% damaged elseif r <= 22 then itemname = "mcl_mobitems:leather" elseif r <= 32 then itemname = "3d_armor:boots_leather" + itemwear = math.random(6554, 65535) -- 10%-100% damaged elseif r <= 42 then itemname = "mcl_mobitems:rotten_flesh" elseif r <= 47 then @@ -58,14 +60,16 @@ minetest.register_tool("mcl_fishing:fishing_rod", { -- Treasure r = math.random(1, 6) if r == 1 then - -- TODO: Enchanted and damaged + -- TODO: Enchanted itemname = "mcl_throwing:bow" + itemwear = math.random(49144, 65535) -- 75%-100% damaged elseif r == 2 then -- TODO: Enchanted book itemname = "mcl_core:book" elseif r == 3 then - -- TODO: Enchanted and damaged + -- TODO: Enchanted itemname = "mcl_fishing:fishing_rod" + itemwear = math.random(49144, 65535) -- 75%-100% damaged elseif r == 4 then itemname = "mobs:nametag" elseif r == 5 then @@ -75,8 +79,9 @@ minetest.register_tool("mcl_fishing:fishing_rod", { end end local inv = user:get_inventory() - if inv:room_for_item("main", {name=itemname, count=itemcount, wear=0, metadata=""}) then - inv:add_item("main", {name=itemname, count=itemcount, wear=0, metadata=""}) + local item = {name=itemname, count=itemcount, wear=itemwear, metadata=""} + if inv:room_for_item("main", item) then + inv:add_item("main", item) end if not minetest.setting_get("creative_mode") then itemstack:add_wear(66000/65) -- 65 uses