From 05df2ee8a4fe6bd4fcb1879fd418ef6ad301fcf4 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 27 Nov 2011 19:39:36 +0200 Subject: Add chat message callback and send functions --- data/mods/default/init.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'data/mods') diff --git a/data/mods/default/init.lua b/data/mods/default/init.lua index ea6bf3da9..537f62e31 100644 --- a/data/mods/default/init.lua +++ b/data/mods/default/init.lua @@ -19,8 +19,11 @@ -- minetest.register_on_newplayer(func(ObjectRef)) -- minetest.register_on_respawnplayer(func(ObjectRef)) -- ^ return true in func to disable regular player placement +-- minetest.register_on_chat_message(func(name, message)) -- minetest.setting_get(name) -- minetest.setting_getbool(name) +-- minetest.chat_send_all(text) +-- minetest.chat_send_player(name, text) -- -- Global objects: -- minetest.env - environment reference @@ -1371,6 +1374,21 @@ end) print("setting max_users = " .. dump(minetest.setting_get("max_users"))) print("setting asdf = " .. dump(minetest.setting_get("asdf"))) +minetest.register_on_chat_message(function(name, message) + print("on_chat_message: name="..dump(name).." message="..dump(message)) + local cmd = "/testcommand" + if message:sub(0, #cmd) == cmd then + print(cmd.." invoked") + return true + end + local cmd = "/help" + if message:sub(0, #cmd) == cmd then + print("script-overridden help command") + minetest.chat_send_all("script-overridden help command") + return true + end +end) + -- -- Done, print some random stuff -- -- cgit v1.2.3