# Salted Earth - Please Help

**URL:** <https://discourse.codecombat.com/t/salted-earth-please-help/9982>\
**Category:** Uncategorized\
**Created:** [December 16, 2016, 2:58pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982 "2016-12-16T14:58:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kid\_Midas](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kid\_Midas](https://discourse.codecombat.com/u/Kid_Midas)\
**Post date:** [December 16, 2016, 2:58pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/1 "2016-12-16T14:58:00Z")

</div>

while True:  
enemy = hero.findNearestEnemy()  
if enemy.type == “munchkin” or enemy.type == “thrower”:  
hero.attack(enemy)  
item = hero.findNearestItem()  
# Check the item type to make sure the hero doesn’t pick up poison!  
# Look for types: ‘gem’ and 'coin’  
if item.type == “gem” or item.type == “coin”:  
hero.move(item.pos)  
This is my code for this level. For some reason it doesn’t work giving me the error : "TypeError: Can’t read protected property : move  
Can someone help me with this?

---

<div class="post-metadata">

**Author:** ![xExaviorx](https://avatars.discourse-cdn.com/v4/letter/x/45deac/32.png) [@xExaviorx](https://discourse.codecombat.com/u/xExaviorx)\
**Post date:** [December 16, 2016, 3:00pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/2 "2016-12-16T15:00:16Z")

</div>

Hey! Can you format your code please? Highlight it and press the " \< / \> " button before posting. Or you can put 2 backticks before and after your code.

---

<div class="post-metadata">

**Author:** ![Ty\_Ler](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ty_ler/32/5322_2.png) [@Ty\_Ler](https://discourse.codecombat.com/u/Ty_Ler)\
**Post date:** [December 16, 2016, 9:37pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/4 "2016-12-16T21:37:43Z")

</div>

I believe its 3 before and after.

---

<div class="post-metadata">

**Author:** ![xExaviorx](https://avatars.discourse-cdn.com/v4/letter/x/45deac/32.png) [@xExaviorx](https://discourse.codecombat.com/u/xExaviorx)\
**Post date:** [December 17, 2016, 12:53am UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/5 "2016-12-17T00:53:48Z")

</div>

Either way works mate ^^

---

<div class="post-metadata">

**Author:** ![Kid\_Midas](https://avatars.discourse-cdn.com/v4/letter/k/b782af/32.png) [@Kid\_Midas](https://discourse.codecombat.com/u/Kid_Midas)\
**Post date:** [December 17, 2016, 7:56pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/6 "2016-12-17T19:56:14Z")

</div>

```python
while True:
    enemy = hero.findNearestEnemy()
    if enemy.type == "munchkin" or enemy.type == "thrower":
        hero.attack(enemy)
    item = hero.findNearestItem()
    # Check the item type to make sure the hero doesn't pick up poison!
    # Look for types: 'gem' and 'coin'
    if item.type == "gem" or item.type == "coin":
        hero.move(item.pos)

```

Like this?

---

<div class="post-metadata">

**Author:** ![Ty\_Ler](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ty_ler/32/5322_2.png) [@Ty\_Ler](https://discourse.codecombat.com/u/Ty_Ler)\
**Post date:** [December 17, 2016, 8:19pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/7 "2016-12-17T20:19:16Z")

</div>

Chnaces are your not wearing the right equipment. You need the shoes that allow the property of move. Try using moveXY their might be a chance thats what your current shoes can access. And yes thats much better.😁

---

<div class="post-metadata">

**Author:** ![lzwerzx](https://avatars.discourse-cdn.com/v4/letter/l/22d042/32.png) [@lzwerzx](https://discourse.codecombat.com/u/lzwerzx)\
**Post date:** [June 30, 2017, 9:43pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/8 "2017-06-30T21:43:31Z")

</div>

You forgot to add x and y. it should look like this:  
while True:  
enemy = hero.findNearestEnemy()  
if enemy.type == “munchkin” or enemy.type == “thrower”:  
hero.attack(enemy)  
item = hero.findNearestItem()  
# Check the item type to make sure the hero doesn’t pick up poison!  
# Look for types: ‘gem’ and 'coin’  
if item.type == “coin” or item.type == “gem”:  
hero.moveXY(item.pos.x, item.pos.y)

---

<div class="post-metadata">

**Author:** ![Hellenar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellenar/32/9100_2.png) [@Hellenar](https://discourse.codecombat.com/u/Hellenar)\
**Post date:** [June 30, 2017, 10:04pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/9 "2017-06-30T22:04:09Z")

</div>

Eventually the hero will be able to access boots that have `move` property, which is good if the hero wants to follow moving objects as it does not always return a fixed coordinate. (Also good for just moving to coins, gems or potions if you want to save time and space.)  
Also try not to revive dead threads in the future 🙂

---

<div class="post-metadata">

**Author:** ![colapssicle](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@colapssicle](https://discourse.codecombat.com/u/colapssicle)\
**Post date:** [December 4, 2017, 4:36pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/10 "2017-12-04T16:36:44Z")

</div>

Is This JavaScript? If’s usually have brackets and parenthesis around them @Kid_Midas

---

<div class="post-metadata">

**Author:** ![colapssicle](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@colapssicle](https://discourse.codecombat.com/u/colapssicle)\
**Post date:** [December 4, 2017, 4:40pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/11 "2017-12-04T16:40:19Z")

</div>

I am having the same problem as @Kid_Midas is. Halp 😖

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 4, 2017, 5:06pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/12 "2017-12-04T17:06:18Z")

</div>

Did you check your equipment to see if the boots you’re currently equipped with have the move property? There is going to be two different ways to write the code for this; one is for move property and the other is for the moveXY property. It just depends on which boots you’re using.

BTW, the previous posts are in Python, not Java.

---

<div class="post-metadata">

**Author:** ![kaiduck](https://avatars.discourse-cdn.com/v4/letter/k/8491ac/32.png) [@kaiduck](https://discourse.codecombat.com/u/kaiduck)\
**Post date:** [December 4, 2017, 8:45pm UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/13 "2017-12-04T20:45:51Z")

</div>

By the way, if you do have boots with move, then they have to be equipped.

---

<div class="post-metadata">

**Author:** ![agarionotpro](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/agarionotpro/32/7218_2.png) [@agarionotpro](https://discourse.codecombat.com/u/agarionotpro)\
**Post date:** [December 20, 2017, 3:16am UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/14 "2017-12-20T03:16:04Z")

</div>

By move so you mean “MoveXY” or Move right/left/up/down?

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 20, 2017, 11:49am UTC](https://discourse.codecombat.com/t/salted-earth-please-help/9982/15 "2017-12-20T11:49:29Z")

</div>

@agarionotpro

Using the moveXY method is different than the move method.

Using moveXY means, go to this coordinate and don’t do anything else until you get there.

Using the move method means take a single step toward a position and then iterate through the code again looking for something else to do. If there is nothing else to do, then take another single step toward that position again. This is particularly handy when moving to a position that is not constant (like another character that is moving).

You need to equip with boots that offer the move method if you’re going to use it.

`
