From bac32864403dcd4af54bda9d19a67812d5281862 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Oct 2014 21:26:25 +0200 Subject: [PATCH] re-implement faction:add_message for Lua. only ancient xmas scripts were using it, but it's a useful function to have. --- src/bind_faction.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bind_faction.c b/src/bind_faction.c index b62c004f8..fafd6bc21 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -22,6 +22,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include #include @@ -211,6 +212,15 @@ static int tolua_faction_renumber(lua_State * L) return 0; } +static int tolua_faction_addnotice(lua_State * L) +{ + faction *self = (faction *)tolua_tousertype(L, 1, 0); + const char *str = tolua_tostring(L, 2, 0); + + addmessage(NULL, self, str, MSG_MESSAGE, ML_IMPORTANT); + return 0; +} + static int tolua_faction_get_objects(lua_State * L) { faction *self = (faction *) tolua_tousertype(L, 1, 0); @@ -563,9 +573,10 @@ void tolua_faction_open(lua_State * L) .property("x", &faction_getorigin_x, &faction_setorigin_x) .property("y", &faction_getorigin_y, &faction_setorigin_y) - .def("add_notice", &faction_addnotice) #endif - tolua_variable(L, TOLUA_CAST "objects", tolua_faction_get_objects, + tolua_function(L, TOLUA_CAST "add_notice", &tolua_faction_addnotice); + + tolua_variable(L, TOLUA_CAST "objects", tolua_faction_get_objects, NULL); } tolua_endmodule(L);