From 4c54e5c20379bbff60a25924790d19a2eb912267 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Wed, 7 May 2008 23:14:54 +0000 Subject: Implemented script bindings for making beings talk and sending private chat messages from scripts to clients. Implemented trigger areas which are only triggered once when a being steps into them instead of every tick. --- src/scripting/lua.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 62fd64a..a8663f7 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -413,6 +413,32 @@ static int LuaBeing_Walk(lua_State *s) return 0; } +/** + * Makes the being say something + * tmw.being_say(source, message) + */ +static int LuaBeing_Say(lua_State *s) +{ + if (!lua_isuserdata(s, 1) || !lua_isstring(s, 2) ) + { + raiseScriptError(s, "being_say called with incorrect parameters."); + return 0; + } + + Being *being = getBeing(s, 1); + std::string message = lua_tostring(s, 2); + + if (being && message != "") + { + GameState::sayAround(being, message); + } else { + raiseScriptError(s, "being_say called with incorrect parameters."); + return 0; + } + + return 0; +} + /** * Function for getting the x-coordinate of the position of a being */ @@ -561,7 +587,8 @@ static int LuaTrigger_Create(lua_State *s) !lua_isnumber(s, 3) || !lua_isnumber(s, 4) || !lua_isstring(s, 5) || - !lua_isnumber(s, 6)) + !lua_isnumber(s, 6) || + !lua_isboolean(s, 7)) { raiseScriptError(s, "trigger_create called with incorrect parameters."); return 0; @@ -576,6 +603,7 @@ static int LuaTrigger_Create(lua_State *s) int height = lua_tointeger(s, 4); std::string function = lua_tostring(s, 5); int id = lua_tointeger(s, 6); + bool once = lua_toboolean(s, 7); LOG_INFO("Created script trigger at "<