diff --git a/README.md b/README.md index 97ed9f1c..65910ceb 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m * [more_chests][] ([GPL][lic.gpl2.0]) -- version: [6be8145 Git][ver.more_chests] *2021-04-05* * tools/ * [compassgps][] ([WTFPL][lic.wtfpl] / [CC0][lic.cc0] / [CC BY-SA][lic.ccbysa]) -- version: [567b95f Git][ver.compassgps] *2018-09-24* - * [equip_exam][] ([MIT][lic.equip_exam]) - version: [1.5][ver.equip_exam] *2021-07-04* + * [equip_exam][] ([MIT][lic.equip_exam]) - version: [1.6][ver.equip_exam] *2021-07-19* * [tools_obsidian][] ([LGPL / CC BY-SA][lic.tools_obsidian]) -- version: [1.0][ver.tools_obsidian] *2021-01-15* * [workbench][] ([BSD][lic.workbench]) -- version: [1.0][ver.workbench] *2021-06-10* * transport/ @@ -595,7 +595,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m [ver.drawers]: https://github.com/minetest-mods/drawers/releases/tag/v0.6.2 [ver.dungeon_master]: https://github.com/AntumMT/mod-mob_dungeon_master/tree/00c890f [ver.enchanting]: https://github.com/AntumMT/mod-enchanting/tree/dee7dde -[ver.equip_exam]: https://github.com/AntumMT/mod-equip_exam/releases/tag/v1.5 +[ver.equip_exam]: https://github.com/AntumMT/mod-equip_exam/releases/tag/v1.6 [ver.equip_wear]: https://github.com/AntumMT/mod-equip_wear/releases/tag/v0.1 [ver.ethereal]: https://notabug.org/TenPlus1/ethereal/src/90cdf94ea6c54cd5e3fcc7f77d3b6121f963c379 [ver.farming]: https://notabug.org/TenPlus1/farming/commit/dedc33cc46ec65782a5b8ab573d1fb6bb6915b63 diff --git a/mods/tools/equip_exam/README.md b/mods/tools/equip_exam/README.md index c4b61677..f9f696ce 100644 --- a/mods/tools/equip_exam/README.md +++ b/mods/tools/equip_exam/README.md @@ -11,12 +11,25 @@ A [Minetest](https://www.minetest.net/) mod that adds a node that can be used to - Code: [MIT](LICENSE.txt) - Textures: [CC0](textures//sources.txt) +### Usage: + +Right-click the equipment examiner node & place an item into its inventory slot to populate the specs list. + ### Requirements: +- Minetest minimum version: 5.0 - Depends: none - Optional depends: - [![default](https://img.shields.io/static/v1?label=GitHub&message=default&color=%23375a7f&logo=github)](https://github.com/minetest/minetest_game/tree/master/mods/default) *(required for craft recipe)* - [![basic_materials](https://img.shields.io/static/v1?label=ContentDB&message=basic_materials&color=%23375a7f&logo=minetest)](https://content.minetest.net/packages/VanessaE/basic_materials/) + - [![wielded_light](https://img.shields.io/static/v1?label=ContentDB&message=wielded_light&color=%23375a7f&logo=minetest)](https://content.minetest.net/packages/bell07/wielded_light/) + - [![workbench](https://img.shields.io/static/v1?label=GitHub&message=workbench&color=%23375a7f&logo=minetest)](https://github.com/AntumMT/mod-workbench) + - [![xdecor](https://img.shields.io/static/v1?label=ContentDB&message=xdecor&color=%23375a7f&logo=minetest)](https://content.minetest.net/packages/jp/xdecor/) + - [![3d_armor_light](https://img.shields.io/static/v1?label=ContentDB&message=3d_armor_light&color=%23375a7f&logo=minetest)](https://content.minetest.net/packages/AntumDeluge/3d_armor_light/) + +#### Other Mod Support: + +- [![3d_armor](https://img.shields.io/static/v1?label=ContentDB&message=3d_armor&color=%23375a7f&logo=minetest)](https://content.minetest.net/packages/stu/3d_armor/) ### Crafting: diff --git a/mods/tools/equip_exam/changelog.txt b/mods/tools/equip_exam/changelog.txt index 55e7f14d..ebed055a 100644 --- a/mods/tools/equip_exam/changelog.txt +++ b/mods/tools/equip_exam/changelog.txt @@ -1,4 +1,13 @@ +v1.6 +---- +- added nil check when updating formspec +- updated for API: + - xdecor (Git commit 0dbf92e) + - wielded_light v2021-07-15 +- removed abandoned wlight support +- added 3d_armor_light support + v1.5 ---- - parses meta information diff --git a/mods/tools/equip_exam/formspec.lua b/mods/tools/equip_exam/formspec.lua index 3810dd9f..e79542bb 100644 --- a/mods/tools/equip_exam/formspec.lua +++ b/mods/tools/equip_exam/formspec.lua @@ -2,57 +2,27 @@ local S = core.get_translator(equip_exam.name) --- START: wlight & wielded_light support - -local light_items = {} - -if core.global_exists("wlight") then - local wlight_register_item_old = wlight.register_item - local wlight_register_armor_old = wlight.register_armor - - wlight.register_item = function(iname, radius) - light_items[iname] = {radius=radius} - - return wlight_register_item_old(iname, radius) - end - - wlight.register_armor = function(iname, radius, litem) - light_items[iname] = {radius=radius} - - return wlight_register_armor_old(iname, radius, litem) - end - - -- re-register torch & megatorch - if core.registered_items["default:torch"] then - wlight.register_item("default:torch") - end - - if core.registered_items["wlight:megatorch"] then - wlight.register_item("wlight:megatorch", 10) - end +-- wielded_light support +local function get_light_def(id) end +if core.global_exists("wielded_light") and wielded_light.get_light_def then + get_light_def = wielded_light.get_light_def end -if core.global_exists("wielded_light") then - local wielded_light_register_old = wielded_light.register_item_light - wielded_light.register_item_light = function(iname, light_level) - light_items[iname] = {radius=light_level} - - return wielded_light_register_old(iname, light_level) - end +-- 3d_armor_light support +local function is_lighted_armor(id) end +if core.global_exists("armor_light") and armor_light.is_lighted then + is_lighted_armor = armor_light.is_lighted 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 -elseif core.global_exists("xdecor") and xdecor.workbench_repairable then +elseif core.global_exists("xdecor") and xdecor.is_repairable then workbench_repairable = function(iname) - return xdecor:workbench_repairable(iname) or false + return xdecor:is_repairable(iname) or false end end @@ -77,7 +47,6 @@ local tool_types = { ["not_repaired_by_anvil"] = "anvil repair disabled", ["_airtanks_uses"] = "uses", ["_airtanks_empty"] = "replace empty with", - ["radius"] = "light radius", } for k, v in pairs(tool_node_types) do tool_types[k] = v @@ -378,16 +347,21 @@ local function get_item_specs(item, technical) table.insert(specs_node, format_spec(node_types, "light_source", item.light_source, technical)) end - if light_items[id] then - item_types.tool = true - if not technical then - table.insert(specs_tool, S("emits light: @1", S("yes"))) + local light_level = get_light_def(id) + if light_level and light_level > 0 then + local spec_list, type_list = specs_tool, tool_types + if is_lighted_armor(id) then + item_types.armor = true + spec_list, type_list = specs_armor, armor_types + else + item_types.tool = true end - local radius = light_items[id].radius - if radius then - table.insert(specs_tool, format_spec(tool_types, "light_radius", radius, technical)) + if not technical then + table.insert(spec_list, S("emits light: @1", S("yes"))) end + + table.insert(spec_list, format_spec(type_list, "light level", light_level, technical)) end local colorable = groups.ud_param2_colorable ~= nil diff --git a/mods/tools/equip_exam/locale/template.txt b/mods/tools/equip_exam/locale/template.txt index 0e70cbda..96a0e421 100644 --- a/mods/tools/equip_exam/locale/template.txt +++ b/mods/tools/equip_exam/locale/template.txt @@ -32,7 +32,6 @@ repair disabled: @1= anvil repair disabled: @1= uses: @1= replace empty with: @1= -light radius: @1= # node Node:= @@ -59,7 +58,6 @@ climable: @1= floodable: @1= liquid type: @1= drawtype: @1= -light level: @1= # tool & node mine level: @1= @@ -67,6 +65,7 @@ chop level: @1= dig level: @1= snap level: @1= explosive level: @1= +light level: @1= # weapon Weapon:= diff --git a/mods/tools/equip_exam/mod.conf b/mods/tools/equip_exam/mod.conf index 62089880..28a87aec 100644 --- a/mods/tools/equip_exam/mod.conf +++ b/mods/tools/equip_exam/mod.conf @@ -2,7 +2,7 @@ title = Equipment Examiner name = equip_exam description = A node that can be used to examine equipment & item specs. author = Jordan Irwin (AntumDeluge) -version = 1.5 +version = 1.6 license = MIT min_minetest_version = 5.0 -optional_depends = default, basic_materials, wlight, wielded_light, workbench, xdecor +optional_depends = default, basic_materials, wielded_light, workbench, xdecor, 3d_armor_light diff --git a/mods/tools/equip_exam/node.lua b/mods/tools/equip_exam/node.lua index 5d97a7f3..3c4cf77a 100644 --- a/mods/tools/equip_exam/node.lua +++ b/mods/tools/equip_exam/node.lua @@ -7,9 +7,14 @@ local common_name = S("Equipment Examiner") local function update_formspec(pos) local meta = core.get_meta(pos) local inv = meta:get_inventory() - local contents = inv:get_list("input")[1] - meta:set_string("formspec", equip_exam:get_formspec(contents, + local inv_list = inv:get_list("input") + if not inv_list then + inv:set_size("input", 1) + inv_list = inv:get_list("input") + end + + meta:set_string("formspec", equip_exam:get_formspec(inv_list[1], inv:is_empty("input"), meta)) end @@ -33,8 +38,6 @@ local node_def = { on_construct = function(pos) local meta = core.get_meta(pos) meta:set_string("infotext", common_name) - local inv = meta:get_inventory() - inv:set_size("input", 1) update_formspec(pos) end, on_rightclick = function(pos, node, player, itemstack, pointed_thing)