Update alternode mod to v1.0...

Release: https://github.com/AntumMT/mod-alternode/releases/tag/v1.0
master
Jordan Irwin 2021-05-05 07:08:29 -07:00
parent 33a965eb69
commit f7b38b854a
7 changed files with 126 additions and 57 deletions

View File

@ -11,6 +11,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*
* [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*
@ -230,6 +231,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[3d_armor]: https://forum.minetest.net/viewtopic.php?t=4654
[airtanks]: https://forum.minetest.net/viewtopic.php?t=17102
[alternode]: https://forum.minetest.net/viewtopic.php?t=26667
[amber]: https://forum.minetest.net/viewtopic.php?t=18186
[ambience]: https://forum.minetest.net/viewtopic.php?t=2807
[animals_aggressive]: https://github.com/AntumMT/mp-animals_aggressive
@ -372,6 +374,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[lic.3d_armor]: mods/modpacks/3d_armor/LICENSE.md
[lic.airtanks]: mods/equipment/airtanks/LICENSE.txt
[lic.alternode]: mods/admin/alternode/LICENSE.txt
[lic.ambience]: mods/sound/ambience/README.md
[lic.ambience_sounds]: mods/sound/ambience/sounds/SoundLicenses.txt
[lic.antum]: mods/antum/LICENSE.txt
@ -461,6 +464,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.3d_armor]: https://github.com/stujones11/minetest-3d_armor/tree/47ecef4
[ver.airtanks]: https://github.com/minetest-mods/airtanks/tree/b686694
[ver.alternode]: https://github.com/AntumMT/mod-alternode/releases/tag/v1.0
[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,27 @@
## Alternode: Node Meta Manipulation
### Description:
A [Minetest](http://minetest.net/) mod that allows administrators with *server* privilege to examine & alter node meta data.
### Licensing:
- Code: [MIT](LICENSE.txt)
- Textures: CC0
### Usage:
Invoke `/giveme alternode:infostick`. Use the infostick on a node to receive coordinate & other information.
**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`.
### Links:
- [Forum](https://forum.minetest.net/viewtopic.php?t=26667)
- [Git repo](http://github.com/AntumMT/mod-alternode)
- [TODO](TODO.txt)

View File

@ -0,0 +1,3 @@
TODO:
- specify that "pos" & "name" are NOT meta data when using infostick

View File

@ -2,11 +2,13 @@
alternode = {}
alternode.name = core.get_current_modname()
local S = core.get_translator(alternode.name)
core.register_craftitem(alternode.name .. ":infostick", {
description = "Tool for retrieving information about node",
short_description = "Info Stick",
inventory_image = "default_stick.png",
description = S("Tool for retrieving information about a node"),
short_description = S("Info Stick"),
inventory_image = "alternode_infostick.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if not user:is_player() then return end
@ -15,21 +17,26 @@ core.register_craftitem(alternode.name .. ":infostick", {
local granted, missing = core.check_player_privs(pname, {server=true,})
if not granted then
core.chat_send_player(pname, "You do not have privileges to use this item (missing priviliges: " .. table.concat(missing, ", ") .. ")")
core.chat_send_player(pname,
S("You do not have privileges to use this item (missing priviliges: @1)", table.concat(missing, ", ")))
return
end
if pointed_thing.type ~= "node" then
core.chat_send_player(pname, "This item only works on nodes")
core.chat_send_player(pname, S("This item only works on nodes"))
return
end
local pos = core.get_pointed_thing_position(pointed_thing, false)
local node = core.get_node_or_nil(pos)
if not node then
core.chat_send_player(pname, S("That doesn't seem to be a proper node"))
return
end
local meta = core.get_meta(pos)
local infostring = "pos: x=" .. tostring(pos.x)
.. ", y=" .. tostring(pos.y)
.. ", z=" .. tostring(pos.z)
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
local value = meta:get_string(key)
@ -53,30 +60,22 @@ function alternode.set(pos, key, value)
return meta:get_string(key) == value
end
function alternode.set_int(pos, key, value)
local meta = core.get_meta(pos)
meta:set_int(key, value)
return meta:get_int(key) == value
end
function alternode.set_float(pos, key, value)
local meta = core.get_meta(pos)
meta:set_float(key, value)
return meta:get_float(key) == value
end
core.register_chatcommand("setmeta", {
params = "<x> <y> <z> string|int|float <key> <value>",
description = "Alter meta data of a node",
params = S("<x> <y> <z> <key> <value>"),
description = S("Alter 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,
"Coordinate parameters must be numbers")
core.chat_send_player(player, S("You must supply proper coordinates"))
return false
end
end
@ -87,69 +86,83 @@ core.register_chatcommand("setmeta", {
z = tonumber(plist[3]),
}
local vtype = plist[4]
local key = plist[5]
local value = plist[6]
local retval = false
if vtype == "int" then
retval = alternode.set_int(pos, key, tonumber(value))
elseif vtype == "float" then
retval = alternode.set_float(pos, key, tonumber(value))
elseif vtype == "string" then
local rem = {}
for idx, word in ipairs(plist) do
if idx > 5 then
table.insert(rem, word)
end
end
retval = alternode.set(pos, key, table.concat(rem, " "))
else
core.chat_send_player(player,
"Unknown meta data type: " .. vtype)
return false
end
if not retval then
core.chat_send_player(player,
"Failed to set node meta at "
.. tostring(pos.x) .. ","
.. tostring(pos.y) .. ","
.. tostring(pos.z))
else
core.chat_send_player(player,
"Set meta \"" .. key .. "="
.. core.get_meta(pos):get_string(key)
.. "\" for node at "
.. tostring(pos.x) .. ","
.. tostring(pos.y) .. ","
.. tostring(pos.z))
end
return retval
end,
})
core.register_chatcommand("getmeta", {
params = "<x> <y> <z> <key>",
description = "Retrieve meta data of a node",
privs = {server=true,},
func = function(player, param)
local plist = string.split(param, " ")
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 value = {}
for idx, word in ipairs(plist) do
if idx > 4 then
table.insert(value, word)
end
end
if #value == 0 then
core.chat_send_player(player, S("You must supply a value parameter"))
return false
end
local retval = alternode.set(pos, key, table.concat(value, " "):trim())
if not retval then
core.chat_send_player(player,
S("Failed to set node meta at @1,@2,@3",
tostring(pos.x), tostring(pos.y), tostring(pos.z)))
else
core.chat_send_player(player,
S('Set meta "@1@=@2" for node at @3,@4,@5',
key, core.get_meta(pos):get_string(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"),
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 value = alternode.get(pos, key)
if not value or value == "" then
core.chat_send_player(player,
"\"" .. key .. "\" key value not present in node meta data")
S('"@1" key value not present in node meta data', key))
else
core.chat_send_player(player,
"Meta value: " .. key .. "=" .. value)
S("Meta value: @1@=@2", key, value))
end
return true

View File

@ -0,0 +1,20 @@
# Translated by:
Tool for retrieving information about a node=
Info Stick=
You do not have privileges to use this item (missing priviliges: @1)=
This item only works on nodes=
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=
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=
Set meta "@1@=@2" for node at @3,@4,@5=
"@1" key value not present in node meta data=
Meta value: @1@=@2=

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B