Added wesnoth.get_time_of_day() Lua function
This commit is contained in:
parent
5c7d4d64e5
commit
a1600a1a63
3 changed files with 14 additions and 0 deletions
|
@ -294,6 +294,7 @@ function my_ai:do_moves()
|
|||
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)
|
||||
|
|
|
@ -248,6 +248,7 @@ static int cfun_ai_execute_recall(lua_State *L)
|
|||
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 @@ static int cfun_ai_get_villages_per_scout(lua_State *L)
|
|||
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 @@ lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engin
|
|||
|
||||
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 @@ lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engin
|
|||
{ "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 },
|
||||
|
|
|
@ -3158,6 +3158,14 @@ static int impl_theme_items_set(lua_State *L)
|
|||
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 @@ LuaKernel::LuaKernel(const config &cfg)
|
|||
{ "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 },
|
||||
|
|
Loading…
Add table
Reference in a new issue