From aaa408bcf586713aa067e85cca4b158ec9feb9dc Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Fri, 28 May 2021 00:24:10 -0700 Subject: [PATCH] Rename to "wdata" --- README.md | 12 ++++++------ api.lua | 26 +++++++++++++------------- docs/api.html | 28 ++++++++++++++-------------- docs/config.ld | 4 ++-- init.lua | 12 ++++++------ mod.conf | 6 +++--- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 77d4fd4..9ce6f59 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -## World Config mod for Minetest +## World Data Manager library for Minetest ### Description: A [Minetest][] library for managing data files in the world directory. -It takes a little work to read from & write to data in the world directory. wconfig aims to make that easier by utilizing just two simple methods. +It takes a little work to read from & write to data in the world directory. `wdata` aims to make that easier by utilizing just two simple methods. ### Licensing: @@ -15,10 +15,10 @@ It takes a little work to read from & write to data in the world directory. wcon There are two methods: ``` -- wconfig.read(fname) +- wdata.read(fname) - reads json data from file in world directory & converts to a table. - fname: File basename without suffix (e.g. "my_config" or "my_mod/my_config"). -- wconfig.write(fname, data[, styled]) +- wdata.write(fname, data[, styled]) - converts table to json data & writes to file in world directory. - fname: File basename without suffix (e.g. "my_config" or "my_mod/my_config"). - data: Table containing data to be exported. @@ -35,8 +35,8 @@ Optional depends: none ### Links - [Forum](https://forum.minetest.net/viewtopic.php?t=26804) -- [Git repo](https://github.com/AntumMT/mod-wconfig) -- [API](https://antummt.github.io/mod-wconfig/docs/api.html) +- [Git repo](https://github.com/AntumMT/mod-wdata) +- [API](https://antummt.github.io/mod-wdata/docs/api.html) - [Changelog](changelog.txt) - [TODO](TODO.txt) diff --git a/api.lua b/api.lua index 6c718d9..414f11f 100644 --- a/api.lua +++ b/api.lua @@ -1,5 +1,5 @@ ---- wconfig API +--- World Data Manager API -- -- @module api.lua @@ -29,16 +29,16 @@ end --- Reads config file from world directory. -- --- @function wconfig.read +-- @function wdata.read -- @tparam string fname Base filename with optional directory structure (e.g. "my_mod/my_config") -- @treturn table Table with contents read from json file or `nil`. -function wconfig.read(fname) +function wdata.read(fname) local fpath = world_path .. "/" .. fname .. ".json" -- check if file exists local fopen = io.open(fpath, "r") if not fopen then - wconfig.log("error", "file not found: " .. fpath) + wdata.log("error", "file not found: " .. fpath) return end @@ -46,7 +46,7 @@ function wconfig.read(fname) io.close(fopen) if not table_data then - wconfig.log("error", "cannot read json data from file: " .. fpath) + wdata.log("error", "cannot read json data from file: " .. fpath) return end @@ -56,17 +56,17 @@ end --- Writes to config file in world directory. -- --- @function wconfig.write +-- @function wdata.write -- @tparam string fname Base filename with optional directory structure (e.g. "my_mod/my_config"). -- @tparam table data Table data to be written to config file. -- @tparam[opt] bool styled Outputs in a human-readable format if this is set (default: `true`). -- @treturn bool `true` if succeeded, `false` if not. -function wconfig.write(fname, data, styled) +function wdata.write(fname, data, styled) styled = styled ~= false local json_data = core.write_json(data, styled) if not json_data then - wconfig.log("error", "cannot convert data to json format") + wdata.log("error", "cannot convert data to json format") return false end @@ -76,7 +76,7 @@ function wconfig.write(fname, data, styled) local dirname = get_dir(fpath) if dirname ~= world_path then if not core.mkdir(dirname) then - wconfig.log("error", "cannot create directory: " .. dirname) + wdata.log("error", "cannot create directory: " .. dirname) return false end end @@ -89,16 +89,16 @@ end -- -- @section aliases ---- Alias of `wconfig.read`. +--- Alias of `wdata.read`. -- -- @falias minetest.read_world_config if not core.read_world_config then - core.read_world_config = wconfig.read + core.read_world_config = wdata.read end ---- Alias of `wconfig.write`. +--- Alias of `wdata.write`. -- -- @falias minetest.write_world_config if not core.write_world_config then - core.write_world_config = wconfig.write + core.write_world_config = wdata.write end diff --git a/docs/api.html b/docs/api.html index 6b876ac..fde8a7e 100644 --- a/docs/api.html +++ b/docs/api.html @@ -3,7 +3,7 @@ - World Config + World Data Manager @@ -24,7 +24,7 @@ diff --git a/docs/config.ld b/docs/config.ld index 00e75c4..d0eb2c1 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -1,5 +1,5 @@ -project = "wconfig" -title = "World Config" +project = "wdata" +title = "World Data Manager" format = "markdown" not_luadoc = true boilerplate = false diff --git a/init.lua b/init.lua index ddab769..980dc54 100644 --- a/init.lua +++ b/init.lua @@ -1,15 +1,15 @@ -wconfig = {} -wconfig.modname = core.get_current_modname() -wconfig.modpath = core.get_modpath(wconfig.modname) +wdata = {} +wdata.modname = core.get_current_modname() +wdata.modpath = core.get_modpath(wdata.modname) -function wconfig.log(lvl, msg) +function wdata.log(lvl, msg) if not msg then msg = lvl lvl = nil end - msg = "[" .. wconfig.modname .. "] " .. msg + msg = "[" .. wdata.modname .. "] " .. msg if not lvl then core.log(msg) else @@ -18,4 +18,4 @@ function wconfig.log(lvl, msg) end -dofile(wconfig.modpath .. "/api.lua") +dofile(wdata.modpath .. "/api.lua") diff --git a/mod.conf b/mod.conf index 5c9078d..352dbdd 100644 --- a/mod.conf +++ b/mod.conf @@ -1,6 +1,6 @@ -name = wconfig -title = World Config -description = Bridging world configuration files & mods. +name = wdata +title = World Data Manager +description = A library for managing data files in the world directory. version = 1.0 license = MIT author = Jordan Irwin (AntumDeluge)