Basic structure
This commit is contained in:
commit
fecaa30117
|
@ -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
|
||||
|
|
@ -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"
|
|
@ -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.
|
||||
|
|
@ -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]")
|
|
@ -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
|
|
@ -0,0 +1,7 @@
|
|||
name = yl_template
|
||||
description = A template with best practices
|
||||
depends = default
|
||||
optional_depends = moreblocks
|
||||
author = AliasAlreadyTaken
|
||||
release = 202106161537
|
||||
title = Template
|
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Loading…
Reference in New Issue