- added new lua method so users can create units without spacing rules:
createUnitNoSpacing
This commit is contained in:
parent
2b50070249
commit
9d6607a051
|
@ -109,6 +109,7 @@ void ScriptManager::init(World* world, GameCamera *gameCamera){
|
|||
luaScript.registerFunction(clearDisplayText, "clearDisplayText");
|
||||
luaScript.registerFunction(setCameraPosition, "setCameraPosition");
|
||||
luaScript.registerFunction(createUnit, "createUnit");
|
||||
luaScript.registerFunction(createUnitNoSpacing, "createUnitNoSpacing");
|
||||
luaScript.registerFunction(destroyUnit, "destroyUnit");
|
||||
luaScript.registerFunction(giveKills, "giveKills");
|
||||
luaScript.registerFunction(morphToUnit, "morphToUnit");
|
||||
|
@ -566,6 +567,12 @@ void ScriptManager::createUnit(const string &unitName, int factionIndex, Vec2i p
|
|||
world->createUnit(unitName, factionIndex, pos);
|
||||
}
|
||||
|
||||
void ScriptManager::createUnitNoSpacing(const string &unitName, int factionIndex, Vec2i pos){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%s] factionIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,unitName.c_str(),factionIndex);
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
world->createUnit(unitName, factionIndex, pos, false);
|
||||
}
|
||||
|
||||
void ScriptManager::destroyUnit(int unitId){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%d]\n",__FILE__,__FUNCTION__,__LINE__,unitId);
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
|
@ -1127,6 +1134,18 @@ int ScriptManager::createUnit(LuaHandle* luaHandle) {
|
|||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::createUnitNoSpacing(LuaHandle* luaHandle) {
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] unit [%s] factionIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,luaArguments.getString(-3).c_str(),luaArguments.getInt(-2));
|
||||
|
||||
thisScriptManager->createUnitNoSpacing(
|
||||
luaArguments.getString(-3),
|
||||
luaArguments.getInt(-2),
|
||||
luaArguments.getVec2i(-1));
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
int ScriptManager::destroyUnit(LuaHandle* luaHandle) {
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ private:
|
|||
void DisplayFormattedLangText(const char *fmt,...);
|
||||
void setCameraPosition(const Vec2i &pos);
|
||||
void createUnit(const string &unitName, int factionIndex, Vec2i pos);
|
||||
void createUnitNoSpacing(const string &unitName, int factionIndex, Vec2i pos);
|
||||
|
||||
void destroyUnit(int unitId);
|
||||
void giveKills(int unitId, int amount);
|
||||
|
@ -286,6 +287,7 @@ private:
|
|||
static int clearDisplayText(LuaHandle* luaHandle);
|
||||
static int setCameraPosition(LuaHandle* luaHandle);
|
||||
static int createUnit(LuaHandle* luaHandle);
|
||||
static int createUnitNoSpacing(LuaHandle* luaHandle);
|
||||
|
||||
static int destroyUnit(LuaHandle* luaHandle);
|
||||
static int giveKills(LuaHandle* luaHandle);
|
||||
|
|
|
@ -834,7 +834,7 @@ void World::morphToUnit(int unitId,const string &morphName,bool ignoreRequiremen
|
|||
}
|
||||
}
|
||||
|
||||
void World::createUnit(const string &unitName, int factionIndex, const Vec2i &pos) {
|
||||
void World::createUnit(const string &unitName, int factionIndex, const Vec2i &pos, bool spaciated) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unitName [%s] factionIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,unitName.c_str(),factionIndex);
|
||||
|
||||
if(factionIndex < factions.size()) {
|
||||
|
@ -863,7 +863,7 @@ void World::createUnit(const string &unitName, int factionIndex, const Vec2i &po
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit created for unit [%s]\n",__FILE__,__FUNCTION__,__LINE__,unit->toString().c_str());
|
||||
|
||||
if(placeUnit(pos, generationArea, unit, true)) {
|
||||
if(placeUnit(pos, generationArea, unit, spaciated)) {
|
||||
unit->create(true);
|
||||
unit->born();
|
||||
scriptManager->onUnitCreated(unit);
|
||||
|
|
|
@ -216,7 +216,7 @@ public:
|
|||
|
||||
//scripting interface
|
||||
void morphToUnit(int unitId,const string &morphName,bool ignoreRequirements);
|
||||
void createUnit(const string &unitName, int factionIndex, const Vec2i &pos);
|
||||
void createUnit(const string &unitName, int factionIndex, const Vec2i &pos,bool spaciated = true);
|
||||
void givePositionCommand(int unitId, const string &commandName, const Vec2i &pos);
|
||||
void giveAttackCommand(int unitId, int unitToAttackId);
|
||||
void giveProductionCommand(int unitId, const string &producedName);
|
||||
|
|
Loading…
Reference in New Issue
Block a user