From 7d3641021b755be133dea58404fcb039211fbe52 Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Sat, 3 Oct 2020 09:38:08 -0700 Subject: Lua API: Add register_on_chatcommand to SSM and CSM (#7862) Allows catching a chatcommand call just after the command and the parameters are parsed but before its existence is checked and before the corresponding function is run. Returning `true` from a callback function will prevent default handling of the command leaving mods to handle the command manually. --- clientmods/preview/init.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clientmods') diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index 089955d2f..977ed0ec3 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -109,6 +109,10 @@ core.register_on_sending_chat_message(function(message) return false end) +core.register_on_chatcommand(function(command, params) + print("[PREVIEW] caught command '"..command.."'. Parameters: '"..params.."'") +end) + -- This is an example function to ensure it's working properly, should be removed before merge core.register_on_hp_modification(function(hp) print("[PREVIEW] HP modified " .. hp) -- cgit v1.2.3