Compare commits
4 Commits
f6d0f0b2a5
...
dcde4d7c05
Author | SHA1 | Date |
---|---|---|
mckaygerhard | dcde4d7c05 | |
mckaygerhard | cd0c35b8c5 | |
mckaygerhard | 3e0ca1304d | |
mckaygerhard | 9f4002b749 |
35
init.lua
35
init.lua
|
@ -2,32 +2,33 @@
|
|||
|
||||
xdecor = {}
|
||||
local modpath = minetest.get_modpath("xdecor")
|
||||
local ar_api = minetest.get_modpath("3d_armor")
|
||||
|
||||
-- Intllib
|
||||
local S
|
||||
if minetest.get_translator ~= nil then
|
||||
S = minetest.get_translator("xdecor") -- 5.x translation function
|
||||
S = minetest.get_translator("xdecor") -- 5.x translation function
|
||||
else
|
||||
if minetest.get_modpath("intllib") then
|
||||
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
||||
if intllib.make_gettext_pair then
|
||||
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
|
||||
else
|
||||
gettext = intllib.Getter() -- old text file method
|
||||
if minetest.get_modpath("intllib") then
|
||||
dofile(minetest.get_modpath("intllib") .. "/init.lua")
|
||||
if intllib.make_gettext_pair then
|
||||
gettext, ngettext = intllib.make_gettext_pair() -- new gettext method
|
||||
else
|
||||
gettext = intllib.Getter() -- old text file method
|
||||
end
|
||||
S = gettext
|
||||
else -- boilerplate function
|
||||
S = function(str, ...)
|
||||
local args = {...}
|
||||
return str:gsub("@%d+", function(match)
|
||||
return args[tonumber(match:sub(2))]
|
||||
end)
|
||||
end
|
||||
end
|
||||
S = gettext
|
||||
else -- boilerplate function
|
||||
S = function(str, ...)
|
||||
local args = {...}
|
||||
return str:gsub("@%d+", function(match)
|
||||
return args[tonumber(match:sub(2))]
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
xdecor.S = S
|
||||
xdecor.reparaible_tools = {"pick", "axe", "shovel", "sword"}
|
||||
xdecor.reparaible_tools = {"pick", "axe", "shovel", "hoe"}
|
||||
|
||||
dofile(modpath .. "/handlers/animations.lua")
|
||||
dofile(modpath .. "/handlers/helpers.lua")
|
||||
|
|
|
@ -108,20 +108,29 @@ function enchanting.fields(pos, _, fields, sender)
|
|||
local tool = inv:get_stack("tool", 1)
|
||||
local mese = inv:get_stack("mese", 1)
|
||||
local orig_wear = tool:get_wear()
|
||||
local mod, name = tool:get_name():match("(.*):(.*)")
|
||||
local enchanted_tool = (mod or "") .. ":enchanted_" .. (name or "") .. "_" .. next(fields)
|
||||
if tool and tool:get_name() and allowed_tools[tool:get_name()] then
|
||||
local mod, name = tool:get_name():match("(.*):(.*)")
|
||||
local enchanted_tool = (mod or "") .. ":enchanted_" .. (name or "") .. "_" .. next(fields)
|
||||
|
||||
if mese:get_count() >= mese_cost and reg_tools[enchanted_tool] then
|
||||
minetest.sound_play("xdecor_enchanting", {
|
||||
to_player = sender:get_player_name(),
|
||||
gain = 0.8
|
||||
})
|
||||
-- Mynetest: check that the "mese" list actually contains mese.
|
||||
if mese:get_name() ~= "default:mese_crystal" then
|
||||
inv:set_stack("mese", 1, nil)
|
||||
return
|
||||
end
|
||||
|
||||
tool:replace(enchanted_tool)
|
||||
tool:add_wear(orig_wear)
|
||||
mese:take_item(mese_cost)
|
||||
inv:set_stack("mese", 1, mese)
|
||||
inv:set_stack("tool", 1, tool)
|
||||
if mese:get_count() >= mese_cost and reg_tools[enchanted_tool] then
|
||||
minetest.sound_play("xdecor_enchanting", {
|
||||
to_player = sender:get_player_name(),
|
||||
gain = 0.8
|
||||
})
|
||||
|
||||
tool:replace(enchanted_tool)
|
||||
tool:add_wear(orig_wear)
|
||||
mese:take_item(mese_cost)
|
||||
inv:set_stack("mese", 1, mese)
|
||||
inv:set_stack("tool", 1, tool)
|
||||
end
|
||||
enchanting.formspec(pos)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -46,6 +46,18 @@ end
|
|||
function workbench:repairable(stack)
|
||||
if custom_repairable[stack] then return true end
|
||||
|
||||
if ar_api then
|
||||
for _, t in ipairs({
|
||||
"armor_head",
|
||||
"armor_torso",
|
||||
"armor_legs",
|
||||
"armor_feet",
|
||||
"armor_shield",
|
||||
}) do
|
||||
if minetest.get_item_group(stack, t) then return true end
|
||||
end
|
||||
end
|
||||
|
||||
for _, t in ipairs(repairable_tools) do
|
||||
if stack:find(t) then
|
||||
return true
|
||||
|
@ -122,6 +134,9 @@ local formspecs = {
|
|||
}
|
||||
|
||||
function workbench:set_formspec(meta, id)
|
||||
if not formspecs[id] then
|
||||
return
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
"size[8,7;]list[current_player;main;0,3.25;8,4;]" ..
|
||||
formspecs[id] .. xbg .. default.get_hotbar_bg(0,3.25))
|
||||
|
@ -145,6 +160,16 @@ function workbench.fields(pos, _, fields)
|
|||
if fields.quit then return end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields.back and meta then
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty("input") then
|
||||
inv:set_list("forms", {})
|
||||
else
|
||||
local input = inv:get_stack("input", 1)
|
||||
workbench:get_output(inv, input, input:get_name())
|
||||
end
|
||||
end
|
||||
|
||||
local id = fields.back and 1 or fields.craft and 2 or fields.storage and 3
|
||||
if not id then return end
|
||||
|
||||
|
@ -163,6 +188,13 @@ function workbench.timer(pos)
|
|||
local tool = inv:get_stack("tool", 1)
|
||||
local hammer = inv:get_stack("hammer", 1)
|
||||
|
||||
-- Mynetest: check that the item is a hammer. See https://github.com/Mynetest/Mynetest-server/issues/105
|
||||
if hammer:get_name() ~= "xdecor:hammer" then
|
||||
timer:stop()
|
||||
inv:set_stack("hammer", 1, nil)
|
||||
return
|
||||
end
|
||||
|
||||
if tool:is_empty() or hammer:is_empty() or tool:get_wear() == 0 then
|
||||
timer:stop()
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue