Author: silene
Date: Sat Feb 13 10:42:15 2010
New Revision: 41177
URL: http://svn.gna.org/viewcvs/wesnoth?rev=41177&view=rev
Log:
Reverted commit 37760, as the WML equivalent is in fact way too weak for most
purposes.
Modified:
trunk/src/scripting/lua.cpp
Modified: trunk/src/scripting/lua.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/scripting/lua.cpp?rev=41177&r1=41176&r2=41177&view=diff
==============================================================================
--- trunk/src/scripting/lua.cpp (original)
+++ trunk/src/scripting/lua.cpp Sat Feb 13 10:42:15 2010
@@ -836,6 +836,51 @@
game_events::handle_event_command(m, queued_event_context::get(), vcfg);
return 0;
+}
+
+/**
+ * Fires an event.
+ * - Arg 1: string containing the event name.
+ * - Arg 2,3: optional first location.
+ * - Arg 4,5: optional second location.
+ * - Arg 6: optional WML table used as the [weapon] tag.
+ * - Arg 7: optional WML table used as the [second_weapon] tag.
+ * - Ret 1: boolean indicating whether the event was processed or not.
+ */
+static int lua_fire_event(lua_State *L)
+{
+ char const *m = luaL_checkstring(L, 1);
+
+ int pos = 2;
+ if (false) {
+ error_call_destructors:
+ return luaL_typerror(L, pos, "WML table");
+ }
+
+ map_location l1, l2;
+ config data;
+
+ if (lua_isnumber(L, 2)) {
+ l1 = map_location(lua_tointeger(L, 2) - 1, lua_tointeger(L, 3)
- 1);
+ if (lua_isnumber(L, 4)) {
+ l2 = map_location(lua_tointeger(L, 4) - 1,
lua_tointeger(L, 5) - 1);
+ pos = 6;
+ } else pos = 4;
+ }
+
+ if (!lua_isnoneornil(L, pos)) {
+ if (!luaW_toconfig(L, pos, data.add_child("first")))
+ goto error_call_destructors;
+ }
+ ++pos;
+ if (!lua_isnoneornil(L, pos)) {
+ if (!luaW_toconfig(L, pos, data.add_child("second")))
+ goto error_call_destructors;
+ }
+
+ bool b = game_events::fire(m, l1, l2, data);
+ lua_pushboolean(L, b);
+ return 1;
}
/**
@@ -1825,6 +1870,7 @@
static luaL_reg const callbacks[] = {
{ "dofile", &intf_dofile },
{ "fire", &intf_fire },
+ { "fire_event", &lua_fire_event },
{ "eval_conditional", &intf_eval_conditional },
{ "find_path", &intf_find_path },
{ "find_vacant_tile", &intf_find_vacant_tile },
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits