generated from your-land/yl_template
Initial commit
This commit is contained in:
commit
db295f4157
22
.luacheckrc
Normal file
22
.luacheckrc
Normal file
@ -0,0 +1,22 @@
|
||||
unused_args = false
|
||||
allow_defined_top = false
|
||||
|
||||
globals = {
|
||||
"yl_template"
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
||||
-- Core
|
||||
"minetest",
|
||||
"core",
|
||||
|
||||
-- Builtin
|
||||
"vector", "ItemStack",
|
||||
"dump", "DIR_DELIM", "VoxelArea", "Settings",
|
||||
|
||||
-- MTG
|
||||
"default", "sfinv", "creative",
|
||||
}
|
121
LICENSE-CC0
Normal file
121
LICENSE-CC0
Normal file
@ -0,0 +1,121 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
CC0 1.0 Universal
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
|
||||
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
|
||||
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
|
||||
HEREUNDER.
|
||||
|
||||
Statement of Purpose
|
||||
|
||||
The laws of most jurisdictions throughout the world automatically confer
|
||||
exclusive Copyright and Related Rights (defined below) upon the creator
|
||||
and subsequent owner(s) (each and all, an "owner") of an original work of
|
||||
authorship and/or a database (each, a "Work").
|
||||
|
||||
Certain owners wish to permanently relinquish those rights to a Work for
|
||||
the purpose of contributing to a commons of creative, cultural and
|
||||
scientific works ("Commons") that the public can reliably and without fear
|
||||
of later claims of infringement build upon, modify, incorporate in other
|
||||
works, reuse and redistribute as freely as possible in any form whatsoever
|
||||
and for any purposes, including without limitation commercial purposes.
|
||||
These owners may contribute to the Commons to promote the ideal of a free
|
||||
culture and the further production of creative, cultural and scientific
|
||||
works, or to gain reputation or greater distribution for their Work in
|
||||
part through the use and efforts of others.
|
||||
|
||||
For these and/or other purposes and motivations, and without any
|
||||
expectation of additional consideration or compensation, the person
|
||||
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
|
||||
is an owner of Copyright and Related Rights in the Work, voluntarily
|
||||
elects to apply CC0 to the Work and publicly distribute the Work under its
|
||||
terms, with knowledge of his or her Copyright and Related Rights in the
|
||||
Work and the meaning and intended legal effect of CC0 on those rights.
|
||||
|
||||
1. Copyright and Related Rights. A Work made available under CC0 may be
|
||||
protected by copyright and related or neighboring rights ("Copyright and
|
||||
Related Rights"). Copyright and Related Rights include, but are not
|
||||
limited to, the following:
|
||||
|
||||
i. the right to reproduce, adapt, distribute, perform, display,
|
||||
communicate, and translate a Work;
|
||||
ii. moral rights retained by the original author(s) and/or performer(s);
|
||||
iii. publicity and privacy rights pertaining to a person's image or
|
||||
likeness depicted in a Work;
|
||||
iv. rights protecting against unfair competition in regards to a Work,
|
||||
subject to the limitations in paragraph 4(a), below;
|
||||
v. rights protecting the extraction, dissemination, use and reuse of data
|
||||
in a Work;
|
||||
vi. database rights (such as those arising under Directive 96/9/EC of the
|
||||
European Parliament and of the Council of 11 March 1996 on the legal
|
||||
protection of databases, and under any national implementation
|
||||
thereof, including any amended or successor version of such
|
||||
directive); and
|
||||
vii. other similar, equivalent or corresponding rights throughout the
|
||||
world based on applicable law or treaty, and any national
|
||||
implementations thereof.
|
||||
|
||||
2. Waiver. To the greatest extent permitted by, but not in contravention
|
||||
of, applicable law, Affirmer hereby overtly, fully, permanently,
|
||||
irrevocably and unconditionally waives, abandons, and surrenders all of
|
||||
Affirmer's Copyright and Related Rights and associated claims and causes
|
||||
of action, whether now known or unknown (including existing as well as
|
||||
future claims and causes of action), in the Work (i) in all territories
|
||||
worldwide, (ii) for the maximum duration provided by applicable law or
|
||||
treaty (including future time extensions), (iii) in any current or future
|
||||
medium and for any number of copies, and (iv) for any purpose whatsoever,
|
||||
including without limitation commercial, advertising or promotional
|
||||
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
|
||||
member of the public at large and to the detriment of Affirmer's heirs and
|
||||
successors, fully intending that such Waiver shall not be subject to
|
||||
revocation, rescission, cancellation, termination, or any other legal or
|
||||
equitable action to disrupt the quiet enjoyment of the Work by the public
|
||||
as contemplated by Affirmer's express Statement of Purpose.
|
||||
|
||||
3. Public License Fallback. Should any part of the Waiver for any reason
|
||||
be judged legally invalid or ineffective under applicable law, then the
|
||||
Waiver shall be preserved to the maximum extent permitted taking into
|
||||
account Affirmer's express Statement of Purpose. In addition, to the
|
||||
extent the Waiver is so judged Affirmer hereby grants to each affected
|
||||
person a royalty-free, non transferable, non sublicensable, non exclusive,
|
||||
irrevocable and unconditional license to exercise Affirmer's Copyright and
|
||||
Related Rights in the Work (i) in all territories worldwide, (ii) for the
|
||||
maximum duration provided by applicable law or treaty (including future
|
||||
time extensions), (iii) in any current or future medium and for any number
|
||||
of copies, and (iv) for any purpose whatsoever, including without
|
||||
limitation commercial, advertising or promotional purposes (the
|
||||
"License"). The License shall be deemed effective as of the date CC0 was
|
||||
applied by Affirmer to the Work. Should any part of the License for any
|
||||
reason be judged legally invalid or ineffective under applicable law, such
|
||||
partial invalidity or ineffectiveness shall not invalidate the remainder
|
||||
of the License, and in such case Affirmer hereby affirms that he or she
|
||||
will not (i) exercise any of his or her remaining Copyright and Related
|
||||
Rights in the Work or (ii) assert any associated claims and causes of
|
||||
action with respect to the Work, in either case contrary to Affirmer's
|
||||
express Statement of Purpose.
|
||||
|
||||
4. Limitations and Disclaimers.
|
||||
|
||||
a. No trademark or patent rights held by Affirmer are waived, abandoned,
|
||||
surrendered, licensed or otherwise affected by this document.
|
||||
b. Affirmer offers the Work as-is and makes no representations or
|
||||
warranties of any kind concerning the Work, express, implied,
|
||||
statutory or otherwise, including without limitation warranties of
|
||||
title, merchantability, fitness for a particular purpose, non
|
||||
infringement, or the absence of latent or other defects, accuracy, or
|
||||
the present or absence of errors, whether or not discoverable, all to
|
||||
the greatest extent permissible under applicable law.
|
||||
c. Affirmer disclaims responsibility for clearing rights of other persons
|
||||
that may apply to the Work or any use thereof, including without
|
||||
limitation any person's Copyright and Related Rights in the Work.
|
||||
Further, Affirmer disclaims responsibility for obtaining any necessary
|
||||
consents, permissions or other rights required for any use of the
|
||||
Work.
|
||||
d. Affirmer understands and acknowledges that Creative Commons is not a
|
||||
party to this document and has no duty or obligation with respect to
|
||||
this CC0 or use of the Work.
|
7
LICENSE-MIT
Normal file
7
LICENSE-MIT
Normal file
@ -0,0 +1,7 @@
|
||||
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
LICENSE.md
Normal file
12
LICENSE.md
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
# License
|
||||
|
||||
Copyright (c) 2024 Developername, Styxcolor
|
||||
|
||||
Code:
|
||||
|
||||
* [MIT](https://gitea.your-land.de/your-land/yl_template/src/LICENSE-MIT) Developername
|
||||
|
||||
Media:
|
||||
|
||||
* screenshot.png [CC0](https://gitea.your-land.de/your-land/yl_template/src/LICENSE-CC0) Styxcolor
|
76
README.md
Normal file
76
README.md
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
# yl_template
|
||||
|
||||
## Purpose
|
||||
|
||||
This mod is not meant to bring functionality by itself, but to serve as a template you can base your mod on. Remove the components you do not want and expand on those you want.
|
||||
|
||||
## Download
|
||||
|
||||
Get it from https://gitea.your-land.de/your-land/yl_template
|
||||
|
||||
## Dependencies
|
||||
|
||||
`Delete the Dependency section if your mod has no dependencies`
|
||||
|
||||
See [mod.conf](mod.conf)
|
||||
|
||||
* [modname_of_dependency](https://gitea.your-land.de/link/to/git/of/dependency)
|
||||
|
||||
## Installation
|
||||
|
||||
1. Copy the "yl_template" folder to your mod directory.
|
||||
2. Make sure the [dependencies](#dependencies) are satisfied, if any.
|
||||
3. Enable the mod in your world.mt file.
|
||||
|
||||
## Configuration
|
||||
|
||||
```
|
||||
yl_template.debug = false
|
||||
```
|
||||
Set to true to enable debug mode
|
||||
|
||||
```
|
||||
yl_template.save_path
|
||||
```
|
||||
Set this to where in the worldfolder you want the JSON files stored.
|
||||
|
||||
## Usage
|
||||
|
||||
This mod targets `[servers|singleplayer|...]`, but should work in `[[servers|singleplayer|...]`, too. It comes with no direct content but exposes functions you can use in your mod.
|
||||
|
||||
### Chatcommands
|
||||
|
||||
|
||||
### Modmakers
|
||||
|
||||
Use the following public functions to `[achieve your goals]`
|
||||
|
||||
## Limitations
|
||||
## Alternatives
|
||||
## 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.
|
||||
|
||||
There is no reason to believe it doesn't work anywhere, but you never know.
|
||||
|
||||
## Allied projects
|
||||
|
||||
If you know a project that uses this mod tell us and we will add it to the list.
|
||||
|
||||
## Uninstall
|
||||
|
||||
Remove it from your mod folder or deactivate it in your world.mt
|
||||
|
||||
Mods that depend on it will cease to work, if the mod is removed without proper replacement.
|
||||
|
||||
## License
|
||||
|
||||
[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)
|
||||
|
||||
* Code MIT Developername
|
||||
* Screenshot CC0 Styxcolor
|
||||
|
||||
## Thank you
|
34
api.lua
Normal file
34
api.lua
Normal file
@ -0,0 +1,34 @@
|
||||
-- Use this file for functions that can be called from other mods
|
||||
-- Make sure the functions are well defended against wrong input and
|
||||
-- document them on the readme, what they do, what types and values
|
||||
-- they expect as parameters and what types and values they return.
|
||||
-- If you ever change those, consider adding backwards compatibility,
|
||||
-- since other mods may rely on them.
|
||||
function yl_template.some_api_call(target, message, color)
|
||||
|
||||
if (type(target) ~= "string") then
|
||||
return false, yl_template.t("error_not_a_string", "target")
|
||||
end
|
||||
if (minetest.get_player_by_name(target) == nil) then
|
||||
return false, yl_template.t("error_player_not_online", target)
|
||||
end
|
||||
|
||||
if (type(message) ~= "string") then
|
||||
return false, yl_template.t("error_not_a_string", "message")
|
||||
end
|
||||
|
||||
-- is_color(color) does not exist, you need to implement it if you want to use it
|
||||
if (is_color(color) == false) then
|
||||
return false, yl_template.t("error_not_a_colorspec", "color")
|
||||
end
|
||||
|
||||
if (minetest.colorize == nil) then
|
||||
return false, yl_template.t("error_function_not_available",
|
||||
"minetest.colorize")
|
||||
end
|
||||
|
||||
local message_with_color = minetest.colorize(color, message)
|
||||
minetest.chat_send_player(target, message_with_color)
|
||||
|
||||
return true, yl_template.t("api_sent_x_to_y", message_with_color, target)
|
||||
end
|
19
chatcommand_admin.lua
Normal file
19
chatcommand_admin.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local chatcommand_cmd = "admin_example"
|
||||
local chatcommand_definition = {
|
||||
params = yl_template.t("chatcommand_admin_parameters"), -- Short parameter description
|
||||
description = yl_template.t("chatcommand_admin_description"), -- Full description
|
||||
privs = {[yl_template.settings.admin_priv] = true}, -- Require the "privs" privilege to run
|
||||
func = function(name, param)
|
||||
local success = true
|
||||
if success then
|
||||
return true, yl_template.t("chatcommand_admin_success_message")
|
||||
else
|
||||
return false, yl_template.t("chatcommand_admin_fail_message")
|
||||
end
|
||||
end
|
||||
-- Called when command is run. Returns boolean success and text output.
|
||||
-- Special case: The help message is shown to the player if `func`
|
||||
-- returns false without a text output.
|
||||
}
|
||||
|
||||
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)
|
19
chatcommand_player.lua
Normal file
19
chatcommand_player.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local chatcommand_cmd = "player_example"
|
||||
local chatcommand_definition = {
|
||||
params = yl_template.t("chatcommand_player_parameters"), -- Short parameter description
|
||||
description = yl_template.t("chatcommand_player_parameters"), -- Full description
|
||||
privs = {privs = true}, -- Require the "privs" privilege to run
|
||||
func = function(name, param)
|
||||
local success = true
|
||||
if success then
|
||||
return true, yl_template.t("chatcommand_player_parameters")
|
||||
else
|
||||
return false, yl_template.t("chatcommand_player_parameters")
|
||||
end
|
||||
end
|
||||
-- Called when command is run. Returns boolean success and text output.
|
||||
-- Special case: The help message is shown to the player if `func`
|
||||
-- returns false without a text output.
|
||||
}
|
||||
|
||||
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)
|
2
chatcommands.lua
Normal file
2
chatcommands.lua
Normal file
@ -0,0 +1,2 @@
|
||||
dofile(yl_template.modpath .. "chatcommand_admin.lua")
|
||||
dofile(yl_template.modpath .. "chatcommand_player.lua")
|
12
config.lua
Normal file
12
config.lua
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
-- Setting a configuration, switch the order in which the settings shall take precedence. First valid one taken.
|
||||
|
||||
yl_template.settings = {}
|
||||
|
||||
yl_template.settings.debug = minetest.settings:get_bool("yl_template.debug", false)
|
||||
|
||||
yl_template.settings.external_value = "mod_default" or minetest.settings:get("yl_template.external_value") or "default"
|
||||
|
||||
yl_template.settings.save_path = "yl_template" or minetest.settings:get("yl_template.save_path") or "default"
|
||||
|
||||
yl_template.settings.admin_priv = "admin_priv" or minetest.settings:get("yl_template.admin_priv") or "server"
|
4
dev/whatdowedo.txt
Normal file
4
dev/whatdowedo.txt
Normal file
@ -0,0 +1,4 @@
|
||||
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.
|
||||
|
13
globalsteps.lua
Normal file
13
globalsteps.lua
Normal file
@ -0,0 +1,13 @@
|
||||
local timer = 0
|
||||
|
||||
local gs = function(dtime)
|
||||
timer = timer + dtime
|
||||
if timer <= yl_template.config.interval then
|
||||
return
|
||||
end
|
||||
timer = 0
|
||||
|
||||
-- do stuff
|
||||
end
|
||||
|
||||
minetest.register_globalstep(gs)
|
7
information.lua
Normal file
7
information.lua
Normal file
@ -0,0 +1,7 @@
|
||||
yl_template.information = {}
|
||||
yl_template.information.version = "0.0.1"
|
||||
yl_template.information.author = "AliasAlreadyTaken"
|
||||
yl_template.information.license = "MIT"
|
||||
yl_template.information.name = "yl_template" -- Name of the mod
|
||||
yl_template.information.source = "https://gitea.your-land.de/your-land/yl_template"
|
||||
yl_template.information.additional = yl_template.t("information_additional")
|
31
init.lua
Normal file
31
init.lua
Normal file
@ -0,0 +1,31 @@
|
||||
-- Version 0.0.1
|
||||
-- Author AliasAlreadyTaken
|
||||
-- License MIT
|
||||
|
||||
-- Changelog
|
||||
|
||||
local mod_start_time = minetest.get_us_time()
|
||||
minetest.log("action", "[MOD] yl_template loading")
|
||||
|
||||
yl_template = {}
|
||||
yl_template.error = {}
|
||||
yl_template.modname = minetest.get_current_modname()
|
||||
yl_template.modstorage = minetest.get_mod_storage()
|
||||
yl_template.modpath = minetest.get_modpath("yl_template") .. DIR_DELIM
|
||||
yl_template.worldpath = minetest.get_worldpath() .. DIR_DELIM
|
||||
|
||||
dofile(yl_template.modpath .. "texts.lua")
|
||||
dofile(yl_template.modpath .. "information.lua")
|
||||
dofile(yl_template.modpath .. "config.lua")
|
||||
dofile(yl_template.modpath .. "setup.lua")
|
||||
dofile(yl_template.modpath .. "privs.lua")
|
||||
dofile(yl_template.modpath .. "internal.lua")
|
||||
dofile(yl_template.modpath .. "api.lua")
|
||||
dofile(yl_template.modpath .. "initialize.lua")
|
||||
dofile(yl_template.modpath .. "distinct_feature.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
|
||||
minetest.log("action", "[MOD] yl_template loaded in [" .. mod_end_time .. "s]")
|
9
initialize.lua
Normal file
9
initialize.lua
Normal file
@ -0,0 +1,9 @@
|
||||
-- Use this file to initialize variables once after server start and check everything is in place
|
||||
|
||||
local function run_each_serverstart()
|
||||
yl_template.data = {}
|
||||
--minetest.on_mods_loaded(0.0, yl_template.on_mods_loaded)
|
||||
--minetest.after(0.0, yl_template.after)
|
||||
end
|
||||
|
||||
run_each_serverstart()
|
54
internal.lua
Normal file
54
internal.lua
Normal file
@ -0,0 +1,54 @@
|
||||
-- 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
|
||||
local function log(text)
|
||||
local logmessage = yl_template.t("log_prefix", yl_template.modname, text)
|
||||
if yl_template.settings.debug then minetest.log("action", logmessage) end
|
||||
return logmessage
|
||||
end
|
||||
|
||||
function yl_template.log(text) return log(text) end
|
||||
|
||||
local function get_savepath()
|
||||
local savepath = yl_template.worldpath .. yl_template.settings.save_path
|
||||
log(yl_template.t("log_prefix", dump(savepath)))
|
||||
return savepath
|
||||
end
|
||||
|
||||
local function get_filepath(filename)
|
||||
local path_to_file = get_savepath() .. DIR_DELIM .. filename .. ".json"
|
||||
log(yl_template.t("get_filepath", dump(filename), dump(path_to_file)))
|
||||
return path_to_file
|
||||
end
|
||||
|
||||
local function save_json(filename, content)
|
||||
if type(filename) ~= "string" or type(content) ~= "table" then
|
||||
return false
|
||||
end
|
||||
local savepath = get_filepath(filename)
|
||||
local savecontent = minetest.write_json(content)
|
||||
return minetest.safe_file_write(savepath, savecontent)
|
||||
end
|
||||
|
||||
local function load_json(path)
|
||||
local file = io.open(path, "r")
|
||||
if not file then
|
||||
return false, yl_template.t("error_cannot_open_file", dump(path))
|
||||
end
|
||||
|
||||
local content = file:read("*all")
|
||||
file:close()
|
||||
|
||||
if not content then
|
||||
return false, yl_template.t("error_cannot_read_file", dump(path))
|
||||
end
|
||||
|
||||
return true, minetest.parse_json(content)
|
||||
end
|
||||
|
||||
-- Public functions wrap the private ones, so they can be exchanged easily
|
||||
|
||||
function yl_template.load(filename, ...) return load_json(filename, ...) end
|
||||
|
||||
function yl_template.save(filename, content, ...)
|
||||
return save_json(filename, content, ...)
|
||||
end
|
6
mod.conf
Normal file
6
mod.conf
Normal file
@ -0,0 +1,6 @@
|
||||
name = yl_template
|
||||
description = A template with best practices
|
||||
depends = default
|
||||
optional_depends = moreblocks
|
||||
author = AliasAlreadyTaken
|
||||
title = Template
|
76
priv_example.lua
Normal file
76
priv_example.lua
Normal file
@ -0,0 +1,76 @@
|
||||
local priv_name = "example"
|
||||
local priv_definition = {
|
||||
description = yl_template.t("privs_example_description"),
|
||||
-- Privilege description
|
||||
|
||||
give_to_singleplayer = false,
|
||||
-- Whether to grant the privilege to singleplayer.
|
||||
|
||||
give_to_admin = true,
|
||||
-- Whether to grant the privilege to the server admin.
|
||||
-- Uses value of 'give_to_singleplayer' by default.
|
||||
|
||||
on_grant = function(name, granter_name)
|
||||
-- logging
|
||||
if (type(granter_name) ~= "string") then
|
||||
local errormessage = yl_template.t("error_name_not_found",
|
||||
dump(granter_name))
|
||||
yl_template.log(errormessage)
|
||||
return false, errormessage
|
||||
end
|
||||
if not name then
|
||||
local errormessage = yl_template.t("error_name_not_found",
|
||||
dump(name))
|
||||
yl_template.log(errormessage)
|
||||
return false, errormessage
|
||||
end
|
||||
if not priv_name then
|
||||
local errormessage = yl_template.t("error_priv_not_found",
|
||||
dump(priv_name))
|
||||
yl_template.log(errormessage)
|
||||
return false, errormessage
|
||||
end
|
||||
local text = yl_template.t("privs_example_grant_logmessage",
|
||||
dump(granter_name), dump(priv_name),
|
||||
dump(name))
|
||||
yl_template.log(text)
|
||||
end,
|
||||
-- Called when given to player 'name' by 'granter_name'.
|
||||
-- 'granter_name' will be nil if the priv was granted by a mod.
|
||||
|
||||
on_revoke = function(name, revoker_name)
|
||||
-- logging
|
||||
if (type(revoker_name) ~= "string") then
|
||||
local errormessage = yl_template.t("error_name_not_found",
|
||||
dump(revoker_name))
|
||||
yl_template.log(errormessage)
|
||||
return false, errormessage
|
||||
end
|
||||
if not name then
|
||||
local errormessage = yl_template.t("error_name_not_found",
|
||||
dump(name))
|
||||
yl_template.log(errormessage)
|
||||
return false, errormessage
|
||||
end
|
||||
if not priv_name then
|
||||
local errormessage = yl_template.t("error_priv_not_found",
|
||||
dump(priv_name))
|
||||
yl_template.log(errormessage)
|
||||
return false, errormessage
|
||||
end
|
||||
local text = yl_template.t("privs_example_revoke_logmessage",
|
||||
dump(revoker_name), dump(priv_name),
|
||||
dump(name))
|
||||
yl_template.log(text)
|
||||
end
|
||||
-- Called when taken from player 'name' by 'revoker_name'.
|
||||
-- 'revoker_name' will be nil if the priv was revoked by a mod.
|
||||
|
||||
-- Note that the above two callbacks will be called twice if a player is
|
||||
-- responsible, once with the player name, and then with a nil player
|
||||
-- name.
|
||||
-- Return true in the above callbacks to stop register_on_priv_grant or
|
||||
-- revoke being called.
|
||||
}
|
||||
|
||||
minetest.register_privilege(priv_name, priv_definition)
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
11
settingtypes.txt
Normal file
11
settingtypes.txt
Normal file
@ -0,0 +1,11 @@
|
||||
[category]
|
||||
|
||||
# Debug
|
||||
# Set this to true to enable debug mode, it will output some more values to log
|
||||
# Optional, default is false
|
||||
yl_template.debug (Debug mode) bool false
|
||||
|
||||
# First line: Name the settings
|
||||
# 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?
|
||||
yl_template.external_value (Description of the setting) string "default_value"
|
19
setup.lua
Normal file
19
setup.lua
Normal file
@ -0,0 +1,19 @@
|
||||
-- Use this file to set up folder and variables once after installation of the mod
|
||||
-- Afterwards you could disable this part of the code or set a variable that tells
|
||||
-- this code not to run again
|
||||
|
||||
local mkdir = minetest.mkdir
|
||||
local save_path = yl_template.settings.save_path
|
||||
|
||||
local function run_once()
|
||||
local path = yl_template.worldpath .. DIR_DELIM .. save_path
|
||||
local file = io.open(path, "r")
|
||||
if not file then
|
||||
mkdir(path)
|
||||
else
|
||||
file:close()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
run_once()
|
47
texts.lua
Normal file
47
texts.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local S = minetest.get_translator(yl_template.modname)
|
||||
|
||||
local texts = {}
|
||||
|
||||
function yl_template.t(key, ...) return S(texts[key], ...) or "" end
|
||||
|
||||
-- Fixed texts
|
||||
|
||||
texts["log_prefix"] = "[MOD] @1 : @2"
|
||||
|
||||
texts["get_savepath"] = "get_savepath : @1"
|
||||
texts["get_filepath"] = "get_filepath : @1"
|
||||
|
||||
-- Translateable texts
|
||||
|
||||
texts["information_additional"] = "Additional information"
|
||||
|
||||
texts["chatcommand_admin_description"] = "Admin Chatcommand description"
|
||||
texts["chatcommand_admin_parameters"] = "<name> <privilege>"
|
||||
texts["chatcommand_admin_success_message"] = "Sucess message"
|
||||
texts["chatcommand_admin_fail_message"] = "Fail message"
|
||||
|
||||
texts["chatcommand_player_description"] = "Player Chatcommand description"
|
||||
texts["chatcommand_player_parameters"] = "<name> <privilege>"
|
||||
texts["chatcommand_player_success_message"] = "Sucess message"
|
||||
texts["chatcommand_player_fail_message"] = "Fail message"
|
||||
|
||||
texts["api_sent_x_to_y"] = "Sent @1 to @2"
|
||||
|
||||
texts["privs_example_description"] = "Can do example task"
|
||||
texts["privs_example_grant_logmessage"] = "User @1 granted priv @2 to user @3"
|
||||
texts["privs_example_revoke_logmessage"] =
|
||||
"User @1 revoked priv @2 from user @3"
|
||||
|
||||
-- Errormessages
|
||||
|
||||
texts["error_not_a_string"] = "@1 not a string"
|
||||
texts["error_player_not_online"] = "@1 not an online player"
|
||||
texts["error_not_a_colorspec"] = "@1 not a ColorSpec"
|
||||
texts["error_not_a_position"] = "@1 not a position"
|
||||
texts["error_function_not_available"] = "@1 not available"
|
||||
|
||||
texts["error_cannot_open_file"] = "Error opening file: @1"
|
||||
texts["error_cannot_read_file"] = "Error reading file: @1"
|
||||
|
||||
texts["error_name_not_found"] = "Name not found: @1"
|
||||
texts["error_priv_not_found"] = "Priv not found: @1"
|
Loading…
Reference in New Issue
Block a user