Bugfix and cleanup on worktable
This commit is contained in:
parent
0709246ea4
commit
584e9a9f68
@ -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 ---
|
||||
|
3
hive.lua
3
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,
|
||||
|
@ -24,8 +24,8 @@ local def = { -- Node name, yield, nodebox shape.
|
||||
|
||||
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",
|
||||
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user