Yeten
June 17, 2016, 6:24am
1
Hi for the level “A Fine Mint” i made a code for this level.
function pickUpCoin() {
var coin = hero.findNearestItem();
if(coin) {
hero.moveXY(coin.pos.x, coin.pos.y);
}
}
while(true) {
var enemy = hero.findNearestEnemy();
hero.attack(enemy);
pickUpCoin();
}
but the hero take to much time for pick the coin and the level fail and say “Ran out of time”
I don’t know what to do.
If u can help me =) and sorry for my english i’m a french =^-^=
Thanks :*
Yeten
June 17, 2016, 8:59pm
2
@Persephone hi I see u play on java script can you help me for my problems?
Serg
June 17, 2016, 9:05pm
3
Please surround your code in 3 backticks (`) above and below your code, so it will format correctly.
Yeten
June 17, 2016, 9:10pm
4
@Serg
‘’'function pickUpCoin() {
var coin = hero.findNearestItem();
if(coin) {
hero.moveXY(coin.pos.x, coin.pos.y);
}
}
while(true) {
var enemy = hero.findNearestEnemy();
hero.attack(enemy);
pickUpCoin();
}’’’
like that?
Serg
June 17, 2016, 9:18pm
5
Use ( ` ) instead of ( ’ ).
Yeten
June 17, 2016, 9:23pm
6
Oh sorry
var coin = hero.findNearestItem();
if(coin) {
hero.moveXY(coin.pos.x, coin.pos.y);
}
}
while(true) {
var enemy = hero.findNearestEnemy();
hero.attack(enemy);
pickUpCoin();
}```
Serg
June 17, 2016, 9:25pm
7
Almost, gotta use 3 of them above and below.
Yeten
June 17, 2016, 9:32pm
8
function pickUpCoin() {
var coin = hero.findNearestItem();
if(coin) {
hero.moveXY(coin.pos.x, coin.pos.y);
}
}
while(true) {
var enemy = hero.findNearestEnemy();
hero.attack(enemy);
pickUpCoin();
}
Yeten
June 17, 2016, 9:33pm
9
that’s what I do, but they disapear
Yeten
June 17, 2016, 9:54pm
10
@Serg I just want to advance through the levels.
my code works but is not optimal and I have two coins to pick up at the end but ran out of time… So i don’t know what to do…
Serg
June 17, 2016, 11:02pm
11
Hi, when I copy paste your code into the level, it doesn’t work. Are you sure you are copy-pasting correctly?
Yeten
June 18, 2016, 5:02am
12
Sure I’am…
On my code in the part of the "while(true)
for the “hero.attack(enemy);” there is a “play” button on the left and and a blue and white frame around the line of code.
Can I give you a screenshot or something like this?
Tom_H
June 18, 2016, 8:55pm
13
yes, you can drag a picture into the typing box:
like this
Yeten
June 18, 2016, 9:03pm
14
@Tom_H @Serg sorry for loosing your time I retry and now it’s working why? i don’t know but the champion don’t make the same decison O.o
Sorry…
1 Like
Tom_H
June 29, 2016, 7:06pm
15
I was having a problem with opening the full chest, but it is fixed now
1 Like