mirror of
https://github.com/redstrate/Kawari.git
synced 2025-06-30 11:47:45 +00:00
Add support on the Rust side for resetting the command identifier.
-sender was also renamed to command_sender in case we'd like to reserve the word "sender" in the future.
This commit is contained in:
parent
0f7e068ba3
commit
385672d797
10 changed files with 23 additions and 14 deletions
|
@ -26,17 +26,15 @@ end
|
|||
|
||||
function printf(player, fmt_str, ...)
|
||||
-- Sender would be defined elsewhere, if at all
|
||||
if sender == nil then
|
||||
sender = ""
|
||||
if command_sender == nil then
|
||||
command_sender = ""
|
||||
end
|
||||
|
||||
if ... ~= nil then
|
||||
player:send_message(sender..fmt_str:format(...))
|
||||
player:send_message(command_sender..fmt_str:format(...))
|
||||
else
|
||||
player:send_message(sender..fmt_str)
|
||||
player:send_message(command_sender..fmt_str)
|
||||
end
|
||||
|
||||
sender = nil -- Reset the sender, it's not required to have for printf to work, and not all users of printf will be commands, most likely.
|
||||
end
|
||||
|
||||
-- Constants
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[teri] "
|
||||
command_sender = "[teri] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local parts = split(args)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
-- A list of festival ids can be found in Hyperborea's source tree:
|
||||
-- https://github.com/kawaii/Hyperborea/blob/main/Hyperborea/festivals.yaml
|
||||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[festival] "
|
||||
command_sender = "[festival] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local parts = split(args)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
-- Ported from Ioncannon's Project Meteor Server
|
||||
-- https://bitbucket.org/Ioncannon/project-meteor-server/src/develop/Data/scripts/commands/gm/nudge.lua
|
||||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[nudge] "
|
||||
command_sender = "[nudge] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local parts = split(args)
|
||||
|
@ -70,5 +70,6 @@ function onCommand(args, player)
|
|||
end
|
||||
|
||||
player:set_position(new_position, player.rotation)
|
||||
|
||||
printf(player, "Positioning %s %s yalms.", direction_str, distance)
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[setspeed] "
|
||||
command_sender = "[setspeed] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local parts = split(args)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[invis] "
|
||||
command_sender = "[invis] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local usage = "\nThis command makes the user invisible to all other actors."
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[wireframe] "
|
||||
command_sender = "[wireframe] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local usage = "\nThis command allows the user to view the world in wireframe mode."
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[unlockaction] "
|
||||
command_sender = "[unlockaction] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local parts = split(args)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
required_rank = GM_RANK_DEBUG
|
||||
sender = "[unlockaetheryte] "
|
||||
command_sender = "[unlockaetheryte] "
|
||||
|
||||
function onCommand(args, player)
|
||||
local parts = split(args)
|
||||
|
|
|
@ -555,6 +555,16 @@ async fn client_loop(
|
|||
let func: Function =
|
||||
lua.globals().get("onCommand")?;
|
||||
func.call::<()>((func_args, connection_data))?;
|
||||
|
||||
/* `command_sender` is an optional variable scripts can define to identify themselves in print messages.
|
||||
* It's okay if this global isn't set. We also don't care what its value is, just that it exists.
|
||||
* This is reset -after- running the command intentionally. Resetting beforehand will never display the command's identifier.
|
||||
*/
|
||||
let command_sender: Result<mlua::prelude::LuaValue, mlua::prelude::LuaError> = lua.globals().get("command_sender");
|
||||
if let Ok(_) = command_sender {
|
||||
// tracing::info!("Resetting command_sender for next script run.");
|
||||
lua.globals().set("command_sender", mlua::Value::Nil)?;
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
tracing::info!("User with account_id {} tried to invoke GM command {} with insufficient privileges!",
|
||||
|
|
Loading…
Add table
Reference in a new issue