OzzyKP
Emperor
I'm making my first attempt to do something in Python and... I'm lost.
I'd like to have a worker created, owned by a particular AI civ when a corporation spreads to a city. My hope is to have corporations spread & operate independently, and have them build rail lines on their own.
I have never done anything in Python before (or much coding period), so I'd love some advice & help. This is the best I've come up with:
At this point I was just hoping to spawn a unit to show that I could make Python do anything at all, I hadn't even begun to worry about assigning it to a certain player. I copy and pasted pieces from other mods, and I've tried it a few different ways, but nothing ever happens. Clearly I'm missing some basic understanding of python.
On the plus side, nothing crashes! It just doesn't do anything.
I'd like to have a worker created, owned by a particular AI civ when a corporation spreads to a city. My hope is to have corporations spread & operate independently, and have them build rail lines on their own.
I have never done anything in Python before (or much coding period), so I'd love some advice & help. This is the best I've come up with:
Code:
def onCorporationSpread(self, argsList):
'Corporation Has Spread to a City'
iCorporation, iOwner, pSpreadCity = argsList
iRailCorp = gc.getInfoTypeForString('CORPORATION_1')
player = PyPlayer(iOwner)
if iCorporation == iRailCorp
CyInterface().addImmediateMessage("Railroad Corp has expanded into your city and will get to work building the rails", "")
newUnit = playerY.initUnit(gc.getInfoTypeForString('UNIT_WORKER'), UnitAITypes.NO_UNITAI)
At this point I was just hoping to spawn a unit to show that I could make Python do anything at all, I hadn't even begun to worry about assigning it to a certain player. I copy and pasted pieces from other mods, and I've tried it a few different ways, but nothing ever happens. Clearly I'm missing some basic understanding of python.
On the plus side, nothing crashes! It just doesn't do anything.