Jordan Irwin 2021-04-25 00:11:17 -07:00
parent 16526a5088
commit 494717e02f
13 changed files with 290 additions and 0 deletions

View File

@ -108,6 +108,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.0][ver.equip_exam] *2021-04-25*
* [tools_obsidian][] ([LGPL / CC BY-SA][lic.tools_obsidian]) -- version: [1.0][ver.tools_obsidian] *2021-01-15*
* [workbench][] ([LGPL / WTFPL](mods/tools/workbench/LICENSE)) -- version: [bd14f59 Git][ver.workbench] *2017-08-08*
* transport/
@ -256,6 +257,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[drawers]: https://forum.minetest.net/viewtopic.php?t=17134
[elevator]: https://forum.minetest.net/viewtopic.php?t=12944
[enchanting]: https://forum.minetest.net/viewtopic.php?t=7354
[equip_exam]: https://forum.minetest.net/viewtopic.php?t=26618
[ethereal]: https://forum.minetest.net/viewtopic.php?t=14638
[farlands]: https://forum.minetest.net/viewtopic.php?t=16921
[farming_plus]: https://forum.minetest.net/viewtopic.php?t=2787
@ -366,6 +368,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[lic.drawers]: mods/storage/drawers/LICENSE.txt
[lic.elevator]: mods/buildings/elevator/readme.txt
[lic.enchanting]: mods/enchanting/LICENSE
[lic.equip_exam]: mods/tools/equip_exam/LICENSE.txt
[lic.ethereal]: mods/world/ethereal/license.txt
[lic.farming_plus]: mods/farming/farming_plus/README.txt
[lic.fort_spikes]: mods/buildings/fort_spikes/LICENSE
@ -470,6 +473,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.dinosaurs_aggressive]: https://github.com/AntumMT/mp-dinosaurs_aggressive/tree/874f299
[ver.drawers]: https://github.com/minetest-mods/drawers/releases/tag/v0.6.2
[ver.enchanting]: https://github.com/minetest-mods/enchanting/tree/13ea31c
[ver.equip_exam]: https://github.com/AntumMT/mod-equip_exam/releases/tag/v1.0
[ver.ethereal]: https://notabug.org/TenPlus1/ethereal/src/9d6103d9bb2be7b7ff761c85a6e7285bfe7700a0
[ver.farming_plus]: https://github.com/PilzAdam/farming_plus/tree/7e0d976
[ver.fort_spikes]: https://github.com/xeranas/fort_spikes/tree/3b98b46

View File

