Add workbench support to check if items are repairable

master
Jordan Irwin 2021-07-04 10:28:27 -07:00
parent de25d4ba1a
commit fbb1cbdee8
5 changed files with 18 additions and 3 deletions

View File

@ -5,6 +5,6 @@ TODO:
- show tooltip when text is longer than list width (or show in separate widget)
- add food attributes
- separate "emits light" values between nodes, tools, & armor
- fix extra backslash ("\") caused by formspec escape when separating item types
- add support mods/items:
- xdecor:workbench
- workbench

View File

@ -5,6 +5,7 @@ v1.5
- supports unifieddyes node coloring
- non-real attributes are hidden in technical view
- displays ID (technical name) of unknown items
- added workbench support to check if items are repairable
v1.4
----

View File

@ -44,6 +44,15 @@ end
-- END: wlight & wielded_light support
-- workbench support
local workbench_repairable
if core.global_exists("workbench") and workbench.repairable then
workbench_repairable = function(iname)
return workbench:repairable(iname) or false
end
end
local general_types = {
["description"] = "Description",
["short_description"] = "Short Description",
@ -171,7 +180,6 @@ local function format_spec(grp, name, value, technical)
nname = name:gsub("_", " "):trim()
end
-- FIXME: name may need formspec_escape as well
return S(nname .. ": @1", value)
end
@ -395,6 +403,11 @@ local function get_item_specs(item, technical)
end
end
if not technical and workbench_repairable then
table.insert(specs_other, format_spec(other_types, "workbench repairable",
workbench_repairable(id), false))
end
if name then
table.insert(specs, S("Name: @1", name))
end

View File

@ -114,3 +114,4 @@ palette index: @1=
durability: @1=
wear: @1=
emits light: @1=
workbench repairable: @1=

View File

@ -5,4 +5,4 @@ author = Jordan Irwin (AntumDeluge)
version = 1.4
license = MIT
min_minetest_version = 5.0
optional_depends = default, basic_materials, wlight, wielded_light
optional_depends = default, basic_materials, wlight, wielded_light, workbench