- added new lua function to display playername:

getPlayerName(i)
This commit is contained in:
Mark Vejvoda
2012-01-05 00:45:17 +00:00
parent 6f924b310d
commit e351def1cb
6 changed files with 77 additions and 0 deletions

View File

@@ -176,6 +176,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
luaScript.registerFunction(getGameWon, "gameWon");
luaScript.registerFunction(getSystemMacroValue, "getSystemMacroValue");
luaScript.registerFunction(getPlayerName, "getPlayerName");
luaScript.registerFunction(loadScenario, "loadScenario");
@@ -1032,6 +1033,12 @@ const string ScriptManager::getSystemMacroValue(const string &key) {
return world->getSystemMacroValue(key);
}
const string ScriptManager::getPlayerName(int factionIndex) {
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->getPlayerName(factionIndex);
}
void ScriptManager::loadScenario(const string &name, bool keepFactions) {
//printf("[%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
@@ -1484,6 +1491,12 @@ int ScriptManager::getSystemMacroValue(LuaHandle* luaHandle) {
return luaArguments.getReturnCount();
}
int ScriptManager::getPlayerName(LuaHandle* luaHandle) {
LuaArguments luaArguments(luaHandle);
luaArguments.returnString(thisScriptManager->getPlayerName(luaArguments.getInt(-1)));
return luaArguments.getReturnCount();
}
int ScriptManager::getUnitCount(LuaHandle* luaHandle){
LuaArguments luaArguments(luaHandle);
luaArguments.returnInt(thisScriptManager->getUnitCount(luaArguments.getInt(-1)));