mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-26 09:03:01 +00:00
Add //ngroups, which lists the groups a given node is a member of
This commit is contained in:
parent
ef86a0658a
commit
78844484f8
6 changed files with 105 additions and 2 deletions
|
@ -9,6 +9,7 @@ Note to self: See the bottom of this file for the release template text.
|
||||||
- Added a (rather nuclear) fix (attempt 4) at finally exterminating all zombie region marker walls forever
|
- Added a (rather nuclear) fix (attempt 4) at finally exterminating all zombie region marker walls forever
|
||||||
- This is not a hotfix to avoid endless small releases fixing the bug, as it's clear it's much more difficult to fix on all systems than initially expected
|
- This is not a hotfix to avoid endless small releases fixing the bug, as it's clear it's much more difficult to fix on all systems than initially expected
|
||||||
- Added [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply), a generalisation of [`//airapply`](https://worldeditadditions.mooncarrot.space/Reference/#airapply) that works with a defined list of nodes. Check out [the reference](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply) - it has some cool tricks to it! (thanks for suggesting, @kliv91 from the Discord server!)
|
- Added [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply), a generalisation of [`//airapply`](https://worldeditadditions.mooncarrot.space/Reference/#airapply) that works with a defined list of nodes. Check out [the reference](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply) - it has some cool tricks to it! (thanks for suggesting, @kliv91 from the Discord server!)
|
||||||
|
- Added [`//ngroups`](https://worldeditadditions.mooncarrot.space/Reference/#ngroups), which lists the groups that a given node is a member of. Useful when paired with [`//nodeapply`](https://worldeditadditions.mooncarrot.space/Reference/#nodeapply)!
|
||||||
|
|
||||||
|
|
||||||
## v1.14.5: The multipoint update, hotfix 5 (1st August 2023)
|
## v1.14.5: The multipoint update, hotfix 5 (1st August 2023)
|
||||||
|
|
|
@ -1401,6 +1401,42 @@ This command is intended for development and modding. You will not normally need
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### `//ngroups <node_name> [v[erbose]]`
|
||||||
|
Lists the groups that a given node is a member of. For example:
|
||||||
|
|
||||||
|
```weacmd
|
||||||
|
//ngroups sand
|
||||||
|
```
|
||||||
|
|
||||||
|
Might return:
|
||||||
|
|
||||||
|
```
|
||||||
|
default:sand ∈ sand crumbly falling_node
|
||||||
|
```
|
||||||
|
|
||||||
|
Groups in Minetest can also have a numerical value greater than 0. Append `v` or `verbose` to see those values:
|
||||||
|
|
||||||
|
```weacmd
|
||||||
|
//ngroups sand v
|
||||||
|
//ngroups sand verbose
|
||||||
|
```
|
||||||
|
|
||||||
|
...both of the above might produce an output like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
default:sand ∈ sand=1 crumbly=3 falling_node=1
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, the customary misc examples:
|
||||||
|
|
||||||
|
```weacmd
|
||||||
|
//ngroups sand
|
||||||
|
//ngroups bakedclay:orange v
|
||||||
|
//ngroups cactus
|
||||||
|
//ngroups default:dry_shrub v
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Extras
|
## Extras
|
||||||
<!--
|
<!--
|
||||||
███████ ██ ██ ████████ ██████ █████ ███████
|
███████ ██ ██ ████████ ██████ █████ ███████
|
||||||
|
|
11
worldeditadditions_commands/commands/nodes/init.lua
Normal file
11
worldeditadditions_commands/commands/nodes/init.lua
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
-- ███ ██ ██████ ██████ ███████ ███████
|
||||||
|
-- ████ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ██ ██ ██ ██ ██ ██ ██ █████ ███████
|
||||||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ██ ████ ██████ ██████ ███████ ███████
|
||||||
|
|
||||||
|
-- Commands that operate on information about nodes, and NOT on the world itself..
|
||||||
|
|
||||||
|
local we_cmdpath = worldeditadditions_commands.modpath .. "/commands/nodes/"
|
||||||
|
|
||||||
|
dofile(we_cmdpath .. "ngroups.lua")
|
52
worldeditadditions_commands/commands/nodes/ngroups.lua
Normal file
52
worldeditadditions_commands/commands/nodes/ngroups.lua
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
local wea_c = worldeditadditions_core
|
||||||
|
local Vector3 = wea_c.Vector3
|
||||||
|
|
||||||
|
|
||||||
|
-- ███ ██ ██████ ██████ ██████ ██ ██ ██████ ███████
|
||||||
|
-- ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ██ ██ ██ ██ ███ ██████ ██ ██ ██ ██ ██████ ███████
|
||||||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ██ ████ ██████ ██ ██ ██████ ██████ ██ ███████
|
||||||
|
|
||||||
|
worldeditadditions_core.register_command("ngroups", {
|
||||||
|
params = "<node_name> [v[erbose]]",
|
||||||
|
description =
|
||||||
|
"Lists the groups that a given node is a part of. If v or verbose are tagged on the end, then group values are also displayed. See also //nodeapply, which pairs well with this command.",
|
||||||
|
privs = {},
|
||||||
|
parse = function(params_text)
|
||||||
|
local parts = wea_c.split_shell(params_text)
|
||||||
|
if #parts == 0 or parts[1] == "" then
|
||||||
|
return false, "Error: No node name specified."
|
||||||
|
end
|
||||||
|
|
||||||
|
local node_name = worldedit.normalize_nodename(parts[1])
|
||||||
|
if not node_name then
|
||||||
|
return false, "Error: Unknown node "..parts[1].."."
|
||||||
|
end
|
||||||
|
|
||||||
|
local verbose = false
|
||||||
|
if parts[2] == "v" or parts[2] == "verbose" then
|
||||||
|
verbose = true
|
||||||
|
end
|
||||||
|
|
||||||
|
return true, node_name, verbose
|
||||||
|
end,
|
||||||
|
nodes_needed = function()
|
||||||
|
return 0
|
||||||
|
end,
|
||||||
|
func = function(_, node_name, verbose)
|
||||||
|
local node_def = minetest.registered_nodes[node_name]
|
||||||
|
if not node_def then return false, "Error: Failed to find definition for node "..node_name.."." end
|
||||||
|
|
||||||
|
local msg = { node_name, "∈" }
|
||||||
|
for group_name, value in pairs(node_def.groups) do
|
||||||
|
local part = group_name
|
||||||
|
if verbose then
|
||||||
|
part = part.."="..tostring(value)
|
||||||
|
end
|
||||||
|
table.insert(msg, part)
|
||||||
|
end
|
||||||
|
|
||||||
|
return true, table.concat(msg, " ")
|
||||||
|
end
|
||||||
|
})
|
|
@ -40,7 +40,10 @@ dofile(wea_cmd.modpath.."/commands/spline.lua")
|
||||||
dofile(wea_cmd.modpath.."/commands/revolve.lua")
|
dofile(wea_cmd.modpath.."/commands/revolve.lua")
|
||||||
|
|
||||||
-- Meta Commands
|
-- Meta Commands
|
||||||
dofile(wea_cmd.modpath.."/commands/meta/init.lua")
|
dofile(wea_cmd.modpath .. "/commands/meta/init.lua")
|
||||||
|
|
||||||
|
-- Node Informational Commands
|
||||||
|
dofile(wea_cmd.modpath .. "/commands/nodes/init.lua")
|
||||||
|
|
||||||
-- Selection Tools
|
-- Selection Tools
|
||||||
dofile(wea_cmd.modpath.."/commands/selectors/init.lua")
|
dofile(wea_cmd.modpath.."/commands/selectors/init.lua")
|
||||||
|
|
|
@ -116,7 +116,7 @@ function NodeListMatcher.match_group(matcher, node_id, group_name)
|
||||||
|
|
||||||
-- 2: Nope, not in the cache. Time to query!
|
-- 2: Nope, not in the cache. Time to query!
|
||||||
local node_name = minetest.get_name_from_content_id(node_id)
|
local node_name = minetest.get_name_from_content_id(node_id)
|
||||||
local group_value = minetest.get_item_group(node_name, "group:"..group_name)
|
local group_value = minetest.get_item_group(node_name, group_name)
|
||||||
if group_value == 0 then group_value = false
|
if group_value == 0 then group_value = false
|
||||||
else group_value = true end
|
else group_value = true end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue