Announcement

Collapse
No announcement yet.

Python - Can't get player start plot

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Everything is finally working! Thanks for all the help!

    Here is the functioning code snippet in case anyone else needs to do the same thing. It finds the human player, their starting plot, and then generates a scout, settler, and warrior at the starting plot.

    Code:
    	def setup(self):
    		# find human player
    		bComputer = True
    		iCount = 0
    		while bComputer:
    			pPlayer = gc.getPlayer(iCount)
    			if (pPlayer.isHuman()):
    				bComputer = False
    				pHuman = pPlayer
    
    				# get human player starting location
    				tStartPlot = pHuman.getStartingPlot()
    
    				# add additional units to the human player's civ
    				self.makeUnit(iSettler, pHuman, tStartPlot, 1)
    				self.makeUnit(iScout, pHuman, tStartPlot, 1)
    				self.makeUnit(iWarrior, pHuman, tStartPlot, 1)
    			else:
    				iCount = iCount + 1
    			
    
    
    
    	#################
    	### Utilities ###
    	#################
    
    	def makeUnit(self, iUnit, pPlayer, tPlot, iNum):
    		# display welcome message
    		self.displayTestPopup()
    		#Makes unit type iUnit for player pPlayer at tPlot
    		pPlayer.initUnit(iUnit, tPlot.getX(), tPlot.getY(), UnitAITypes.NO_UNITAI)
    Enjoy!

    Comment

    Working...
    X