Renames template to actual modname

This commit is contained in:
AliasAlreadyTaken 2024-06-09 11:11:43 +02:00
parent d52d182cfe
commit 425ca87db2
19 changed files with 104 additions and 103 deletions

View File

@ -9,4 +9,4 @@ Code:
Media: Media:
* screenshot.png [CC0](https://gitea.your-land.de/your-land/yl_template/src/LICENSE-CC0) Styxcolor * screenshot.png [CC0](https://gitea.your-land.de/your-land/yl_skinsdb_addon/src/LICENSE-CC0) Styxcolor

View File

@ -1,5 +1,5 @@
# yl_template # yl_skinsdb_addon
## Purpose ## Purpose
@ -7,22 +7,22 @@ This mod is not meant to bring functionality by itself, but to serve as a templa
## Download ## Download
Get it from https://gitea.your-land.de/your-land/yl_template Get it from https://gitea.your-land.de/your-land/yl_skinsdb_addon
## Installation ## Installation
1. Copy the "yl_template" folder to your mod directory. 1. Copy the "yl_skinsdb_addon" folder to your mod directory.
2. Enable the mod in your world.mt file. 2. Enable the mod in your world.mt file.
## Configuration ## Configuration
``` ```
yl_template.debug = false yl_skinsdb_addon.debug = false
``` ```
Set to true to enable debug mode Set to true to enable debug mode
``` ```
yl_template.save_path yl_skinsdb_addon.save_path
``` ```
Set this to where in the worldfolder you want the JSON files stored. Set this to where in the worldfolder you want the JSON files stored.
@ -41,7 +41,7 @@ Use the following public functions to `[achieve your goals]`
## Alternatives ## Alternatives
## Supported versions ## Supported versions
If you use yl_template, but something is wrong, please [file a bug](https://gitea.your-land.de/your-land/yl_template/issues/new). PRs also welcome. If you use yl_skinsdb_addon, but something is wrong, please [file a bug](https://gitea.your-land.de/your-land/yl_skinsdb_addon/issues/new). PRs also welcome.
There is no reason to believe it doesn't work anywhere, but you never know. There is no reason to believe it doesn't work anywhere, but you never know.
@ -59,7 +59,7 @@ Mods that depend on it will cease to work, if the mod is removed without proper
[Shorthand of your chosen license: MIT, LGPLv3+, GPLv3+, AGPL, ...]. Please choose one of the major license that is compatible with as much of the MT universe over some obscure and incompatible license. If you use the screenshot.png, keep Styxcolor in there because she made that screenshot.png, if you add your own, replace the line with whoever made it. Example for MIT and CC0: [Shorthand of your chosen license: MIT, LGPLv3+, GPLv3+, AGPL, ...]. Please choose one of the major license that is compatible with as much of the MT universe over some obscure and incompatible license. If you use the screenshot.png, keep Styxcolor in there because she made that screenshot.png, if you add your own, replace the line with whoever made it. Example for MIT and CC0:
See [LICENSE.md](https://gitea.your-land.de/your-land/yl_template/src/LICENSE.md) See [LICENSE.md](https://gitea.your-land.de/your-land/yl_skinsdb_addon/src/LICENSE.md)
* Code MIT Developername * Code MIT Developername
* Screenshot CC0 Styxcolor * Screenshot CC0 Styxcolor

14
api.lua
View File

@ -4,31 +4,31 @@
-- they expect as parameters and what types and values they return. -- they expect as parameters and what types and values they return.
-- If you ever change those, consider adding backwards compatibility, -- If you ever change those, consider adding backwards compatibility,
-- since other mods may rely on them. -- since other mods may rely on them.
function yl_template.some_api_call(target, message, color) function yl_skinsdb_addon.some_api_call(target, message, color)
if (type(target) ~= "string") then if (type(target) ~= "string") then
return false, yl_template.t("error_not_a_string", "target") return false, yl_skinsdb_addon.t("error_not_a_string", "target")
end end
if (minetest.get_player_by_name(target) == nil) then if (minetest.get_player_by_name(target) == nil) then
return false, yl_template.t("error_player_not_online", target) return false, yl_skinsdb_addon.t("error_player_not_online", target)
end end
if (type(message) ~= "string") then if (type(message) ~= "string") then
return false, yl_template.t("error_not_a_string", "message") return false, yl_skinsdb_addon.t("error_not_a_string", "message")
end end
-- is_color(color) does not exist, you need to implement it if you want to use it -- is_color(color) does not exist, you need to implement it if you want to use it
if (is_color(color) == false) then if (is_color(color) == false) then
return false, yl_template.t("error_not_a_colorspec", "color") return false, yl_skinsdb_addon.t("error_not_a_colorspec", "color")
end end
if (minetest.colorize == nil) then if (minetest.colorize == nil) then
return false, yl_template.t("error_function_not_available", return false, yl_skinsdb_addon.t("error_function_not_available",
"minetest.colorize") "minetest.colorize")
end end
local message_with_color = minetest.colorize(color, message) local message_with_color = minetest.colorize(color, message)
minetest.chat_send_player(target, message_with_color) minetest.chat_send_player(target, message_with_color)
return true, yl_template.t("api_sent_x_to_y", message_with_color, target) return true, yl_skinsdb_addon.t("api_sent_x_to_y", message_with_color, target)
end end

View File

@ -1,14 +1,14 @@
local chatcommand_cmd = "admin_example" local chatcommand_cmd = "admin_example"
local chatcommand_definition = { local chatcommand_definition = {
params = yl_template.t("chatcommand_admin_parameters"), -- Short parameter description params = yl_skinsdb_addon.t("chatcommand_admin_parameters"), -- Short parameter description
description = yl_template.t("chatcommand_admin_description"), -- Full description description = yl_skinsdb_addon.t("chatcommand_admin_description"), -- Full description
privs = {[yl_template.settings.admin_priv] = true}, -- Require the "privs" privilege to run privs = {[yl_skinsdb_addon.settings.admin_priv] = true}, -- Require the "privs" privilege to run
func = function(name, param) func = function(name, param)
local success = true local success = true
if success then if success then
return true, yl_template.t("chatcommand_admin_success_message") return true, yl_skinsdb_addon.t("chatcommand_admin_success_message")
else else
return false, yl_template.t("chatcommand_admin_fail_message") return false, yl_skinsdb_addon.t("chatcommand_admin_fail_message")
end end
end end
-- Called when command is run. Returns boolean success and text output. -- Called when command is run. Returns boolean success and text output.

View File

@ -1,14 +1,14 @@
local chatcommand_cmd = "player_example" local chatcommand_cmd = "player_example"
local chatcommand_definition = { local chatcommand_definition = {
params = yl_template.t("chatcommand_player_parameters"), -- Short parameter description params = yl_skinsdb_addon.t("chatcommand_player_parameters"), -- Short parameter description
description = yl_template.t("chatcommand_player_parameters"), -- Full description description = yl_skinsdb_addon.t("chatcommand_player_parameters"), -- Full description
privs = {privs = true}, -- Require the "privs" privilege to run privs = {privs = true}, -- Require the "privs" privilege to run
func = function(name, param) func = function(name, param)
local success = true local success = true
if success then if success then
return true, yl_template.t("chatcommand_player_parameters") return true, yl_skinsdb_addon.t("chatcommand_player_parameters")
else else
return false, yl_template.t("chatcommand_player_parameters") return false, yl_skinsdb_addon.t("chatcommand_player_parameters")
end end
end end
-- Called when command is run. Returns boolean success and text output. -- Called when command is run. Returns boolean success and text output.

View File

@ -1,2 +1,2 @@
dofile(yl_template.modpath .. "chatcommand_admin.lua") dofile(yl_skinsdb_addon.modpath .. "chatcommand_admin.lua")
dofile(yl_template.modpath .. "chatcommand_player.lua") dofile(yl_skinsdb_addon.modpath .. "chatcommand_player.lua")

View File

@ -1,10 +1,8 @@
-- Setting a configuration, switch the order in which the settings shall take precedence. First valid one taken. -- Setting a configuration, switch the order in which the settings shall take precedence. First valid one taken.
yl_template.settings = {} yl_skinsdb_addon.settings = {}
yl_template.settings.external_value = "mod_default" or minetest.settings:get("yl_template.external_value") or "default" yl_skinsdb_addon.settings.save_path = minetest.settings:get("yl_skinsdb_addon.save_path") or "worldmods/yl_skins_folder/textures"
yl_template.settings.save_path = "yl_template" or minetest.settings:get("yl_template.save_path") or "default" yl_skinsdb_addon.settings.admin_privs = minetest.settings:get("yl_skinsdb_addon.admin_privs") or "server"
yl_template.settings.admin_priv = "admin_priv" or minetest.settings:get("yl_template.admin_priv") or "server"

View File

@ -1,4 +1,11 @@
This file holds a couple of editors notes regarding the mod.
Todo's can be noted here, known issues, the path to ressources or general annotations. This is a skinsDB addon, in a stub, to not infect the rest of our code with GPL.
The only functionality this mod is intended to add is a way to retrofit skins into a running server.
We need
- a process to clone, push to and update this mod on the server
- a second mod that holds all the textures
- a chatcommand that reads the files of a directory, compares them to a list we have ingame and then adds new skins to a table, which is then processed by
- a function that actually imports those skins and makes them available to players

View File

@ -2,7 +2,7 @@ local timer = 0
local gs = function(dtime) local gs = function(dtime)
timer = timer + dtime timer = timer + dtime
if timer <= yl_template.config.interval then if timer <= yl_skinsdb_addon.config.interval then
return return
end end
timer = 0 timer = 0

View File

@ -1,7 +1,7 @@
yl_template.information = {} yl_skinsdb_addon.information = {}
yl_template.information.version = "0.0.1" yl_skinsdb_addon.information.version = "0.0.1"
yl_template.information.author = "AliasAlreadyTaken" yl_skinsdb_addon.information.author = "AliasAlreadyTaken"
yl_template.information.license = "MIT" yl_skinsdb_addon.information.license = "MIT"
yl_template.information.name = "yl_template" -- Name of the mod yl_skinsdb_addon.information.name = "yl_skinsdb_addon"
yl_template.information.source = "https://gitea.your-land.de/your-land/yl_template" yl_skinsdb_addon.information.source = "https://gitea.your-land.de/your-land/yl_skinsdb_addon"
yl_template.information.additional = yl_template.t("information_additional") yl_skinsdb_addon.information.additional = yl_skinsdb_addon.t("information_additional")

View File

@ -5,27 +5,24 @@
-- Changelog -- Changelog
local mod_start_time = minetest.get_us_time() local mod_start_time = minetest.get_us_time()
minetest.log("action", "[MOD] yl_template loading") minetest.log("action", "[MOD] yl_skinsdb_addon loading")
yl_template = {} yl_skinsdb_addon = {}
yl_template.error = {} yl_skinsdb_addon.error = {}
yl_template.modname = minetest.get_current_modname() yl_skinsdb_addon.modname = minetest.get_current_modname()
yl_template.modstorage = minetest.get_mod_storage() yl_skinsdb_addon.modstorage = minetest.get_mod_storage()
yl_template.modpath = minetest.get_modpath("yl_template") .. DIR_DELIM yl_skinsdb_addon.modpath = minetest.get_modpath("yl_skinsdb_addon") .. DIR_DELIM
yl_template.worldpath = minetest.get_worldpath() .. DIR_DELIM yl_skinsdb_addon.worldpath = minetest.get_worldpath() .. DIR_DELIM
dofile(yl_template.modpath .. "texts.lua") dofile(yl_skinsdb_addon.modpath .. "texts.lua")
dofile(yl_template.modpath .. "information.lua") dofile(yl_skinsdb_addon.modpath .. "information.lua")
dofile(yl_template.modpath .. "config.lua") dofile(yl_skinsdb_addon.modpath .. "config.lua")
dofile(yl_template.modpath .. "setup.lua") dofile(yl_skinsdb_addon.modpath .. "setup.lua")
dofile(yl_template.modpath .. "privs.lua") dofile(yl_skinsdb_addon.modpath .. "privs.lua")
dofile(yl_template.modpath .. "internal.lua") dofile(yl_skinsdb_addon.modpath .. "internal.lua")
dofile(yl_template.modpath .. "api.lua") --dofile(yl_skinsdb_addon.modpath .. "api.lua")
dofile(yl_template.modpath .. "initialize.lua") dofile(yl_skinsdb_addon.modpath .. "initialize.lua")
dofile(yl_template.modpath .. "distinct_feature.lua") dofile(yl_skinsdb_addon.modpath .. "chatcommands.lua")
dofile(yl_template.modpath .. "overwrite_feature.lua")
dofile(yl_template.modpath .. "globalsteps.lua")
dofile(yl_template.modpath .. "chatcommands.lua")
local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000 local mod_end_time = (minetest.get_us_time() - mod_start_time) / 1000000
minetest.log("action", "[MOD] yl_template loaded in [" .. mod_end_time .. "s]") minetest.log("action", "[MOD] yl_skinsdb_addon loaded in [" .. mod_end_time .. "s]")

View File

@ -1,9 +1,9 @@
-- Use this file to initialize variables once after server start and check everything is in place -- Use this file to initialize variables once after server start and check everything is in place
local function run_each_serverstart() local function run_each_serverstart()
yl_template.data = {} yl_skinsdb_addon.data = {}
--minetest.on_mods_loaded(0.0, yl_template.on_mods_loaded) --minetest.on_mods_loaded(0.0, yl_skinsdb_addon.on_mods_loaded)
--minetest.after(0.0, yl_template.after) --minetest.after(0.0, yl_skinsdb_addon.after)
end end
run_each_serverstart() run_each_serverstart()

View File

@ -1,22 +1,22 @@
-- The functions and variables in this file are only for use in the mod itself. -- The functions and variables in this file are only for use in the mod itself.
-- Those that do real work should be local and wrapped in public functions -- Those that do real work should be local and wrapped in public functions
local function log(text) local function log(text)
local logmessage = yl_template.t("log_prefix", yl_template.modname, text) local logmessage = yl_skinsdb_addon.t("log_prefix", yl_skinsdb_addon.modname, text)
if yl_template.settings.debug then minetest.log("action", logmessage) end if yl_skinsdb_addon.settings.debug then minetest.log("action", logmessage) end
return logmessage return logmessage
end end
function yl_template.log(text) return log(text) end function yl_skinsdb_addon.log(text) return log(text) end
local function get_savepath() local function get_savepath()
local savepath = yl_template.worldpath .. yl_template.settings.save_path local savepath = yl_skinsdb_addon.worldpath .. yl_skinsdb_addon.settings.save_path
log(yl_template.t("log_prefix", dump(savepath))) log(yl_skinsdb_addon.t("log_prefix", dump(savepath)))
return savepath return savepath
end end
local function get_filepath(filename) local function get_filepath(filename)
local path_to_file = get_savepath() .. DIR_DELIM .. filename .. ".json" local path_to_file = get_savepath() .. DIR_DELIM .. filename .. ".json"
log(yl_template.t("get_filepath", dump(filename), dump(path_to_file))) log(yl_skinsdb_addon.t("get_filepath", dump(filename), dump(path_to_file)))
return path_to_file return path_to_file
end end
@ -32,14 +32,14 @@ end
local function load_json(path) local function load_json(path)
local file = io.open(path, "r") local file = io.open(path, "r")
if not file then if not file then
return false, yl_template.t("error_cannot_open_file", dump(path)) return false, yl_skinsdb_addon.t("error_cannot_open_file", dump(path))
end end
local content = file:read("*all") local content = file:read("*all")
file:close() file:close()
if not content then if not content then
return false, yl_template.t("error_cannot_read_file", dump(path)) return false, yl_skinsdb_addon.t("error_cannot_read_file", dump(path))
end end
return true, minetest.parse_json(content) return true, minetest.parse_json(content)
@ -47,8 +47,8 @@ end
-- Public functions wrap the private ones, so they can be exchanged easily -- Public functions wrap the private ones, so they can be exchanged easily
function yl_template.load(filename, ...) return load_json(filename, ...) end function yl_skinsdb_addon.load(filename, ...) return load_json(filename, ...) end
function yl_template.save(filename, content, ...) function yl_skinsdb_addon.save(filename, content, ...)
return save_json(filename, content, ...) return save_json(filename, content, ...)
end end

View File

@ -1,6 +1,5 @@
name = yl_template name = yl_skinsdb_addon
description = A template with best practices description = An addon to skinsdb to retrofit skins
depends = default depends = skins_db, yl_skins_folder
optional_depends = moreblocks
author = AliasAlreadyTaken author = AliasAlreadyTaken
title = Template title = YL Skins Addon

View File

@ -1,6 +1,6 @@
local priv_name = "example" local priv_name = "example"
local priv_definition = { local priv_definition = {
description = yl_template.t("privs_example_description"), description = yl_skinsdb_addon.t("privs_example_description"),
-- Privilege description -- Privilege description
give_to_singleplayer = false, give_to_singleplayer = false,
@ -13,27 +13,27 @@ local priv_definition = {
on_grant = function(name, granter_name) on_grant = function(name, granter_name)
-- logging -- logging
if (type(granter_name) ~= "string") then if (type(granter_name) ~= "string") then
local errormessage = yl_template.t("error_name_not_found", local errormessage = yl_skinsdb_addon.t("error_name_not_found",
dump(granter_name)) dump(granter_name))
yl_template.log(errormessage) yl_skinsdb_addon.log(errormessage)
return false, errormessage return false, errormessage
end end
if not name then if not name then
local errormessage = yl_template.t("error_name_not_found", local errormessage = yl_skinsdb_addon.t("error_name_not_found",
dump(name)) dump(name))
yl_template.log(errormessage) yl_skinsdb_addon.log(errormessage)
return false, errormessage return false, errormessage
end end
if not priv_name then if not priv_name then
local errormessage = yl_template.t("error_priv_not_found", local errormessage = yl_skinsdb_addon.t("error_priv_not_found",
dump(priv_name)) dump(priv_name))
yl_template.log(errormessage) yl_skinsdb_addon.log(errormessage)
return false, errormessage return false, errormessage
end end
local text = yl_template.t("privs_example_grant_logmessage", local text = yl_skinsdb_addon.t("privs_example_grant_logmessage",
dump(granter_name), dump(priv_name), dump(granter_name), dump(priv_name),
dump(name)) dump(name))
yl_template.log(text) yl_skinsdb_addon.log(text)
end, end,
-- Called when given to player 'name' by 'granter_name'. -- Called when given to player 'name' by 'granter_name'.
-- 'granter_name' will be nil if the priv was granted by a mod. -- 'granter_name' will be nil if the priv was granted by a mod.
@ -41,27 +41,27 @@ local priv_definition = {
on_revoke = function(name, revoker_name) on_revoke = function(name, revoker_name)
-- logging -- logging
if (type(revoker_name) ~= "string") then if (type(revoker_name) ~= "string") then
local errormessage = yl_template.t("error_name_not_found", local errormessage = yl_skinsdb_addon.t("error_name_not_found",
dump(revoker_name)) dump(revoker_name))
yl_template.log(errormessage) yl_skinsdb_addon.log(errormessage)
return false, errormessage return false, errormessage
end end
if not name then if not name then
local errormessage = yl_template.t("error_name_not_found", local errormessage = yl_skinsdb_addon.t("error_name_not_found",
dump(name)) dump(name))
yl_template.log(errormessage) yl_skinsdb_addon.log(errormessage)
return false, errormessage return false, errormessage
end end
if not priv_name then if not priv_name then
local errormessage = yl_template.t("error_priv_not_found", local errormessage = yl_skinsdb_addon.t("error_priv_not_found",
dump(priv_name)) dump(priv_name))
yl_template.log(errormessage) yl_skinsdb_addon.log(errormessage)
return false, errormessage return false, errormessage
end end
local text = yl_template.t("privs_example_revoke_logmessage", local text = yl_skinsdb_addon.t("privs_example_revoke_logmessage",
dump(revoker_name), dump(priv_name), dump(revoker_name), dump(priv_name),
dump(name)) dump(name))
yl_template.log(text) yl_skinsdb_addon.log(text)
end end
-- Called when taken from player 'name' by 'revoker_name'. -- Called when taken from player 'name' by 'revoker_name'.
-- 'revoker_name' will be nil if the priv was revoked by a mod. -- 'revoker_name' will be nil if the priv was revoked by a mod.

View File

@ -1 +1 @@
dofile(yl_template.modpath .. "priv_example.lua") dofile(yl_skinsdb_addon.modpath .. "priv_example.lua")

View File

@ -3,4 +3,4 @@
# First line: Name the settings # First line: Name the settings
# Second line: Say what it does, how to use it, what it changes # Second line: Say what it does, how to use it, what it changes
# Third line: Is it optional? What's the default value? Does it expect a certain set of values? # Third line: Is it optional? What's the default value? Does it expect a certain set of values?
yl_template.external_value (Description of the setting) string "default_value" yl_skinsdb_addon.external_value (Description of the setting) string "default_value"

View File

@ -3,10 +3,10 @@
-- this code not to run again -- this code not to run again
local mkdir = minetest.mkdir local mkdir = minetest.mkdir
local save_path = yl_template.settings.save_path local save_path = yl_skinsdb_addon.settings.save_path
local function run_once() local function run_once()
local path = yl_template.worldpath .. DIR_DELIM .. save_path local path = yl_skinsdb_addon.worldpath .. DIR_DELIM .. save_path
local file = io.open(path, "r") local file = io.open(path, "r")
if not file then if not file then
mkdir(path) mkdir(path)

View File

@ -1,8 +1,8 @@
local S = minetest.get_translator(yl_template.modname) local S = minetest.get_translator(yl_skinsdb_addon.modname)
local texts = {} local texts = {}
function yl_template.t(key, ...) return S(texts[key], ...) or "" end function yl_skinsdb_addon.t(key, ...) return S(texts[key], ...) or "" end
-- Fixed texts -- Fixed texts
@ -13,7 +13,7 @@ texts["get_filepath"] = "get_filepath : @1"
-- Translateable texts -- Translateable texts
texts["information_additional"] = "Additional information" texts["information_additional"] = "An addon to skinsdb to retrofit skins"
texts["chatcommand_admin_description"] = "Admin Chatcommand description" texts["chatcommand_admin_description"] = "Admin Chatcommand description"
texts["chatcommand_admin_parameters"] = "<name> <privilege>" texts["chatcommand_admin_parameters"] = "<name> <privilege>"