mail[Wesnoth-commits] r36892 - /trunk/src/scripting/lua.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on July 14, 2009 - 18:02:
Author: silene
Date: Tue Jul 14 18:02:00 2009
New Revision: 36892

URL: http://svn.gna.org/viewcvs/wesnoth?rev=36892&view=rev
Log:
Added Lua accessor for map size.

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=36892&r1=36891&r2=36892&view=diff
==============================================================================
--- trunk/src/scripting/lua.cpp (original)
+++ trunk/src/scripting/lua.cpp Tue Jul 14 18:02:00 2009
@@ -952,6 +952,19 @@
        return 0;
 }
 
+/**
+ * Returns the map size.
+ * - Ret 1: width.
+ * - Ret 2: height.
+ */
+static int lua_get_map_size(lua_State *L)
+{
+       const gamemap &map = *game_events::resources->game_map;
+       lua_pushinteger(L, map.w());
+       lua_pushinteger(L, map.h());
+       return 2;
+}
+
 static int lua_message(lua_State *L)
 {
        char const *m = luaL_checkstring(L, 1);
@@ -985,6 +998,7 @@
                { "dofile",                   &lua_dofile                   },
                { "fire",                     &lua_fire                     },
                { "fire_event",               &lua_fire_event               },
+               { "get_map_size",             &lua_get_map_size             },
                { "get_side",                 &lua_get_side                 },
                { "get_terrain",              &lua_get_terrain              },
                { "get_terrain_info",         &lua_get_terrain_info         },




Related Messages


Powered by MHonArc, Updated Tue Jul 14 18:20:44 2009