[SOLVED] - JS - Salted Earth

Hello community,
I encounter an issue with my code for Salted Earth in JS mode.

I really can’t understand where is the default in my code:

while(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy.type == "munchkin" || enemy.type == "thrower") {
        hero.attack(enemy);
    }
    var item = hero.findNearestItem();
    // Vérifie quel est le type de l'objet pour être sûre que le héro ne ramasse pas du poison !
    // Si le type d'objet est une "gem" ou une "coin":
    if (item == "Gold Coin" || item == "gem") {
        hero.say("hello");
        // Ensuite déplace toi et ramasse le:
        hero.moveXY(item.pos.x, item.pos.y);
    }

In verification of item type, if I write just coin, I never go and pick it.
If I type gold coin, I go and pick just the first time.
I tried to get the information about the item passing it in
hero.say(item);
each new coin has a different tag: gold coin 1, and i suppose gold coin 2 and then.

So, is my code wrong, or there is a default in the game?

thank you for your help.

instead of if (item==)
try:

if (item.type=="gold-coin" || item.type=="gem"{
whatever here
}

perfect.
thks @riticmaster908

Please mark ritic’s post as a solution if your problem is solved

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.