diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-01-21 22:39:29 +0800 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-01-22 18:52:59 +0800 |
commit | 5636dccf2166ef86731ca68a2ced822cf733b938 (patch) | |
tree | f3fc270b896f20a12f8da7ef21f7c6e51636e5c0 /src | |
parent | b07fb57cd954b976758cd94196adb00bc25fcedf (diff) | |
download | manaserv-5636dccf2166ef86731ca68a2ced822cf733b938.tar.gz manaserv-5636dccf2166ef86731ca68a2ced822cf733b938.tar.bz2 manaserv-5636dccf2166ef86731ca68a2ced822cf733b938.tar.xz manaserv-5636dccf2166ef86731ca68a2ced822cf733b938.zip |
Added announce(text [, sender]) lua function
The function will cause a global announcement.
If no sender ist set "Server" will be used.
Reviewed-by: Bjorn.
Diffstat (limited to 'src')
-rw-r--r-- | src/scripting/lua.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 21c4b4b8..a03bc574 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1714,10 +1714,6 @@ static int chat_message(lua_State *s) GameState::sayTo(being, NULL, message); } } - else if (lua_gettop(s) == 1 && lua_isstring(s, 1)) - { - // TODO: make chatserver send a global message - } else { raiseScriptError(s, "chat_message called with incorrect parameters."); @@ -2586,6 +2582,23 @@ static int map_object_get_type(lua_State *s) return 1; } +/** + * mana.announce(text [, sender]) + * Does a global announce + */ +static int announce(lua_State *s) +{ + const char *message = luaL_checkstring(s, 1); + const char *sender = luaL_optstring(s, 2, "Server"); + + MessageOut msg(GAMSG_ANNOUNCE); + msg.writeString(message); + msg.writeInt16(0); // Announce from server so id = 0 + msg.writeString(sender); + accountHandler->send(msg); + return 0; +} + static int require_loader(lua_State *s) { // Add .lua extension (maybe only do this when it doesn't have it already) @@ -2706,6 +2719,7 @@ LuaScript::LuaScript(): { "map_object_get_bounds", &map_object_get_bounds }, { "map_object_get_name", &map_object_get_name }, { "map_object_get_type", &map_object_get_type }, + { "announce", &announce }, { NULL, NULL } }; luaL_register(mState, "mana", callbacks); |