Orge Gorge Gouger Help

Could anyone tell me why this code works

    while self.now() < 20: 
    self.say("message")
    while self.gold < 60:
        item = self.findNearest(self.findItems())
        coins = self.findItems()
        coinIndex = 0
        while coinIndex < len(coins):
            coin = coins[coinIndex]
            if coin.value > 1:
                self.moveXY(coin.pos.x, coin.pos.y)
            coinIndex += 1
    
    while self.pos.x > 16:
        self.move({'x': 15, 'y': 38})
        
    self.buildXY("fence", 21, 37)    

while this code doesn’t

    while self.now() < 20: 
    
        while self.gold < 60:
            item = self.findNearest(self.findItems())
            coins = self.findItems()
            coinIndex = 0
            while coinIndex < len(coins):
                coin = coins[coinIndex]
                if coin.value > 1:
                    self.moveXY(coin.pos.x, coin.pos.y)                
                coinIndex += 1
    
    while self.pos.x > 16:
        self.move({'x': 15, 'y': 38})
        
    self.buildXY("fence", 21, 37)    

For some reason the self.say makes it work. why is this

Please read the FAQ, so that your code is properly formatted. I added the ```s to your post but your formatting looks wrong, please check and fix it.

Well, what happens when you run the first code? What happens when you run the second?

The second code has no visible affect on the hero

Are there any errors that come out when you run it?

So my code works but it isn’t good enough to get the 60 coin bonus. Is it okay to post my code? Can anyone help me with this?

Really, the only thing you can do at this point is to find a better coin collecting function, and maybe increase your speed.

right now im using the compound boots which are the fastest availible. my coin collecting function finds the highest value coin and if its less than 15 distance it will go to that coin, otherwise it will just go to the closest. the most coins ive been able to get is like 43. any suggestions?

I tried the first code (the working one) and it said that i needed a string to build a fire-trap, bear-trap, decoy, or arrow-tower. Any suggestions? Solutions?

If you have the Stone Builder’s Hammer, it can’t build fences. Only the wooden ones can do so.

Yeah, I figured that out, like, 20 minutes after I posted the question. XD Thanks anyway, though!