Initial commit

master
Jordan Irwin 2021-04-23 16:57:12 -07:00 committed by GitHub
commit dc8ffc7eda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 132 additions and 0 deletions

21
LICENSE.txt Normal file
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.

11
README.md Normal file
View File

@ -0,0 +1,11 @@
## Equipment Examiner
### Description:
Tool to examine item stats in Minetest.
WARNING: this mod is in development & not ready for live use
### Licensing:
- [MIT](LICENSE.txt)

64
formspec.lua Normal file
View File

@ -0,0 +1,64 @@
local S = core.get_translator("equip_exam")
equip_exam.formspec_name = "equipExam"
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
if item.tool_capabilities.damage_groups then
for k, v in pairs(item.tool_capabilities.damage_groups) do
if not specs or specs == "" then
specs = k .. ": " .. v
else
specs = specs .. "," .. S("Damge to @1 type:", k) .. " " .. v
end
end
end
return specs
end
local function get_formspec(item)
local specs
if item 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]"
--.. "box[1,1;1,1;#555555]"
--.. "list[context;input;1,1;1,1;]"
.. "list[context;input;1,1;1,1;0]"
.. "button_exit[0.25,3.1;2.5,0.8;close;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
function equip_exam:show_formspec(player)
local playername = player:get_player_name()
if not playername or not player:is_player() then return end
core.show_formspec(playername, equip_exam.formspec_name, get_formspec())
end

13
init.lua Normal file
View File

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

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = equip_exam
description = Equipment examiner.
version = 0.1
license = MIT

19
node.lua Normal file
View File

@ -0,0 +1,19 @@
local node_def = {
drawtype = "normal",
tiles = {
"equip_exam_examiner_front.png",
"equip_exam_examiner.png",
},
is_gound_content = false,
stack_max = 1,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
equip_exam:show_formspec(player)
end,
on_construct = function(pos)
local inv = core.get_meta(pos):get_inventory()
inv:set_size('input', 1)
end,
}
core.register_node("equip_exam:examiner", node_def)