My code is this:
# This level shows how to define your own functions. # The code inside a function is not executed immediately. It's saved for later. # This function has your hero collect the nearest coin. # This function has your hero summon a soldier. def summonSoldier(): # Fill in code here to summon a soldier if you have enough gold if self.gold >= self.costOf("soldier"): self.summon("soldier") else: break # This function commands your soldiers to attack their nearest enemy. def commandSoldiers(): soldiers = self.findFriends() if soldiers: for soldier in self.findFriends(): target = soldier.findNearest(soldier.findEnemies()) if target: self.command(soldier, "attack", target) def pickUpNearestCoin(): while self.gold < self.costOf("soldier"): coin = self.findNearest(self.findItems()) self.moveXY(coin.pos.x, coin.pos.y) loop: # In your loop, you can "call" the functions defined above. # The following line causes the code inside the "pickUpNearestCoin" function to be executed. pickUpNearestCoin() # Call summonSoldier here summonSoldier() #Call commandSoldiers here commandSoldiers()
I get an error on, “if target” (line 17), which is the most ANNOYING of them all, “Attempted to assign readonly property.” The reason it is so annoying? I don’t even know what it means and how to fix it!
Even before I started getting this error, Tharin wouldn’t move after getting coins and summoning his first soldier. Besides the obvious gear (Boss Star, Progammaticon IV), I have:
Emperor’s Glove (yeah, that’s right),
Crude Telephoto Glasses,
Quartz Sense Stone,
Rusted Iron Breastplate,
Rusted Iron Helmet,
and the Steel Striker.
What should I do?