- added new lua method to get system macro values:

dofile(getSystemMacroValue("$SCENARIO_PATH") .. "unit.ai.class.lua")
This commit is contained in:
Mark Vejvoda
2012-01-05 00:04:55 +00:00
parent 2e6fcb2d4a
commit 6f924b310d
4 changed files with 38 additions and 0 deletions

View File

@@ -175,6 +175,8 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
luaScript.registerFunction(getGameWon, "gameWon");
luaScript.registerFunction(getSystemMacroValue, "getSystemMacroValue");
luaScript.registerFunction(loadScenario, "loadScenario");
//load code
@@ -1024,6 +1026,12 @@ int ScriptManager::getUnitCountOfType(int factionIndex, const string &typeName)
return world->getUnitCountOfType(factionIndex, typeName);
}
const string ScriptManager::getSystemMacroValue(const string &key) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
ScriptManager_STREFLOP_Wrapper streflopWrapper;
return world->getSystemMacroValue(key);
}
void ScriptManager::loadScenario(const string &name, bool keepFactions) {
//printf("[%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
@@ -1470,6 +1478,12 @@ int ScriptManager::getLastAttackingUnitId(LuaHandle* luaHandle) {
return luaArguments.getReturnCount();
}
int ScriptManager::getSystemMacroValue(LuaHandle* luaHandle) {
LuaArguments luaArguments(luaHandle);
luaArguments.returnString(thisScriptManager->getSystemMacroValue(luaArguments.getString(-1)));
return luaArguments.getReturnCount();
}
int ScriptManager::getUnitCount(LuaHandle* luaHandle){
LuaArguments luaArguments(luaHandle);
luaArguments.returnInt(thisScriptManager->getUnitCount(luaArguments.getInt(-1)));