From 1677c68a7bdbe4fe28b9020ebf02540a2ec4f91d Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 17 Oct 2024 00:27:33 +0100 Subject: [PATCH] update some commands to the new notification system ....there's a bug in run_command tho with respect to return value handling --- worldeditadditions/lib/selection/selection.lua | 6 +++--- .../commands/extra/saplingaliases.lua | 7 ++++++- worldeditadditions_commands/commands/extra/sculptlist.lua | 2 +- worldeditadditions_commands/commands/meta/for.lua | 5 +++-- worldeditadditions_commands/commands/metaball.lua | 3 +-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/worldeditadditions/lib/selection/selection.lua b/worldeditadditions/lib/selection/selection.lua index f3d08ce..b8232f5 100644 --- a/worldeditadditions/lib/selection/selection.lua +++ b/worldeditadditions/lib/selection/selection.lua @@ -62,9 +62,9 @@ function selection.add_point(name, newpos) -- Done automatically -- worldedit.marker_update(name) - worldedit.player_notify(name, msg) + wea_c.notify.ok(name, msg) else - worldedit.player_notify(name, "Error. Too far away (try raising your maxdist with //farwand maxdist )") + wea_c.notify.error(name, "Error. Too far away (try raising your maxdist with //farwand maxdist )") -- print("[set_pos1]", name, "nil") end end @@ -76,7 +76,7 @@ function selection.clear_points(name) wea_c.pos.clear(name) -- worldedit.marker_update(name) - worldedit.player_notify(name, "Region cleared") + wea_c.notify.ok(name, "Region cleared") end --- Checks if a string is a valid axis. diff --git a/worldeditadditions_commands/commands/extra/saplingaliases.lua b/worldeditadditions_commands/commands/extra/saplingaliases.lua index 5dad0d0..96b31f3 100644 --- a/worldeditadditions_commands/commands/extra/saplingaliases.lua +++ b/worldeditadditions_commands/commands/extra/saplingaliases.lua @@ -17,6 +17,8 @@ minetest.register_chatcommand("/saplingaliases", { local msg = {} + local mode = "info" + if params_text == "aliases" then table.insert(msg, "Currently registered aliases:\n") local aliases = wea_c.get_all_sapling_aliases() @@ -32,10 +34,13 @@ minetest.register_chatcommand("/saplingaliases", { local str = table.concat(results, "\n") table.insert(msg, str) else + mode = "error" table.insert(msg, "Unknown mode '") table.insert(msg, params_text) table.insert(msg, "' (valid modes: aliases, all_saplings).") end - worldedit.player_notify(name, table.concat(msg)) + + -- Don't forget to update this + wea_c.notify(name, mode, table.concat(msg)) end }) diff --git a/worldeditadditions_commands/commands/extra/sculptlist.lua b/worldeditadditions_commands/commands/extra/sculptlist.lua index 1d0dad8..64f9622 100644 --- a/worldeditadditions_commands/commands/extra/sculptlist.lua +++ b/worldeditadditions_commands/commands/extra/sculptlist.lua @@ -53,6 +53,6 @@ minetest.register_chatcommand("/sculptlist", { table.insert(msg, wea_c.format.make_ascii_table(display)) end - worldedit.player_notify(name, table.concat(msg)) + wea_c.notify.info(name, table.concat(msg)) end }) diff --git a/worldeditadditions_commands/commands/meta/for.lua b/worldeditadditions_commands/commands/meta/for.lua index 819d891..03e76d3 100644 --- a/worldeditadditions_commands/commands/meta/for.lua +++ b/worldeditadditions_commands/commands/meta/for.lua @@ -1,3 +1,5 @@ +local wea_c = worldeditadditions_core + -- ███████ ██████ ██████ -- ██ ██ ██ ██ ██ -- █████ ██ ██ ██████ @@ -13,7 +15,6 @@ -- ?Basename support for values -- ?Comma deliniation support for values -local wea_c = worldeditadditions_core local function step(params) -- Initialize additional params on first call if not params.first then @@ -38,7 +39,7 @@ local function step(params) -- If we haven't run out of values call function again minetest.after(0, step, params) else - worldedit.player_notify(params.player_name, "For ".. + wea_c.notify.ok(params.player_name, "For ".. table.concat(params.values,", ").. ", /"..params.cmd_name.." completed in " .. wea_c.format.human_time(params.time)) diff --git a/worldeditadditions_commands/commands/metaball.lua b/worldeditadditions_commands/commands/metaball.lua index a3fbc77..f0fe9ae 100644 --- a/worldeditadditions_commands/commands/metaball.lua +++ b/worldeditadditions_commands/commands/metaball.lua @@ -86,8 +86,7 @@ worldeditadditions_core.register_command("metaball", { local success, value = wea.metaballs.volume(name) if not success then - worldedit.player_notify(name, value) - return -1 + return false, value end return value