Author: nephro
Date: Tue Jun 7 14:02:03 2011
New Revision: 49787
URL: http://svn.gna.org/viewcvs/wesnoth?rev=49787&view=rev
Log:
Added wesnoth.get_time_of_day() Lua function
Modified:
trunk/data/ai/scenarios/scenario-lua-ai.cfg
trunk/src/ai/lua/core.cpp
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=49787&r1=49786&r2=49787&view=diff
==============================================================================
--- trunk/data/ai/scenarios/scenario-lua-ai.cfg (original)
+++ trunk/data/ai/scenarios/scenario-lua-ai.cfg Tue Jun 7 14:02:03 2011
@@ -294,6 +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())
my_leader = wesnoth.get_units({canrecruit = true, side = ai.side})[1]
x,y = ai.suitable_keep(my_leader)
Modified: trunk/src/ai/lua/core.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/ai/lua/core.cpp?rev=49787&r1=49786&r2=49787&view=diff
==============================================================================
--- trunk/src/ai/lua/core.cpp (original)
+++ trunk/src/ai/lua/core.cpp Tue Jun 7 14:02:03 2011
@@ -248,6 +248,7 @@
return transform_ai_action(L,recall_result);
}
+// Aspect section
static int cfun_ai_get_aggression(lua_State *L)
{
double aggression = get_readonly_context(L).get_aggression();
@@ -364,6 +365,7 @@
lua_pushnumber(L, villages_per_scout);
return 1;
}
+// End of aspect section
lua_ai_context* lua_ai_context::create(lua_State *L, char const *code,
ai::engine_lua *engine)
{
@@ -384,6 +386,7 @@
static luaL_reg const callbacks[] = {
{ "attack", &cfun_ai_execute_attack
},
+ // Aspects
{ "get_aggression", &cfun_ai_get_aggression
},
{ "get_attack_depth", &cfun_ai_get_attack_depth
}, // { "get_", &cfun_ai_get_}, little template # TODELETE
{ "get_caution", &cfun_ai_get_caution
},
@@ -400,6 +403,7 @@
{ "get_support_villages", &cfun_ai_get_support_villages
},
{ "get_village_value", &cfun_ai_get_village_value
},
{ "get_villages_per_scout", &cfun_ai_get_villages_per_scout
},
+ // End of aspects
{ "move", &cfun_ai_execute_move_partial
},
{ "move_full", &cfun_ai_execute_move_full
},
{ "recall", &cfun_ai_execute_recall
},
Modified: trunk/src/scripting/lua.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/scripting/lua.cpp?rev=49787&r1=49786&r2=49787&view=diff
==============================================================================
--- trunk/src/scripting/lua.cpp (original)
+++ trunk/src/scripting/lua.cpp Tue Jun 7 14:02:03 2011
@@ -3158,6 +3158,14 @@
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)
{
@@ -3208,6 +3216,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_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