write something there
This commit is contained in:
commit
b4b6c08f4f
8546 changed files with 309825 additions and 0 deletions
1
mods/tt/.mailmap
Normal file
1
mods/tt/.mailmap
Normal file
|
@ -0,0 +1 @@
|
|||
Wuzzy <Wuzzy@disroot.org> <Wuzzy2@mail.ru>
|
29
mods/tt/API.md
Normal file
29
mods/tt/API.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Tooltip API
|
||||
This API explains how to handle the extended item tooltips (`description` field).
|
||||
|
||||
## Fields
|
||||
|
||||
Add these to the item definition.
|
||||
|
||||
* `_tt_ignore`: If `true`, the `description` of this item won't be altered at all
|
||||
* `_tt_help`: Custom help text
|
||||
|
||||
Once this mod had overwritten the `description` field of an item was overwritten, it will save the original (unaltered) `description` in the `_tt_original_description` field.
|
||||
|
||||
## `tt.register_snippet(func)`
|
||||
|
||||
Register a custom snippet function.
|
||||
`func` is a function of the form `func(itemstring)`.
|
||||
It will be called for (nearly) every itemstring.
|
||||
|
||||
Returns: Two values, the first one is required.
|
||||
1st return value: A string you want to append to this item or `nil` if nothing shall be appended.
|
||||
2nd return value: If nil, `tt` will take of the text color. If a ColorString in `"#RRGGBB"` format, entire text is colorized in this color. Return `false` to force `tt` to not apply text any colorization (useful if you want to call `minetest.colorize` yourself.
|
||||
|
||||
Example:
|
||||
|
||||
tt.register_snippet(function(itemstring)
|
||||
if minetest.get_item_group(itemstring, "magic") == 1 then
|
||||
return "This item is magic"
|
||||
end
|
||||
end)
|
9
mods/tt/LICENSE.txt
Normal file
9
mods/tt/LICENSE.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
Copyright 2024 Wuzzy
|
||||
|
||||
The MIT License
|
||||
|
||||
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.
|
12
mods/tt/README.md
Normal file
12
mods/tt/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Extended Tooltips (`tt`)
|
||||
This mod extends the tooltip of items to add more informative texts.
|
||||
|
||||
The mod itself does nothing and is meant to be integrated into
|
||||
games to use the API to define custom tooltips (see `API.md`).
|
||||
|
||||
## Version
|
||||
1.0.0
|
||||
|
||||
## License
|
||||
This mod is free software, released under the MIT License.
|
||||
See `LICENSE.txt` for the full text.
|
50
mods/tt/init.lua
Normal file
50
mods/tt/init.lua
Normal file
|
@ -0,0 +1,50 @@
|
|||
tt = {}
|
||||
tt.COLOR_DEFAULT = "#d0ffd0"
|
||||
tt.COLOR_DANGER = "#ffff00"
|
||||
tt.COLOR_GOOD = "#00ff00"
|
||||
|
||||
-- API
|
||||
tt.registered_snippets = {}
|
||||
|
||||
tt.register_snippet = function(func)
|
||||
table.insert(tt.registered_snippets, func)
|
||||
end
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/snippets.lua")
|
||||
|
||||
-- Apply item description updates
|
||||
|
||||
local function append_snippets()
|
||||
for itemstring, def in pairs(minetest.registered_items) do
|
||||
if itemstring ~= "" and itemstring ~= "air" and itemstring ~= "ignore" and itemstring ~= "unknown" and def ~= nil and def.description ~= nil and def.description ~= "" and def._tt_ignore ~= true then
|
||||
local desc = def.description
|
||||
local orig_desc = desc
|
||||
local first = true
|
||||
-- Apply snippets
|
||||
for s=1, #tt.registered_snippets do
|
||||
local str, snippet_color = tt.registered_snippets[s](itemstring)
|
||||
if snippet_color == nil then
|
||||
snippet_color = tt.COLOR_DEFAULT
|
||||
elseif snippet_color == false then
|
||||
snippet_color = false
|
||||
end
|
||||
if str then
|
||||
if first then
|
||||
first = false
|
||||
end
|
||||
desc = desc .. "\n"
|
||||
if snippet_color then
|
||||
desc = desc .. minetest.colorize(snippet_color, str)
|
||||
else
|
||||
desc = desc .. str
|
||||
end
|
||||
end
|
||||
end
|
||||
if desc ~= def.description then
|
||||
minetest.override_item(itemstring, { description = desc, _tt_original_description = orig_desc })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_mods_loaded(append_snippets)
|
3
mods/tt/locale/template.txt
Normal file
3
mods/tt/locale/template.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
# textdomain: tt
|
||||
Extended Tooltips=
|
||||
Support for custom tooltip extensions for items=
|
3
mods/tt/locale/tt.de.tr
Normal file
3
mods/tt/locale/tt.de.tr
Normal file
|
@ -0,0 +1,3 @@
|
|||
# textdomain: tt
|
||||
Extended Tooltips=Erweiterte Tooltips
|
||||
Support for custom tooltip extensions for items=Unterstützung für eigene Tooltip-Erweiterungen für Gegenstände
|
3
mods/tt/mod.conf
Normal file
3
mods/tt/mod.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = tt
|
||||
title = Extended Tooltips
|
||||
description = Support for custom tooltip extensions for items
|
11
mods/tt/snippets.lua
Normal file
11
mods/tt/snippets.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
-- CUSTOM SNIPPETS --
|
||||
|
||||
-- Custom text (_tt_help)
|
||||
tt.register_snippet(function(itemstring)
|
||||
local def = minetest.registered_items[itemstring]
|
||||
if def._tt_help then
|
||||
return def._tt_help
|
||||
end
|
||||
end)
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue