- added more lua debug info

This commit is contained in:
SoftCoder
2013-12-30 14:00:04 -08:00
parent 450e23c85c
commit 5613b0739e
3 changed files with 18 additions and 2 deletions

View File

@@ -454,6 +454,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
loadGame(this->rootNode); loadGame(this->rootNode);
this->rootNode = NULL; this->rootNode = NULL;
if(LuaScript::getDebugModeEnabled() == true) printf("Calling onLoad luaSavedGameData.size() = %d\n",(int)luaSavedGameData.size());
luaScript.beginCall("onLoad"); luaScript.beginCall("onLoad");
luaScript.endCall(); luaScript.endCall();
} }
@@ -1983,11 +1985,18 @@ void ScriptManager::addMessageToQueue(ScriptManagerMessage msg) {
} }
void ScriptManager::storeSaveGameData(string name, string value) { void ScriptManager::storeSaveGameData(string name, string value) {
if(LuaScript::getDebugModeEnabled() == true) printf("storeSaveGameData name [%s] value [%s]\n",name.c_str(),value.c_str());
luaSavedGameData[name] = value; luaSavedGameData[name] = value;
} }
string ScriptManager::loadSaveGameData(string name) { string ScriptManager::loadSaveGameData(string name) {
return luaSavedGameData[name]; string value = luaSavedGameData[name];
if(LuaScript::getDebugModeEnabled() == true) printf("loadSaveGameData result name [%s] value [%s]\n",name.c_str(),value.c_str());
return value;
} }
// ========================== lua callbacks =============================================== // ========================== lua callbacks ===============================================
@@ -4895,6 +4904,8 @@ void ScriptManager::saveGame(XmlNode *rootNode) {
luaScript.beginCall("onSave"); luaScript.beginCall("onSave");
luaScript.endCall(); luaScript.endCall();
if(LuaScript::getDebugModeEnabled() == true) printf("After onSave luaSavedGameData.size() = %d\n",(int)luaSavedGameData.size());
for(std::map<string, string>::iterator iterMap = luaSavedGameData.begin(); for(std::map<string, string>::iterator iterMap = luaSavedGameData.begin();
iterMap != luaSavedGameData.end(); ++iterMap) { iterMap != luaSavedGameData.end(); ++iterMap) {
@@ -5021,6 +5032,9 @@ void ScriptManager::loadGame(const XmlNode *rootNode) {
// LuaScript luaScript; // LuaScript luaScript;
vector<XmlNode *> savedGameDataItemNodeList = scriptManagerNode->getChildList("SavedGameDataItem"); vector<XmlNode *> savedGameDataItemNodeList = scriptManagerNode->getChildList("SavedGameDataItem");
if(LuaScript::getDebugModeEnabled() == true) printf("In loadGame savedGameDataItemNodeList.size() = %d\n",(int)savedGameDataItemNodeList.size());
for(unsigned int i = 0; i < savedGameDataItemNodeList.size(); ++i) { for(unsigned int i = 0; i < savedGameDataItemNodeList.size(); ++i) {
XmlNode *node = savedGameDataItemNodeList[i]; XmlNode *node = savedGameDataItemNodeList[i];
string key = node->getAttribute("key")->getValue(); string key = node->getAttribute("key")->getValue();

View File

@@ -56,6 +56,8 @@ public:
~LuaScript(); ~LuaScript();
static void setDebugModeEnabled(bool value) { debugModeEnabled = value; } static void setDebugModeEnabled(bool value) { debugModeEnabled = value; }
static bool getDebugModeEnabled() { return debugModeEnabled; }
static void setDisableSandbox(bool value) { disableSandbox = value; } static void setDisableSandbox(bool value) { disableSandbox = value; }
void loadCode(string code, string name); void loadCode(string code, string name);