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"}
|
local enchs = {"durable", "fast"}
|
||||||
|
|
||||||
for _, e in pairs(enchs) do
|
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)
|
toolstack:replace("xdecor:enchanted_"..string.sub(toolname, 9).."_"..e)
|
||||||
mesestack:take_item()
|
mesestack:take_item()
|
||||||
inv:set_stack("mese", 1, mesestack)
|
inv:set_stack("mese", 1, mesestack)
|
||||||
@ -55,12 +55,14 @@ local function enchput(pos, listname, index, stack, player)
|
|||||||
end
|
end
|
||||||
if listname == "tool" then
|
if listname == "tool" then
|
||||||
local tdef = minetest.registered_tools[toolname]
|
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, "stone") and not
|
||||||
string.find(toolname, "wood") then
|
string.find(toolname, "wood") then
|
||||||
return 1
|
return 1
|
||||||
else return 0 end
|
else return 0 end
|
||||||
end
|
end
|
||||||
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
xdecor.register("enchantment_table", {
|
xdecor.register("enchantment_table", {
|
||||||
@ -82,9 +84,7 @@ xdecor.register("enchantment_table", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
local tools = {
|
local tools = {
|
||||||
{"axe", "choppy"},
|
{"axe", "choppy"}, {"pick", "cracky"}, {"shovel", "crumbly"}
|
||||||
{"pick", "cracky"},
|
|
||||||
{"shovel", "crumbly"}
|
|
||||||
}
|
}
|
||||||
local materials = {"steel", "bronze", "mese", "diamond"}
|
local materials = {"steel", "bronze", "mese", "diamond"}
|
||||||
|
|
||||||
@ -103,9 +103,9 @@ for _, m in pairs(materials) do
|
|||||||
local maxlvl = registered_tool["maxlevel"]
|
local maxlvl = registered_tool["maxlevel"]
|
||||||
|
|
||||||
local dig_faster, use_longer = {}, {}
|
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
|
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
|
end
|
||||||
|
|
||||||
--- Pickaxes ---
|
--- Pickaxes ---
|
||||||
|
3
hive.lua
3
hive.lua
@ -42,9 +42,6 @@ xdecor.register("hive", {
|
|||||||
puncher:set_hp(health-4)
|
puncher:set_hp(health-4)
|
||||||
end,
|
end,
|
||||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
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
|
if listname == "honey" then return 0 end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end,
|
end,
|
||||||
|
@ -12,20 +12,20 @@ local material = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local def = { -- Node name, yield, nodebox shape.
|
local def = { -- Node name, yield, nodebox shape.
|
||||||
{ "nanoslab", "16", {-0.5, -0.5, -0.5, 0, -0.4375, 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} },
|
{"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} },
|
{"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} },
|
{"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} },
|
{"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} } },
|
{"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} } },
|
{"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} } }
|
{"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 function xconstruct(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local nodebtn = {}
|
|
||||||
|
|
||||||
|
local nodebtn = {}
|
||||||
for i=1, #def do
|
for i=1, #def do
|
||||||
nodebtn[#nodebtn+1] = "item_image_button["..(i-1)..
|
nodebtn[#nodebtn+1] = "item_image_button["..(i-1)..
|
||||||
",0.5;1,1;xdecor:"..def[i][1].."_cloud;"..def[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 inv = meta:get_inventory()
|
||||||
local inputstack = inv:get_stack("input", 1)
|
local inputstack = inv:get_stack("input", 1)
|
||||||
local outputstack = inv:get_stack("output", 1)
|
local outputstack = inv:get_stack("output", 1)
|
||||||
|
local outputcount = outputstack:get_count()
|
||||||
|
local inputname = inputstack:get_name()
|
||||||
local shape, get = {}, {}
|
local shape, get = {}, {}
|
||||||
local anz = 0
|
local anz = 0
|
||||||
|
|
||||||
for _, d in pairs(def) do
|
for _, d in pairs(def) do
|
||||||
local nb, anz = d[1], d[2]
|
local nb, anz = d[1], d[2]
|
||||||
if outputstack:get_count() < 99 and fields[nb] then
|
if outputcount < 99 and fields[nb] then
|
||||||
shape = "xdecor:"..nb.."_"..string.sub(inputstack:get_name(), 9)
|
shape = "xdecor:"..nb.."_"..string.sub(inputname, 9)
|
||||||
get = shape.." "..anz
|
get = shape.." "..anz
|
||||||
|
|
||||||
if not minetest.registered_nodes[shape] then return end
|
if not minetest.registered_nodes[shape] then return end
|
||||||
@ -82,7 +84,7 @@ local function xdig(pos, player)
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
if not inv:is_empty("input") or not inv:is_empty("output") or not
|
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
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -103,14 +105,15 @@ local function xput(pos, listname, index, stack, player)
|
|||||||
if listname == "tool" then
|
if listname == "tool" then
|
||||||
local tdef = minetest.registered_tools[stackname]
|
local tdef = minetest.registered_tools[stackname]
|
||||||
local twear = stack:get_wear()
|
local twear = stack:get_wear()
|
||||||
|
|
||||||
if not (tdef and twear > 0) then return 0 end
|
if not (tdef and twear > 0) then return 0 end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
xdecor.register("worktable", {
|
xdecor.register("worktable", {
|
||||||
description = "Work Table",
|
description = "Work Table",
|
||||||
groups = {cracky=3},
|
groups = {cracky=2},
|
||||||
sounds = xdecor.wood,
|
sounds = xdecor.wood,
|
||||||
tiles = {
|
tiles = {
|
||||||
"xdecor_worktable_top.png", "xdecor_worktable_top.png",
|
"xdecor_worktable_top.png", "xdecor_worktable_top.png",
|
||||||
@ -124,25 +127,25 @@ xdecor.register("worktable", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, m in pairs(material) do
|
for _, m in pairs(material) do
|
||||||
for n=1, #def do
|
for n=1, #def do
|
||||||
local w = def[n]
|
local w = def[n]
|
||||||
local nodename = "default:"..m
|
local nodename = "default:"..m
|
||||||
local ndef = minetest.registered_nodes[nodename]
|
local ndef = minetest.registered_nodes[nodename]
|
||||||
if not ndef then return end
|
if not ndef then return end
|
||||||
|
|
||||||
xdecor.register(w[1].."_"..m, {
|
xdecor.register(w[1].."_"..m, {
|
||||||
description = string.sub(string.upper(w[1]), 0, 1)..string.sub(w[1], 2),
|
description = string.sub(string.upper(w[1]), 0, 1)..string.sub(w[1], 2),
|
||||||
light_source = ndef.light_source,
|
light_source = ndef.light_source,
|
||||||
sounds = ndef.sounds,
|
sounds = ndef.sounds,
|
||||||
tiles = ndef.tiles,
|
tiles = ndef.tiles,
|
||||||
groups = {snappy=3, not_in_creative_inventory=1},
|
groups = {snappy=3, not_in_creative_inventory=1},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = w[3]
|
fixed = w[3]
|
||||||
},
|
},
|
||||||
on_place = minetest.rotate_node
|
on_place = minetest.rotate_node
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
@ -156,13 +159,10 @@ minetest.register_abm({
|
|||||||
local wear = tool:get_wear()
|
local wear = tool:get_wear()
|
||||||
local wear2 = hammer:get_wear()
|
local wear2 = hammer:get_wear()
|
||||||
|
|
||||||
local repair = -500 -- Tool's repairing factor (higher in negative means greater repairing).
|
local repair = -500 -- Tool's repairing factor (0-65535 -- 0 = new condition).
|
||||||
local wearhammer = 250 -- Hammer's wearing factor (higher in positive means greater wearing).
|
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 tool:is_empty() or hammer:is_empty() or wear == 0 then return end
|
||||||
|
|
||||||
if (hammer:is_empty() or hammer:get_name() ~= "xdecor:hammer") then
|
|
||||||
return end
|
|
||||||
|
|
||||||
tool:add_wear(repair)
|
tool:add_wear(repair)
|
||||||
hammer:add_wear(wearhammer)
|
hammer:add_wear(wearhammer)
|
||||||
|
Loading…
Reference in New Issue
Block a user