Ogre Gorge Gouger String Help


#1

When I wrote my code, I thought it was perfect, but every time I try it, when I have to build the fence, it says that I need a string to build it, and this has never happened before, and I don’t know how do do a string. Here is my code:

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)

Help please!


#2

It probably would be easier to understand if you formatted it as code: do it like this

but omit the space.

code goes here

`` `

but a string is something between quotes. Like the "message" you say.

#3

Hey,

I use the following code.

while self.pos.x > 16:
    # Retreat behind the fence
    self.moveXY(15, 38)
    self.buildXY("fence", 21, 38)

self.move() updates continuously. It is one of the things we supposed to be learning about in this level. If you use self.moveXY(), the move will complete before the interpreter(?) reads the next line of code.

George34


#4

Oooohhh! Thanks! I was able to get it working now!