Compare commits

...

4 Commits

Author SHA1 Message Date
Starbeamrainbowlabs 2c30ed8634
Tweak changelog 2023-07-09 23:39:52 +01:00
Starbeamrainbowlabs bf365d2d11
reference: update //maze and //maze3d
Ref https://forum.minetest.net/viewtopic.php?p=414718#p414718
2023-07-09 19:57:02 +01:00
Starbeamrainbowlabs f2214150f2
Update minetest.chatcommands → minetest.registered_chatcommands 2023-07-09 19:49:38 +01:00
Starbeamrainbowlabs 3bfc62be24
Make //unmark WEA-aware
Backwards compatibility with WE is maintained.
2023-07-09 19:44:31 +01:00
15 changed files with 73 additions and 15 deletions

View File

@ -11,6 +11,7 @@ Note to self: See the bottom of this file for the release template text.
- Add new multi-point selection wand ![A picture of the multi-point wand](https://raw.githubusercontent.com/sbrl/Minetest-WorldEditAdditions/main/worldeditadditions_farwand/textures/worldeditadditions_multiwand.png) to select many points at once.
- Implement custom region boxing UI, which replaces the WorldEdit region box when using WorldEditAdditions wands.
- Is backwards compatible with regular WorldEdit wands and tools, as WorldEditAdditions keeps the new positioning system in sync with WorldEdit's.
- The new multipoint wand required this as a prerequisite
- Add [`//spline`](https://worldeditadditions.mooncarrot.space/Reference/#spline), for drawing curved lines with an arbitrary number of points **(uses the new multi-point wand)**
- Add [`//revolve`](https://worldeditadditions.mooncarrot.space/Reference/#revolve), which makes multiple evenly-spaced rotated copies of the defined region **(uses the new multi-point wand)**
- [`//copy+`](https://worldeditadditions.mooncarrot.space/Reference/#copy), [`//move+`](https://worldeditadditions.mooncarrot.space/Reference/#move): Added support for integrated `airapply` mode, which replaces nodes at the target only if they are air - append `airapply`/`aa` to the command to use

View File

@ -105,6 +105,8 @@ Generates a maze using replace_node as the walls and air as the paths. Uses [an
Requires the currently selected area to be at least 3x3 on the x and z axes respectively.
Mazes are generated from the bottom to the top of the defined region. In other words, the height of the walls of the maze is equal to the height of the defined region.
The optional `path_length` and `path_width` arguments require additional explanation. When generating a maze, a multi-headed random walk is performed. When the generator decides to move forwards from a point, it does so `path_length` nodes at a time. `path_length` defaults to `2`.
`path_width` is easier to explain. It defaults to `1`, and is basically the number of nodes wide the path generated is.
@ -126,7 +128,7 @@ The last example below shows how to set the path length and width:
### `//maze3d <replace_node> [<path_length> [<path_width> [<path_depth> [<seed>]]]]`
Same as `//maze`, but instead generates mazes in 3 dimensions instead of 2. Requires the currently selected area to be at least 3x3x3.
The optional `path_depth` parameter defaults to `1` and allows customisation of the height of the paths generated.
The optional `path_depth` parameter defaults to `1` and allows customisation of the height of the paths generated. In other words, it customises the ceiling height, or the distance from the floor to the ceiling of the paths generated.
To get a better look at the generated maze, try inverting it like so:

View File

@ -68,7 +68,7 @@ worldeditadditions_core.register_command("for", {
return true, values, command, args
end,
func = function(name, values, command, args)
local cmd = minetest.chatcommands[command]
local cmd = minetest.registered_chatcommands[command]
if not cmd then
return false, "Error: "..command.." isn't a valid command."
end

View File

@ -20,7 +20,7 @@ local function step(params)
if not args then args = ""
else args = args:match("^%s*(.*)%s*$") end
-- Get command and test privs
local cmd = minetest.chatcommands[command]
local cmd = minetest.registered_chatcommands[command]
if not cmd then
return false, "Error: "..command.." isn't a valid command."
end

View File

@ -20,7 +20,7 @@ local function step(params)
))
))
local cmd = minetest.chatcommands[params.cmd_name]
local cmd = minetest.registered_chatcommands[params.cmd_name]
minetest.log("action", params.name.." runs "..full_cmd.." (time "..tostring(params.i).." of "..tostring(params.count)..")")
cmd.func(params.name, params.args)
@ -80,7 +80,7 @@ minetest.register_chatcommand("/many", {
cmd_name = wea_c.trim(cmd_name):sub(2) -- Things start at 1, not 0 in Lua :-(
-- Check the command we're going to execute
local cmd = minetest.chatcommands[cmd_name]
local cmd = minetest.registered_chatcommands[cmd_name]
if not cmd then
return false, "Error: "..cmd_name.." isn't a valid command."
end

View File

@ -31,7 +31,7 @@ minetest.register_chatcommand("/multi", {
worldedit.player_notify(name, "#"..i..": "..command)
local cmd = minetest.chatcommands[command_name]
local cmd = minetest.registered_chatcommands[command_name]
if not cmd then
return false, "Error: "..command_name.." isn't a valid command."
end

View File

@ -123,7 +123,7 @@ worldeditadditions_core.register_command("subdivide", {
-- worldedit.marker_update(name)
cmd.func(name, wea_c.table.unpack(cmd_args_parsed))
if will_trigger_saferegion(name, cmd_name, args) then
minetest.chatcommands["/y"].func(name)
minetest.registered_chatcommands["/y"].func(name)
end
worldedit.player_notify_unsuppress(name)

View File

@ -20,6 +20,7 @@ dofile(we_cmdpath.."spush.lua")
dofile(we_cmdpath.."srect.lua")
dofile(we_cmdpath.."sshift.lua")
dofile(we_cmdpath.."sstack.lua")
dofile(we_cmdpath.."unmark.lua")
-- Aliases
worldedit.alias_command("sfac", "sfactor")

View File

@ -0,0 +1,32 @@
local weac = worldeditadditions_core
local worldedit_unmark
if minetest.registered_chatcommands["/unmark"] then
worldedit_unmark = minetest.registered_chatcommands["/unmark"].func
end
local function do_unmark(name, params_text)
-- Hide the WorldEdit marker, if appropriate
if type(worldedit_unmark) == "function" then
worldedit_unmark(name, params_text)
end
-- Hide the WorldEditAdditions marker
weac.pos.unmark(name)
end
if minetest.registered_chatcommands["/unmark"] then
minetest.override_chatcommand("/unmark", {
params = "",
description = "Hide the markers for the defined region (and any other positions), but do not remove the points themselves.",
func = do_unmark
})
else
minetest.register_chatcommand("/unmark", {
params = "",
description = "Hide the markers for the defined region (and any other positions), but do not remove the points themselves.",
privs = { worldedit = true },
func = do_unmark
})
end

View File

@ -2,7 +2,7 @@
--- Fetches the definition of a WorldEditAdditions or WorldEdit command
-- Does not support fetching generic Minetest commands - check
-- minetest.chatcommands for this.
-- minetest.registered_chatcommands for this.
-- @param cmdname string The name of the command to fetch the definition for.
local function fetch_command_def(cmdname)
local wea_c = worldeditadditions_core

View File

@ -250,6 +250,14 @@ local function push(player_name, pos)
return #positions[player_name]
end
--- Hides the visual markers for the given player's positions and defined region, but does not clear the points.
-- @param player_name string The name of the player to operate on.
local function unmark(player_name)
anchor:emit("unmark", {
player_name = player_name
})
end
anchor = wea_c.EventEmitter.new({
get = get,
@ -265,7 +273,8 @@ anchor = wea_c.EventEmitter.new({
set1 = set1,
set2 = set2,
set_all = set_all,
compat_worldedit_get = compat_worldedit_get
unmark = unmark,
compat_worldedit_get = compat_worldedit_get,
})
anchor.debug = false

View File

@ -82,4 +82,16 @@ wea_c.pos:addEventListener("clear", function(event)
worldedit.marker_update(event.player_name)
end
position_entities[event.player_name] = nil
end)
wea_c.pos:addEventListener("unmark", function(event)
ensure_player(event.player_name)
if #position_entities[event.player_name] > 0 then
for _, entity in pairs(position_entities[event.player_name]) do
wea_c.entities.pos_marker.delete(entity)
end
end
-- Note that this function is NOT WorldEdit compatible, because it is only called through our override of WorldEdit's `//unmark`, and WorldEdit doesn't have an API function to call to unmark and everything is complicated.
end)

View File

@ -69,4 +69,5 @@ end
weac.pos:addEventListener("set", handle_event)
weac.pos:addEventListener("pop", handle_event)
weac.pos:addEventListener("push", handle_event)
weac.pos:addEventListener("clear", do_delete)
weac.pos:addEventListener("clear", do_delete)
weac.pos:addEventListener("unmark", do_delete)

View File

@ -18,15 +18,15 @@ local function register_alias(cmdname_target, cmdname_source, override)
-- print("DEBUG ALIAS source "..cmdname_source.." target "..cmdname_target)
if minetest.chatcommands["/"..cmdname_target] then
if minetest.registered_chatcommands["/" .. cmdname_target] then
minetest.override_chatcommand(
"/"..cmdname_target,
minetest.chatcommands["/"..cmdname_source]
minetest.registered_chatcommands["/" .. cmdname_source]
)
else
minetest.register_chatcommand(
"/"..cmdname_target,
minetest.chatcommands["/"..cmdname_source]
minetest.registered_chatcommands["/" .. cmdname_source]
)
end
wea_c.registered_commands[cmdname_target] = wea_c.registered_commands[cmdname_source]

View File

@ -8,8 +8,8 @@
local worldedit_command_y, worldedit_command_n
if minetest.global_exists("worldedit") then
worldedit_command_y = minetest.chatcommands["/y"].func
worldedit_command_n = minetest.chatcommands["/n"].func
worldedit_command_y = minetest.registered_chatcommands["/y"].func
worldedit_command_n = minetest.registered_chatcommands["/n"].func
end
--- A table that holds at most 1 pending function call per player.