Update alternode mod to v1.1...

Release: https://github.com/AntumMT/mod-alternode/releases/tag/v1.1
master
Jordan Irwin 2021-05-14 15:29:04 -07:00
parent 62821f6acb
commit 6c8eaa5bb5
6 changed files with 82 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -16,12 +16,15 @@ Invoke `/giveme alternode:infostick`. Use the infostick on a node to receive coo
**Chat commands:**
- */getmeta <x> <y> <z> <key>*
- prints the value of `key` in the node's meta data at `x,y,z`.
- */setmeta <x> <y> <z> string|int|float <key> <new_value>*
- 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 <x> <y> <z> <key> <new_value>*
- Sets the value of `key` in meta data of node at `x,y,z`.
- */unsetmeta <x> <y> <z> <key>*
- 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)

View File

@ -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("<x> <y> <z> <key> <value>"),
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("<x> <y> <z> <key>"),
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("<x> <y> <z> <key>"),
description = S("Retrieve meta data of a node"),

View File

@ -9,12 +9,15 @@ That doesn't seem to be a proper node=
pos: x@=@1, y@=@2, z@=@3; name@=@4=
<x> <y> <z> <key>=
<x> <y> <z> <key> <value>=
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=

View File

@ -1,5 +1,5 @@
name = alternode
title = Alter Node
description = Manage node meta data
version = 1.0
version = 1.1
author = Jordan Irwin (AntumDeluge)