(1) added wesnoth.is_debug_mode();

(2) disabled the LuaAI debug library usage for non-debug launch modes
This commit is contained in:
Dmitry Kovalenko 2012-04-16 20:49:02 +00:00
parent 04f9899eb6
commit f54f2b0e75
3 changed files with 23 additions and 4 deletions

View file

@ -1,9 +1,14 @@
--! #textdomain wesnoth
return { -- TODO: Disable the ability to register this library
-- if wesnoth started without -d argument
return {
init = function(ai)
if (not wesnoth.is_debug_mode()) then
wesnoth.message("LuaAI Error", "The LuaAI debug library is only available in debug mode")
return
end
ai.debug = {}
function ai.debug.get_dst_src()
@ -27,4 +32,5 @@ return { -- TODO: Disable the ability to register this library
end
end
}

View file

@ -257,12 +257,13 @@ local my_ai = { }
-- data = { ["pers"] = 5, ["stringg"] = "stringg" }
local ai_stdlib = wesnoth.require('ai/lua/stdlib.lua');
ai_stdlib.init(ai)
ai_stdlib.init(ai, true)
function my_ai:stage_hello()
local debug_utils = wesnoth.require "~add-ons/Wesnoth_Lua_Pack/debug_utils.lua"
local mm = ai.get_dst_src()
wesnoth.message("dbg mode: " .. tostring(wesnoth.is_debug_mode()))
--local mm = ai.get_dst_src()
--ai.debug.get_dst_src()
--ai.debug.get_enemy_dst_src()
debug_utils.dbms(ai,false,"variable",false)

View file

@ -1980,6 +1980,17 @@ static int intf_debug(lua_State* L)
return 1;
}
/**
* Returns a bool value indicating whether the
* game is launched in debug mode
* - Ret 1: bool
*/
static int intf_is_debug_mode(lua_State *L)
{
lua_pushboolean(L, game_config::debug);
return 1;
}
/**
* Removes all messages from the chat window.
*/
@ -3479,6 +3490,7 @@ LuaKernel::LuaKernel(const config &cfg)
{ "get_variable", &intf_get_variable },
{ "get_village_owner", &intf_get_village_owner },
{ "highlight_hex", &intf_highlight_hex },
{ "is_debug_mode", &intf_is_debug_mode },
{ "is_enemy", &intf_is_enemy },
{ "match_location", &intf_match_location },
{ "match_side", &intf_match_side },