LuaAI: created some debug methods
ai.debug will be registered by stdlib on demand
This commit is contained in:
parent
267e05f04d
commit
8f99e3f995
4 changed files with 32 additions and 4 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
return {
|
||||
|
||||
init = function(ai)
|
||||
init = function(ai, dbg)
|
||||
|
||||
-- Initialize the cache system for LuaAI context
|
||||
local cache = wesnoth.require("ai/lua/cache.lua")
|
||||
|
@ -85,6 +85,11 @@ return {
|
|||
end
|
||||
|
||||
-- End of proxy function section
|
||||
|
||||
if dbg then
|
||||
local debug = wesnoth.require("ai/lua/debug.lua")
|
||||
debug.init(ai)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
@ -262,9 +262,10 @@ ai_stdlib.init(ai)
|
|||
|
||||
function my_ai:stage_hello()
|
||||
local debug_utils = wesnoth.require "~add-ons/Wesnoth_Lua_Pack/debug_utils.lua"
|
||||
|
||||
|
||||
--debug_utils.dbms(mm[2].movements,false,"variable",false)
|
||||
local mm = ai.get_dst_src()
|
||||
--ai.debug.get_dst_src()
|
||||
--ai.debug.get_enemy_dst_src()
|
||||
debug_utils.dbms(ai,false,"variable",false)
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -1116,6 +1116,10 @@ void readonly_context_impl::recalculate_move_maps() const
|
|||
}
|
||||
}
|
||||
move_maps_valid_ = true;
|
||||
|
||||
// invalidate lua cache
|
||||
dst_src_valid_lua_ = false;
|
||||
src_dst_valid_lua_ = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1126,6 +1130,10 @@ void readonly_context_impl::recalculate_move_maps_enemy() const
|
|||
enemy_possible_moves_ = moves_map();
|
||||
calculate_possible_moves(enemy_possible_moves_,enemy_srcdst_,enemy_dstsrc_,true);
|
||||
move_maps_enemy_valid_ = true;
|
||||
|
||||
// invalidate lua cache
|
||||
dst_src_enemy_valid_lua_ = false;
|
||||
src_dst_enemy_valid_lua_ = false;
|
||||
}
|
||||
|
||||
void readonly_context_impl::set_dst_src_valid_lua()
|
||||
|
|
|
@ -798,6 +798,18 @@ static int cfun_ai_is_src_dst_enemy_valid(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int cfun_ai_recalculate_move_maps(lua_State *L)
|
||||
{
|
||||
get_readonly_context(L).recalculate_move_maps();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cfun_ai_recalculate_move_maps_enemy(lua_State *L)
|
||||
{
|
||||
get_readonly_context(L).recalculate_move_maps_enemy();
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engine_lua *engine)
|
||||
{
|
||||
int res_ai = luaL_loadstring(L, code);//stack size is now 1 [ -1: ai_context]
|
||||
|
@ -822,6 +834,8 @@ lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engin
|
|||
{ "get_new_src_dst", &cfun_ai_get_srcdst },
|
||||
{ "get_new_enemy_dst_src", &cfun_ai_get_enemy_dstsrc },
|
||||
{ "get_new_enemy_src_dst", &cfun_ai_get_enemy_srcdst },
|
||||
{ "recalculate_move_maps", &cfun_ai_recalculate_move_maps },
|
||||
{ "recalculate_enemy_move_maps",&cfun_ai_recalculate_move_maps_enemy },
|
||||
// End of move maps
|
||||
// Goals and targets
|
||||
{ "get_targets", &cfun_ai_get_targets },
|
||||
|
|
Loading…
Add table
Reference in a new issue