Ogre Encampment Help Please!


#1

Hi, I need help solving this puzzle. I am using python and would appreciate any help given for python coding.
Thanks!


#2

By the way, here is the code that I am using:

loop:
Enemy == self.findNearestEnemy()
if enemy:
self.attack(enemy)
self.attack(enemy)
if not enemy:
self.attack(“Chest”)

For the coding that is bold in italics, it keeps telling me that “Enemy” is not defined.
Can somebody please help?
Thanks!


#3

use 1 =
= for assigning variables
== for comparing two statements


#5

Sorry, meant to put this in and ask, how does this help define “Enemy”? :confused:


#6

Enemy is a variable:
You save somthing as a variable by using =

enemy = self.findNearestEnemy() saves the result of self.findNearestEnemy() as enemy

If you try to use the variable before you have saved something as the variable the computer will say the variable is undefined. It would like be trying to open a computer file before you saved it.

Variables