loop:
flagGreen = self.findFlag("green")
if flagGreen:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fence", 36, 30)
flagBlack = self.findFlag("black")
if flagBlack:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fire-trap", x, y)
flagViolet = self.findFlag("violet")
if flagBlack:
x = flag.pos.x
y = flag.pos.y
self.moveXY(x, y)
loop:
flagGreen = self.findFlag("green")
if flagGreen:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fence", x, y)
flagBlack = self.findFlag("black")
if flagBlack:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fire-trap", x, y)
flagViolet = self.findFlag("violet")
if flagViolet:
x = flag.pos.x
y = flag.pos.y
self.moveXY(x, y)
I PMed you how to write code so we can read it. Please fix your previous posts.
I overlooked that you never call self.pickUp(flag) This method takes one of the three methods above and removes that flag from the gameboard (so you can reuse it).
After each action (build, build or move) you should pickup the flag.
loop:
flagGreen = self.findFlag("green")
if flagGreen:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fence", x, y)
self.pickUpFlag()
flagBlack = self.findFlag("black")
if flagBlack:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fire-trap", x, y)
self.pickUpFlag()
flagViolet = self.findFlag("violet")
if flagViolet:
x = flag.pos.x
y = flag.pos.y
self.moveXY(x, y)
self.pickUpFlag()
What exactly did not work? Do you get an error? If yes, which one? If not: What happens differently from what you expect to happen?
Also a common source of problem: Check that you have a hammer and a flag equipped. There is really no reason to ever unequip the flag, but maybe you have a sword in hand. With a sword you can obviously not build a fence or a fire-trap.
loop:
flagGreen = self.findFlag("green")
if flagGreen:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fence", x, y)
self.pickUp(flagGreen)
flagBlack = self.findFlag("black")
if flagBlack:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fire-trap", x, y)
self.pickUp(flagBlack)
flagViolet = self.findFlag("violet")
if flagViolet:
x = flag.pos.x
y = flag.pos.y
self.moveXY(x, y)
self.pickUp(flagViolet)
loop:
self.pickUpFlag(flagGreen)
self.pickUpFlag(flagBlack)
self.pickUpFlag(flagViolet)
if flagGreen:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fence", x, y)
self.pickUpFlag(flagGreen)
if flagBlack:
x = flag.pos.x
y = flag.pos.y
self.buildXY("fire-trap", x, y)
self.pickUpFlag(flagBlack)
if flagViolet:
x = flag.pos.x
y = flag.pos.y
self.moveXY(x, y)
self.pickUpFlag(flagViolet)
change flag to flagGreen (or black/violet where appropriate)
I’ve never seen “self.findFlag(flagGreen)” so I wouldn’t have expected that to work.
If it does, cool!! if not then make it (replacing Color/“color” of course):
if flagBlack:
x = flag.pos.x ------>flagBlack.pos.x
y = flag.pos.y ---------------->flag.pos.y
self.buildXY(“fire-trap”, x, y)
self.pickUpFlag(flagBlack)
Help! My language is Python and here is my coding:
loop:
flag = self.findFlag()
if flag:
# How do we get fx and fy from the flag’s pos?
flagpos = flag.pos
fx = flag.pos.x
fy = flag.pos.y
self.buildXY(“fire-trap”, fx, fy)
self.pickUpFlag(flag)
else:
item = self.findNearestItem()
if item:
pos = item.pos
itemX = pos.x
itemY = pos.y
self.moveXY(itemX, itemY)
How do I make it do a firetrap? I’ve tried doing this but didn’t work:
loop:
flag = self.findFlag()
if flag:
# How do we get fx and fy from the flag’s pos?
flagpos = flag.pos
fx = flag.pos.x
fy = flag.pos.y
self.buildXY(“fire-trap”, fx, fy)
self.pickUpFlag(flag)
else:
item = self.findNearestItem()
if item:
pos = item.pos
itemX = pos.x
itemY = pos.y
self.moveXY(itemX, itemY)
loop:
flag = self.findFlag()
if flag:
# How do we get fx and fy from the flag’s pos?
flagpos = flag.pos
fx = flag.pos.x
fy = flag.pos.y
self.buildXY(“fence”, fx, fy)
self.pickUpFlag(flag)
else:
self.buildXY(“firetrap”, fx, fy)