From 584e9a9f686dd2da8a06238485457b56fdf2cf92 Mon Sep 17 00:00:00 2001 From: jp Date: Mon, 3 Aug 2015 00:36:32 +0200 Subject: [PATCH] Bugfix and cleanup on worktable --- enchanting.lua | 14 +++++----- hive.lua | 3 -- worktable.lua | 76 +++++++++++++++++++++++++------------------------- 3 files changed, 45 insertions(+), 48 deletions(-) diff --git a/enchanting.lua b/enchanting.lua index f018935..9b4d2fa 100644 --- a/enchanting.lua +++ b/enchanting.lua @@ -26,7 +26,7 @@ local function enchfields(pos, formname, fields, sender) local enchs = {"durable", "fast"} for _, e in pairs(enchs) do - if string.find(toolname, "default:") and mese > 0 and fields[e] then + if mese > 0 and fields[e] then toolstack:replace("xdecor:enchanted_"..string.sub(toolname, 9).."_"..e) mesestack:take_item() inv:set_stack("mese", 1, mesestack) @@ -55,12 +55,14 @@ local function enchput(pos, listname, index, stack, player) end if listname == "tool" then local tdef = minetest.registered_tools[toolname] - if tdef and not string.find(toolname, "sword") and not + if tdef and string.find(toolname, "default:") and not + string.find(toolname, "sword") and not string.find(toolname, "stone") and not string.find(toolname, "wood") then return 1 else return 0 end end + return count end xdecor.register("enchantment_table", { @@ -82,9 +84,7 @@ xdecor.register("enchantment_table", { }) local tools = { - {"axe", "choppy"}, - {"pick", "cracky"}, - {"shovel", "crumbly"} + {"axe", "choppy"}, {"pick", "cracky"}, {"shovel", "crumbly"} } local materials = {"steel", "bronze", "mese", "diamond"} @@ -103,9 +103,9 @@ for _, m in pairs(materials) do local maxlvl = registered_tool["maxlevel"] local dig_faster, use_longer = {}, {} - use_longer = registered_tool["uses"] * 1.1 -- Wearing factor for enchanted tools (higher in positive means longer use). + use_longer = registered_tool["uses"] * 1.1 -- Wearing factor for enchanted tools (higher number = longer use). for i = 1, 3 do - dig_faster[i] = registered_tool["times"][i] - 0.1 -- Digging factor for enchanted tools (higher in negative means faster dig). + dig_faster[i] = registered_tool["times"][i] - 0.1 -- Digging factor for enchanted tools (lower number = faster dig). end --- Pickaxes --- diff --git a/hive.lua b/hive.lua index 562d962..26ad37f 100644 --- a/hive.lua +++ b/hive.lua @@ -42,9 +42,6 @@ xdecor.register("hive", { puncher:set_hp(health-4) end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - if listname == "honey" then return 0 end return stack:get_count() end, diff --git a/worktable.lua b/worktable.lua index 2583d96..53e99f4 100644 --- a/worktable.lua +++ b/worktable.lua @@ -12,20 +12,20 @@ local material = { } local def = { -- Node name, yield, nodebox shape. - { "nanoslab", "16", {-0.5, -0.5, -0.5, 0, -0.4375, 0} }, - { "micropanel", "16", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0} }, - { "microslab", "8", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5} }, - { "panel", "4", {-0.5, -0.5, -0.5, 0.5, 0, 0} }, - { "slab", "2", {-0.5, -0.5, -0.5, 0.5, 0, 0.5} }, - { "outerstair", "1", { {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0, 0.5, 0.5} } }, - { "stair", "1", { {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5} } }, - { "innerstair", "1", { {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5}, {-0.5, 0, -0.5, 0, 0.5, 0} } } + {"nanoslab", "16", {-0.5, -0.5, -0.5, 0, -0.4375, 0}}, + {"micropanel", "16", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0}}, + {"microslab", "8", {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}}, + {"panel", "4", {-0.5, -0.5, -0.5, 0.5, 0, 0}}, + {"slab", "2", {-0.5, -0.5, -0.5, 0.5, 0, 0.5}}, + {"outerstair", "1", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0, 0.5, 0.5}}}, + {"stair", "1", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5}}}, + {"innerstair", "1", {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0, 0.5, 0.5, 0.5}, {-0.5, 0, -0.5, 0, 0.5, 0}}} } local function xconstruct(pos) local meta = minetest.get_meta(pos) - local nodebtn = {} + local nodebtn = {} for i=1, #def do nodebtn[#nodebtn+1] = "item_image_button["..(i-1).. ",0.5;1,1;xdecor:"..def[i][1].."_cloud;"..def[i][1]..";]" @@ -60,13 +60,15 @@ local function xfields(pos, formname, fields, sender) local inv = meta:get_inventory() local inputstack = inv:get_stack("input", 1) local outputstack = inv:get_stack("output", 1) + local outputcount = outputstack:get_count() + local inputname = inputstack:get_name() local shape, get = {}, {} local anz = 0 for _, d in pairs(def) do local nb, anz = d[1], d[2] - if outputstack:get_count() < 99 and fields[nb] then - shape = "xdecor:"..nb.."_"..string.sub(inputstack:get_name(), 9) + if outputcount < 99 and fields[nb] then + shape = "xdecor:"..nb.."_"..string.sub(inputname, 9) get = shape.." "..anz if not minetest.registered_nodes[shape] then return end @@ -82,7 +84,7 @@ local function xdig(pos, player) local inv = meta:get_inventory() if not inv:is_empty("input") or not inv:is_empty("output") or not - inv:is_empty("fuel") or not inv:is_empty("src") then + inv:is_empty("hammer") or not inv:is_empty("tool") then return false end return true @@ -103,14 +105,15 @@ local function xput(pos, listname, index, stack, player) if listname == "tool" then local tdef = minetest.registered_tools[stackname] local twear = stack:get_wear() - if not (tdef and twear > 0) then return 0 end end + + return count end xdecor.register("worktable", { description = "Work Table", - groups = {cracky=3}, + groups = {cracky=2}, sounds = xdecor.wood, tiles = { "xdecor_worktable_top.png", "xdecor_worktable_top.png", @@ -124,25 +127,25 @@ xdecor.register("worktable", { }) for _, m in pairs(material) do - for n=1, #def do - local w = def[n] - local nodename = "default:"..m - local ndef = minetest.registered_nodes[nodename] - if not ndef then return end +for n=1, #def do + local w = def[n] + local nodename = "default:"..m + local ndef = minetest.registered_nodes[nodename] + if not ndef then return end - xdecor.register(w[1].."_"..m, { - description = string.sub(string.upper(w[1]), 0, 1)..string.sub(w[1], 2), - light_source = ndef.light_source, - sounds = ndef.sounds, - tiles = ndef.tiles, - groups = {snappy=3, not_in_creative_inventory=1}, - node_box = { - type = "fixed", - fixed = w[3] - }, - on_place = minetest.rotate_node - }) - end + xdecor.register(w[1].."_"..m, { + description = string.sub(string.upper(w[1]), 0, 1)..string.sub(w[1], 2), + light_source = ndef.light_source, + sounds = ndef.sounds, + tiles = ndef.tiles, + groups = {snappy=3, not_in_creative_inventory=1}, + node_box = { + type = "fixed", + fixed = w[3] + }, + on_place = minetest.rotate_node + }) +end end minetest.register_abm({ @@ -156,13 +159,10 @@ minetest.register_abm({ local wear = tool:get_wear() local wear2 = hammer:get_wear() - local repair = -500 -- Tool's repairing factor (higher in negative means greater repairing). - local wearhammer = 250 -- Hammer's wearing factor (higher in positive means greater wearing). + local repair = -500 -- Tool's repairing factor (0-65535 -- 0 = new condition). + local wearhammer = 250 -- Hammer's wearing factor (0-65535 -- 0 = new condition). - if (tool:is_empty() or wear == 0 or wear == 65535) then return end - - if (hammer:is_empty() or hammer:get_name() ~= "xdecor:hammer") then - return end + if tool:is_empty() or hammer:is_empty() or wear == 0 then return end tool:add_wear(repair) hammer:add_wear(wearhammer)