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*** ***"UPDATES" Denotes updates available***
* admin/ * 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* * [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] * [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* * [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 [3d_armor]: https://forum.minetest.net/viewtopic.php?t=4654
[airtanks]: https://forum.minetest.net/viewtopic.php?t=17102 [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 [amber]: https://forum.minetest.net/viewtopic.php?t=18186
[ambience]: https://forum.minetest.net/viewtopic.php?t=2807 [ambience]: https://forum.minetest.net/viewtopic.php?t=2807
[animals_aggressive]: https://github.com/AntumMT/mp-animals_aggressive [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.3d_armor]: mods/modpacks/3d_armor/LICENSE.md
[lic.airtanks]: mods/equipment/airtanks/LICENSE.txt [lic.airtanks]: mods/equipment/airtanks/LICENSE.txt
[lic.alternode]: mods/admin/alternode/LICENSE.txt
[lic.ambience]: mods/sound/ambience/README.md [lic.ambience]: mods/sound/ambience/README.md
[lic.ambience_sounds]: mods/sound/ambience/sounds/SoundLicenses.txt [lic.ambience_sounds]: mods/sound/ambience/sounds/SoundLicenses.txt
[lic.antum]: mods/antum/LICENSE.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.3d_armor]: https://github.com/stujones11/minetest-3d_armor/tree/47ecef4
[ver.airtanks]: https://github.com/minetest-mods/airtanks/tree/b686694 [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.amber]: https://github.com/theraven262/amber/tree/56627fa
[ver.ambience]: https://notabug.org/TenPlus1/ambience/src/e317f727d00d5c034226c0e7217ed0559c208038 [ver.ambience]: https://notabug.org/TenPlus1/ambience/src/e317f727d00d5c034226c0e7217ed0559c208038
[ver.animals_aggressive]: https://github.com/AntumMT/mp-animals_aggressive/tree/4eede4d [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 = {}
alternode.name = core.get_current_modname() alternode.name = core.get_current_modname()
local S = core.get_translator(alternode.name)
core.register_craftitem(alternode.name .. ":infostick", { core.register_craftitem(alternode.name .. ":infostick", {
description = "Tool for retrieving information about node", description = S("Tool for retrieving information about a node"),
short_description = "Info Stick", short_description = S("Info Stick"),
inventory_image = "default_stick.png", inventory_image = "alternode_infostick.png",
stack_max = 1, stack_max = 1,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
if not user:is_player() then return end 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,}) local granted, missing = core.check_player_privs(pname, {server=true,})
if not granted then 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 return
end end
if pointed_thing.type ~= "node" then 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 return
end end
local pos = core.get_pointed_thing_position(pointed_thing, false) 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 meta = core.get_meta(pos)
local infostring = "pos: x=" .. tostring(pos.x) local infostring = S("pos: x@=@1, y@=@2, z@=@3; name@=@4",
.. ", y=" .. tostring(pos.y) tostring(pos.x), tostring(pos.y), tostring(pos.z), node.name)
.. ", z=" .. tostring(pos.z)
for _, key in ipairs({"infotext", "owner"}) do for _, key in ipairs({"infotext", "owner"}) do
local value = meta:get_string(key) local value = meta:get_string(key)
@ -53,30 +60,22 @@ function alternode.set(pos, key, value)
return meta:get_string(key) == value return meta:get_string(key) == value
end 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", { core.register_chatcommand("setmeta", {
params = "<x> <y> <z> string|int|float <key> <value>", params = S("<x> <y> <z> <key> <value>"),
description = "Alter meta data of a node", description = S("Alter meta data of a node"),
privs = {server=true,}, privs = {server=true,},
func = function(player, param) func = function(player, param)
local plist = string.split(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 for _, p in ipairs({plist[1], plist[2], plist[3]}) do
if tonumber(p) == nil then if tonumber(p) == nil then
core.chat_send_player(player, core.chat_send_player(player, S("You must supply proper coordinates"))
"Coordinate parameters must be numbers")
return false return false
end end
end end
@ -87,43 +86,37 @@ core.register_chatcommand("setmeta", {
z = tonumber(plist[3]), z = tonumber(plist[3]),
} }
local vtype = plist[4] local key = plist[4]
local key = plist[5] if key then key = key:trim() end
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, " ")) if not key or key == "" then
else core.chat_send_player(player, S("You must supply a key parameter"))
core.chat_send_player(player,
"Unknown meta data type: " .. vtype)
return false return false
end 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 if not retval then
core.chat_send_player(player, core.chat_send_player(player,
"Failed to set node meta at " S("Failed to set node meta at @1,@2,@3",
.. tostring(pos.x) .. "," tostring(pos.x), tostring(pos.y), tostring(pos.z)))
.. tostring(pos.y) .. ","
.. tostring(pos.z))
else else
core.chat_send_player(player, core.chat_send_player(player,
"Set meta \"" .. key .. "=" S('Set meta "@1@=@2" for node at @3,@4,@5',
.. core.get_meta(pos):get_string(key) key, core.get_meta(pos):get_string(key),
.. "\" for node at " tostring(pos.x), tostring(pos.y), tostring(pos.z)))
.. tostring(pos.x) .. ","
.. tostring(pos.y) .. ","
.. tostring(pos.z))
end end
return retval return retval
@ -131,11 +124,24 @@ core.register_chatcommand("setmeta", {
}) })
core.register_chatcommand("getmeta", { core.register_chatcommand("getmeta", {
params = "<x> <y> <z> <key>", params = S("<x> <y> <z> <key>"),
description = "Retrieve meta data of a node", description = S("Retrieve meta data of a node"),
privs = {server=true,}, privs = {server=true,},
func = function(player, param) func = function(player, param)
local plist = string.split(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 = { local pos = {
x = tonumber(plist[1]), x = tonumber(plist[1]),
y = tonumber(plist[2]), y = tonumber(plist[2]),
@ -143,13 +149,20 @@ core.register_chatcommand("getmeta", {
} }
local key = plist[4] 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) local value = alternode.get(pos, key)
if not value or value == "" then if not value or value == "" then
core.chat_send_player(player, 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 else
core.chat_send_player(player, core.chat_send_player(player,
"Meta value: " .. key .. "=" .. value) S("Meta value: @1@=@2", key, value))
end end
return true 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 name = alternode
title = Alter Node title = Alter Node
description = Manage node meta data description = Manage node meta data
version = 1.0
author = Jordan Irwin (AntumDeluge)

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B