@ -0,0 +1,21 @@
MIT License
Copyright © 2021 Jordan Irwin (AntumDeluge)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,65 @@
## Equipment Examiner
### Description:
Tool to examine item stats in [Minetest](https://www.minetest.net/).
![screenshot](screenshot.png)
### Licensing:
- Code: [MIT](LICENSE.txt)
- Textures: [CC0](textures//sources.txt)
### Dependencies:
- Required:
- none
- Optional:
- [default](https://github.com/minetest/minetest_game/tree/master/mods/default) *(required for craft recipe)*
- [basic_materials](https://forum.minetest.net/viewtopic.php?t=21000)
### Crafting:
<details>
<summary>Spoiler:</summary>
Key:
- d:s = default:steel_ingot (wrought iron ingot)
- d:b = default:bronze_ingot (bronze ingot)
- d:o = default:obsidianbrick (obsidian brick)
- b:i = basic_materials:ic (simple integrated circuit)
<blockquote>
Without `basic_materials`:
```
┌─────┬─────┬─────┐
│ d:s │ d:b │ d:s │
├─────┼─────┼─────┤
│ d:b │ d:o │ d:b │
├─────┼─────┼─────┤
│ d:s │ d:b │ d:s │
└─────┴─────┴─────┘
```
With `basic_materials`:
```
┌─────┬─────┬─────┐
│ d:s │ d:b │ d:s │
├─────┼─────┼─────┤
│ d:b │ b:i │ d:b │
├─────┼─────┼─────┤
│ d:s │ d:b │ d:s │
└─────┴─────┴─────┘
```
</blockquote>
</details>
### Links:
- [Minetest forum](https://forum.minetest.net/viewtopic.php?t=26618)
- [GitHub repo](https://github.com/AntumMT/mod-equip_exam)
- [Changelog](CHANGES.txt)
- [TODO](TODO.txt)

View File

@ -0,0 +1,19 @@
if not core.get_modpath("default") then return end -- default mod required for craft recipe
local main_ingredient = "default:obsidianbrick"
local circuit = "basic_materials:ic"
if core.registered_items[circuit] then
main_ingredient = circuit
end
local recipe = {
{"default:steel_ingot", "default:bronze_ingot", "default:steel_ingot",},
{"default:bronze_ingot", main_ingredient, "default:bronze_ingot",},
{"default:steel_ingot", "default:bronze_ingot", "default:steel_ingot",},
}
core.register_craft({
output = "equip_exam:examiner",
recipe = recipe,
})

View File

@ -0,0 +1,100 @@
local S = core.get_translator(equip_exam.name)
local function get_item_specs(item)
if not item then return nil end
local specs = nil
local name = item.short_description
if not name then name = item.description end
local id = item.name
if not name then
specs = S("ID: @1", id)
else
specs = S("Name: @1", name) .. "," .. S("ID: @1", id)
end
local tool_capabilities = item.tool_capabilities
local armor_groups = item.armor_groups
-- is a tool
if tool_capabilities then
if tool_capabilities.damage_groups and tool_capabilities.damage_groups.fleshy then
specs = specs .. "," .. S("Attack: @1", tool_capabilities.damage_groups.fleshy)
end
if tool_capabilities.groupcaps then
local cracky = tool_capabilities.groupcaps.cracky -- mining/pick axe
local choppy = tool_capabilities.groupcaps.choppy -- cutting/axe
local crumbly = tool_capabilities.groupcaps.crumbly -- digging/shovel
local snappy = tool_capabilities.groupcaps.snappy -- ???/sword
if cracky and cracky.maxlevel then
specs = specs .. "," .. S("Mine level: @1", cracky.maxlevel)
end
if choppy and choppy.maxlevel then
specs = specs .. "," .. S("Chop level: @1", choppy.maxlevel)
end
if crumbly and crumbly.maxlevel then
specs = specs .. "," .. S("Dig level: @1", crumbly.maxlevel)
end
if snappy and snappy.maxlevel then
specs = specs .. "," .. S("Snap level: @1", snappy.maxlevel)
end
end
-- is armor
elseif armor_groups and armor_groups.fleshy then
specs = specs .. "," .. S("Defense: @1", armor_groups.fleshy)
end
return specs
end
--- Retrieves formspec string.
--
-- @function equip_exam:get_formspec
-- @param item The item name string.
-- @param empty If *true*, no stats information will be printed.
function equip_exam:get_formspec(item, empty)
local specs
if not empty then
specs = get_item_specs(core.registered_tools[item])
else
specs = "" -- empty
end
if not specs then
specs = S("Specs unavailable")
end
local formspec = "formspec_version[4]"
.. "size[12,9]"
.. "list[context;input;1,1;1,1;0]"
.. "button_exit[0.25,3.1;2.5,0.8;close;" .. S("Close") .. "]"
.. "label[3,0.7;" .. S("Specs:") .. "]"
.. "textlist[3,1;8,3;speclist;" .. specs .. ";1;false]"
.. "list[current_player;main;1.15,4.1;8,4;0]"
return formspec
end
--- Displays the formspec to a player.
--
-- @function equip_exam:show_formspec
-- @param pos The coordinates where the node is located.
-- @param player Player object to whom formspec will be displayed.
function equip_exam:show_formspec(pos, player)
local playername = player:get_player_name()
if not playername or not player:is_player() then return end
local meta = core.get_meta(pos)
local inv = meta:get_inventory()
local contents = inv:get_list("input")[1]
core.show_formspec(playername, equip_exam.name, equip_exam:get_formspec(contents:get_name(), inv:is_empty("input")))
end

View File

@ -0,0 +1,14 @@
equip_exam = {}
equip_exam.name = core.get_current_modname()
equip_exam.path = core.get_modpath(equip_exam.name)
local files = {
"formspec",
"node",
"crafting",
}
for _, f in pairs(files) do
dofile(equip_exam.path .. "/" .. f .. ".lua")
end

View File

@ -0,0 +1,14 @@
## Translated by:
Equipment Examiner=
Specs:=
Specs unavailable=
Close=
Name: @1=
ID: @1=
Attack: @1=
Defense: @1=
Mine level: @1=
Chop level: @1=
Dig level: @1=
Snap level: @1=

View File

@ -0,0 +1,7 @@
title = Equipment Examiner
name = equip_exam
description = A node that will examine the specs of equipment.
author = Jordan Irwin (AntumDeluge)
version = 1.0
license = MIT
optional_depends = basic_materials

View File

@ -0,0 +1,44 @@
local S = core.get_translator(equip_exam.name)
local common_name = S("Equipment Examiner")
local node_def = {
description = common_name,
short_description = common_name,
drawtype = "normal",
tiles = {
"equip_exam_examiner.png",
"equip_exam_examiner.png",
"equip_exam_examiner_front.png",
"equip_exam_examiner.png",
},
groups = {oddly_breakable_by_hand=1,},
is_gound_content = false,
stack_max = 1,
on_construct = function(pos)
local meta = core.get_meta(pos)
meta:set_string("infotext", common_name)
meta:set_string("formspec", equip_exam:get_formspec())
local inv = meta:get_inventory()
inv:set_size("input", 1)
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
equip_exam:show_formspec(pos, player)
end,
can_dig = function(pos, player)
local meta = core.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("input")
end,
-- FIXME: both are called when item is replaced with another
on_metadata_inventory_put = function(pos, listname, index, stack, player)
equip_exam:show_formspec(pos, player)
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
equip_exam:show_formspec(pos, player)
end,
}
core.register_node("equip_exam:examiner", node_def)

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,2 @@
equip_exam_examiner*.png: https://opengameart.org/node/19848 (CC0)