Decoy Drill : Python problem


#1

Hi,

I really don’t get what’s the problem with this code and would appreciate any help.
When I execute this code, I collect 8 to 15 coins and claim “4” to Naria who calls me a liar ( true )
If I delete the last 3 lines, character collects 8 to 15 coins, nothing more happens.
Any ideas ?

decoysBuilt = 0
self.gold = 0

loop:
item = self.findNearestItem()
# Loot the coin!
itemX = item.pos.x
itemY = item.pos.y
self.moveXY(itemX, itemY)
# Each decoy costs 25 gold. Use the Quartz Sense Stone
# to know when you have more than 25 gold with self.gold.
if self.gold >= 25:
self.buildXY(“decoy”, self.pos.x - 5, self.pos.y)
# Keep a count of decoys you built as you go along.
decoysBuilt = decoysBuilt +1
# Break out of the loop when you have built 4.
elif decoysBuilt == 4:
break
self.moveXY(14, 36)
self.say(“4”)


#2

I found the solution after all


#3

Hello, Kezako, and welcome. Please format your code according to the FAQ.

You make a variable self.gold. This is unnecessary. self.gold is already an attribute of your player.

Unfortunately, it is impossible to complete further analysis of your code until you format it properly. Please do so.


#4

Hello ChronistGilver,

Thanks for your answer; and I’ll keep that in mind for next time.