Author: anonymissimus
Date: Tue Jun  7 17:26:57 2011
New Revision: 49788

URL: http://svn.gna.org/viewcvs/wesnoth?rev=49788&view=rev
Log:
transformed wesnoth.get_time_of_day into a more useful implementation

(will extend with more parameters and return values)

Modified:
    trunk/data/ai/scenarios/scenario-lua-ai.cfg
    trunk/src/scripting/lua.cpp

Modified: trunk/data/ai/scenarios/scenario-lua-ai.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ai/scenarios/scenario-lua-ai.cfg?rev=49788&r1=49787&r2=49788&view=diff
==============================================================================
--- trunk/data/ai/scenarios/scenario-lua-ai.cfg (original)
+++ trunk/data/ai/scenarios/scenario-lua-ai.cfg Tue Jun  7 17:26:57 2011
@@ -294,7 +294,7 @@
 wesnoth.message('Support villages: ' .. tostring(ai.get_support_villages()))
 wesnoth.message('Village value: ' .. ai.get_village_value())
 wesnoth.message('Villages per scout: ' .. ai.get_villages_per_scout())
-wesnoth.message('TOOD: ' .. wesnoth.get_time_of_day())
+wesnoth.message('TOOD: ' .. wesnoth.get_time_of_day().id)
        
        my_leader = wesnoth.get_units({canrecruit = true, side = ai.side})[1]
        x,y = ai.suitable_keep(my_leader)

Modified: trunk/src/scripting/lua.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/scripting/lua.cpp?rev=49788&r1=49787&r2=49788&view=diff
==============================================================================
--- trunk/src/scripting/lua.cpp (original)
+++ trunk/src/scripting/lua.cpp Tue Jun  7 17:26:57 2011
@@ -1616,6 +1616,23 @@
        lua_setfield(L, -2, "keep");
        lua_pushinteger(L, info.gives_healing());
        lua_setfield(L, -2, "healing");
+
+       return 1;
+}
+
+/**
+ * Gets time of day information.
+ * - Ret 1: table.
+ */
+static int intf_get_time_of_day(lua_State *L)
+{
+       const time_of_day& tod = resources::tod_manager->get_time_of_day();
+
+       lua_newtable(L);
+       lua_pushstring(L, tod.id.c_str());
+       lua_setfield(L, -2, "id");
+       lua_pushinteger(L, tod.lawful_bonus);
+       lua_setfield(L, -2, "lawful_bonus");
 
        return 1;
 }
@@ -3158,14 +3175,6 @@
        return 0;
 }
 
-// A function that pushesh the current ToD on the stack
-static int intf_get_tod(lua_State *L)
-{
-       std::string tod = resources::tod_manager->get_time_of_day().id;
-       lua_pushstring(L, tod.c_str());
-       return 1;
-}
-
 LuaKernel::LuaKernel(const config &cfg)
        : mState(luaL_newstate()), level_(cfg)
 {
@@ -3216,7 +3225,7 @@
                { "get_sides",                &intf_get_sides                },
                { "get_terrain",              &intf_get_terrain              },
                { "get_terrain_info",         &intf_get_terrain_info         },
-               { "get_time_of_day",          &intf_get_tod                  },
+               { "get_time_of_day",          &intf_get_time_of_day          },
                { "get_unit",                 &intf_get_unit                 },
                { "get_units",                &intf_get_units                },
                { "get_variable",             &intf_get_variable             },


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to