commit fecaa301171595207e3fa121604d82a45306239d Author: AliasAlreadyTaken Date: Wed Jun 16 17:51:26 2021 +0200 Basic structure diff --git a/README.md b/README.md new file mode 100644 index 0000000..282e624 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ + +# 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. + +## Download + +Get it from https://gitea.your-land.de/your-land/yl_template + +## Installation + +Being a template, you shouldn't install the mod itself. Your mod could look like this: + + + +## Usage +## Uninstall +## License + diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..067d9be --- /dev/null +++ b/config.lua @@ -0,0 +1,4 @@ + +-- Setting a configuration, switch the order in which the settings shall take precedence. First valid one taken. + +yl_template.external_value = "mod_default" or minetest.settings:get_string("external_value") or "default" \ No newline at end of file diff --git a/dev/whatdowedo.txt b/dev/whatdowedo.txt new file mode 100644 index 0000000..5ca6f6f --- /dev/null +++ b/dev/whatdowedo.txt @@ -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. + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..97f2f81 --- /dev/null +++ b/init.lua @@ -0,0 +1,24 @@ +-- Version 0.0.1 +-- Author AliasAlreadyTaken +-- License MIT + +-- Changelog + +local mod_start_time = core.get_us_time() +core.log("action", "[MOD] yl_template loading") + +yl_template = {} +yl_template.error = {} +yl_template.modstorage = core.get_mod_storage() +yl_template.modpath = core.get_modpath("yl_template") .. DIR_DELIM +yl_template.worldpath = core.get_worldpath() .. DIR_DELIM + +dofile(yl_template.modpath .. "config.lua") +dofile(yl_template.modpath .. "internal.lua") +dofile(yl_template.modpath .. "api.lua") +dofile(yl_template.modpath .. "distinct_feature.lua") +dofile(yl_template.modpath .. "overwrite_feature.lua") +dofile(yl_template.modpath .. "globalsteps.lua") + +local mod_end_time = (core.get_us_time() - mod_start_time) / 1000000 +core.log("action", "[MOD] yl_template loaded in [" .. mod_end_time .. "s]") diff --git a/internal.lua b/internal.lua new file mode 100644 index 0000000..effde31 --- /dev/null +++ b/internal.lua @@ -0,0 +1,53 @@ + +-- 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 debug = true + +local function say(text) + if yl_template.debug then + core.log("action", "[MOD] yl_template : " .. text) + end +end + +local function save_path(file) + return yl_template.worldpath .. file .. ".json" +end + +local function save_json(filename, content) + if type(filename) ~= "string" or type(content) ~= "table" then + return false + end + local savepath = save_path(filename) + local savecontent = minetest.write_json(content) + return minetest.safe_file_write(savepath, savecontent) +end + + +local function load_json(filename) -- returns the saved dialog + local savepath = save_path(filename) + + local file, err = io.open(savepath, "r") + if err then + return {} + end + io.input(file) + local savecontent = io.read() + local content = minetest.parse_json(savecontent) + io.close(file) + + if type(content) ~= "table" then + content = {} + end + + return 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.load(filename, content, ...) + return load_json(filename, content, ...) +end \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..58188ed --- /dev/null +++ b/mod.conf @@ -0,0 +1,7 @@ +name = yl_template +description = A template with best practices +depends = default +optional_depends = moreblocks +author = AliasAlreadyTaken +release = 202106161537 +title = Template \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..fedca9a Binary files /dev/null and b/screenshot.png differ