From 6c8eaa5bb5de0df245b1e3bb71957c17d1279048 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Fri, 14 May 2021 15:29:04 -0700 Subject: [PATCH] Update alternode mod to v1.1... Release: https://github.com/AntumMT/mod-alternode/releases/tag/v1.1 --- README.md | 4 +- mods/admin/alternode/CHANGES.txt | 13 ++++++ mods/admin/alternode/README.md | 9 ++-- mods/admin/alternode/init.lua | 58 +++++++++++++++++++++++- mods/admin/alternode/locale/template.txt | 5 +- mods/admin/alternode/mod.conf | 2 +- 6 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 mods/admin/alternode/CHANGES.txt diff --git a/README.md b/README.md index 975224f1..0ebd0c41 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m ***"UPDATES" Denotes updates available*** * admin/ - * [alternode][] ([MIT][lic.alternode]) -- version: [1.0][ver.alternode] *2021-05-03* + * [alternode][] ([MIT][lic.alternode]) -- version: [1.1][ver.alternode] *2021-05-14* * [cleaner][] ([CC0][lic.cc0]) -- version: [0.4 (68222b1 Git)][ver.cleaner] *2017-08-30* * [invisible][] ([LGPL][lic.lgpl2.1] / [CC BY-SA][lic.ccbysa4.0]) -- version: [4 (a2a6504 Git)][ver.invisible] * [no_fall_damage][] ([MIT][lic.no_fall_damage]) -- version [1.0.0][ver.no_fall_damage] *2020-12-19* @@ -448,7 +448,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m [ver.3d_armor]: https://github.com/minetest-mods/3d_armor/tree/f07f050 [ver.airtanks]: https://github.com/minetest-mods/airtanks/tree/b686694 -[ver.alternode]: https://github.com/AntumMT/mod-alternode/releases/tag/v1.0 +[ver.alternode]: https://github.com/AntumMT/mod-alternode/releases/tag/v1.1 [ver.amber]: https://github.com/theraven262/amber/tree/56627fa [ver.ambience]: https://notabug.org/TenPlus1/ambience/src/e317f727d00d5c034226c0e7217ed0559c208038 [ver.animals_aggressive]: https://github.com/AntumMT/mp-animals_aggressive/tree/4eede4d diff --git a/mods/admin/alternode/CHANGES.txt b/mods/admin/alternode/CHANGES.txt new file mode 100644 index 00000000..260aa48b --- /dev/null +++ b/mods/admin/alternode/CHANGES.txt @@ -0,0 +1,13 @@ + +1.1 +- added alternode.unset method to unset node meta data +- added /unsetmeta chat command + + +1.0 +- initial release +- added alternode:infostick to get position & some meta info from nodes +- added alternode.get method to retrieve meta value of a node +- added alternode.set method to set meta value of a node +- added /getmeta chat command +- added /setmeta chat command diff --git a/mods/admin/alternode/README.md b/mods/admin/alternode/README.md index 5617bfd4..540c0d51 100644 --- a/mods/admin/alternode/README.md +++ b/mods/admin/alternode/README.md @@ -16,12 +16,15 @@ Invoke `/giveme alternode:infostick`. Use the infostick on a node to receive coo **Chat commands:** - */getmeta * - - prints the value of `key` in the node's meta data at `x,y,z`. -- */setmeta string|int|float * - - Sets the value of `key` in the meta data of node at `x,y,z`. + - prints the value of `key` in meta data of node at `x,y,z`. +- */setmeta * + - Sets the value of `key` in meta data of node at `x,y,z`. +- */unsetmeta * + - Unsets the value of `key` in meta data of node at `x,y,z`. ### Links: - [Forum](https://forum.minetest.net/viewtopic.php?t=26667) - [Git repo](http://github.com/AntumMT/mod-alternode) +- [Changelog](CHANGES.txt) - [TODO](TODO.txt) diff --git a/mods/admin/alternode/init.lua b/mods/admin/alternode/init.lua index eaf156cf..29e34efd 100644 --- a/mods/admin/alternode/init.lua +++ b/mods/admin/alternode/init.lua @@ -38,7 +38,7 @@ core.register_craftitem(alternode.name .. ":infostick", { local infostring = S("pos: x@=@1, y@=@2, z@=@3; name@=@4", tostring(pos.x), tostring(pos.y), tostring(pos.z), node.name) - for _, key in ipairs({"infotext", "owner"}) do + for _, key in ipairs({"id", "infotext", "owner"}) do local value = meta:get_string(key) if value and value ~= "" then infostring = infostring .. "; " @@ -60,10 +60,16 @@ function alternode.set(pos, key, value) return meta:get_string(key) == value end +function alternode.unset(pos, key) + local meta = core.get_meta(pos) + meta:set_string(key, nil) + return meta:get_string(key) == "" +end + core.register_chatcommand("setmeta", { params = S(" "), - description = S("Alter meta data of a node"), + description = S("Set meta data of a node"), privs = {server=true,}, func = function(player, param) local plist = string.split(param, " ") @@ -123,6 +129,54 @@ core.register_chatcommand("setmeta", { end, }) +core.register_chatcommand("unsetmeta", { + params = S(" "), + description = S("Unset meta data of a node"), + privs = {server=true,}, + func = function(player, param) + local plist = string.split(param, " ") + + if #plist < 3 then + core.chat_send_player(player, S("You must supply proper coordinates")) + return false + end + + for _, p in ipairs({plist[1], plist[2], plist[3]}) do + if tonumber(p) == nil then + core.chat_send_player(player, S("You must supply proper coordinates")) + return false + end + end + + local pos = { + x = tonumber(plist[1]), + y = tonumber(plist[2]), + z = tonumber(plist[3]), + } + + local key = plist[4] + if key then key = key:trim() end + + if not key or key == "" then + core.chat_send_player(player, S("You must supply a key parameter")) + return false + end + + local retval = alternode.unset(pos, key) + if not retval then + core.chat_send_player(player, + S("Failed to unset node meta at @1,@2,@3", + tostring(pos.x), tostring(pos.y), tostring(pos.z))) + else + core.chat_send_player(player, + S('Unset meta "@1" for node at @2,@3,@4', + key, tostring(pos.x), tostring(pos.y), tostring(pos.z))) + end + + return retval + end, +}) + core.register_chatcommand("getmeta", { params = S(" "), description = S("Retrieve meta data of a node"), diff --git a/mods/admin/alternode/locale/template.txt b/mods/admin/alternode/locale/template.txt index 214cec0e..f181432b 100644 --- a/mods/admin/alternode/locale/template.txt +++ b/mods/admin/alternode/locale/template.txt @@ -9,12 +9,15 @@ That doesn't seem to be a proper node= pos: x@=@1, y@=@2, z@=@3; name@=@4= = = -Alter meta data of a node= +Set meta data of a node= +Unset meta data of a node= Retrieve meta data of a node= You must supply proper coordinates= You must supply a key parameter= You must supply a value parameter= Failed to set node meta at @1,@2,@3= +Failed to unset node meta at @1,@2,@3= Set meta "@1@=@2" for node at @3,@4,@5= +Unset meta "@1" for node at @2,@3,@4= "@1" key value not present in node meta data= Meta value: @1@=@2= diff --git a/mods/admin/alternode/mod.conf b/mods/admin/alternode/mod.conf index a753befb..e825eb18 100644 --- a/mods/admin/alternode/mod.conf +++ b/mods/admin/alternode/mod.conf @@ -1,5 +1,5 @@ name = alternode title = Alter Node description = Manage node meta data -version = 1.0 +version = 1.1 author = Jordan Irwin (AntumDeluge)