(btw I am new to this site not the game)
I have been playing this for a while now but I got stuck at the bookkeeper level, I keep trying different codes but every time the game says that I have reached the hard limit of 3000000 or that there is a infant loop. Please help!
This is what I have so far for this attempt:
loop:
enemy = self.findNearest(self.findEnemies())
if enemy:
self.attack(enemy)
if self.now() > 15:
break
Tell Naria how many enemies you defeated.
self.say(“I got 4”)
while self.now() < 30:
if item:
item = self.findNearestitems()
x = item.pos.x
y = item.pos.y
self.moveXY(x, y)
(I hope that I am not a idiot because I cant find any info about this on how to complete it)
As @Hinkle and @AdrianCgw mentioned. Please format your code according to the FAQ. It helps us to be able to read your code more easily. And also if there is any more info you can give, please provide.
i’m sorry may be my explanation in the bottom if mesage is not evident (my english is not native). firstly :
I mean after each attack means after each hitting with the sword even if enemy wasn’t killed but only its health only decreased hero goes to Naria. If i want to make hero go to tell Nira only if enemy killed what would be the correct code?
second and more important because it is condition if level to pass it :
The result of :
this.say(""+defeated+"");
not correct, because i may kill 2 or 3 enemies but hero says 0 or 1 .
Thank you very much for your attention. Yes I investigated it too and now hero is not going after each attack to tell_Naria
But the second problem is counting. After hero killed all enemies it still says 0 killed .
help me, please … … my character just run to the archer without attacking. Here is my code
time = self.now()
enemy = self.findNearestEnemy()
enemykilled = 0
coin = self.findNearestItem()
coincollected = 0
if time < 15:
if enemy:
self.attack(enemy)
enemykilled += 1
else:
self.shield()
if time > 15:
self.moveXY(59, 33)
self.say(enemykilled)
if time < 30 and time > 15:
if coin:
coinX = coin.pos.x
coinY = coin.pos.y
self.moveXY(coinX, coinY)
coincollected += 1
self.moveXY(59, 33)
self.say(coincollected)
if time < 45 and time > 30:
enemykilled = 0
self.attack(enemy)
enemykilled += 1
self.moveXY(59, 33)
self.say(enemykilled)
What’s wrong?
thanks
Check the other code posted in this thread. In pseudocode you must try to do this:
initialize the number of enemies killed to 0
loop:
find enemy
if enemy:
while enemy_not_dead_yet:
attack enemy
#end of while - enemy just died here
increment the number of killed enemies
#end of enemy code
get current time
if time > 15 break
#end of loop
go to Naria
tell her number of enemies killed
Errors in your code:
you do not have a loop
you are mixing the initializations (enemykiled=0) which must be executed only once,
with the updates (time=self.now(), enemy=self.find …) which need to executed for each new loop
}
// Tell Naria how many enemies you defeated.
enemy_killed=0;
loop {
if (this.killedenemy)
this.enemykilled++;
}
// Collect coins until the clock reaches 30 seconds.
var item = this.findNearestItem();
// Tell Naria how much gold you collected.
// Fight enemies until the clock reaches 45 seconds.
// Remember to reset the count of defeated enemies!