# CodeCombat - Salted Earth\[SOLVED\]

**URL:** <https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997>\
**Category:** Level Help\
**Created:** [May 19, 2021, 1:00pm UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997 "2021-05-19T13:00:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![King\_RaiderVII](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/king_raidervii/32/22594_2.png) [@King\_RaiderVII](https://discourse.codecombat.com/u/King_RaiderVII)\
**Post date:** [May 19, 2021, 1:00pm UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997/1 "2021-05-19T13:00:26Z")

</div>

Why won’t my hero go get the coins? Help, please!

---

<div class="post-metadata">

**Author:** ![King\_RaiderVII](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/king_raidervii/32/22594_2.png) [@King\_RaiderVII](https://discourse.codecombat.com/u/King_RaiderVII)\
**Post date:** [May 19, 2021, 1:01pm UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997/2 "2021-05-19T13:01:43Z")

</div>

My code:

```python

# Ogres are attacking a nearby settlement!
# Be careful, though, for the ogres have sown the ground with poison.
# Gather coins and defeat the ogres, but avoid the burls and poison!

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!
    # If the item's type is "gem" or "coin":
    if item.type == "gem" or item.type == "coin":
        # Then move and pick it up:
        item.x == x
        item.y == y
        hero.moveXY(x, y)

```

---

<div class="post-metadata">

**Author:** ![King\_RaiderVII](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/king_raidervii/32/22594_2.png) [@King\_RaiderVII](https://discourse.codecombat.com/u/King_RaiderVII)\
**Post date:** [May 19, 2021, 1:04pm UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997/3 "2021-05-19T13:04:09Z")

</div>

Could @thebagel or @Deadpool198 help me? (They’re the only ones I basically know)

---

<div class="post-metadata">

**Author:** ![King\_RaiderVII](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/king_raidervii/32/22594_2.png) [@King\_RaiderVII](https://discourse.codecombat.com/u/King_RaiderVII)\
**Post date:** [May 19, 2021, 1:14pm UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997/4 "2021-05-19T13:14:09Z")

</div>

Could somebody PLEASE help me?

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [May 19, 2021, 1:55pm UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997/5 "2021-05-19T13:55:59Z")

</div>

> [@King\_RaiderVII](#):
>
> ```python
> item.x == x
> item.y == y
> 
> ```

Make that:

```python
x = item.pos.x
y = item.pos.y

```

You are creating a variable and assigning that variable a value. When you do that, you need to use one equal sign. The double equal sign is to check if something is equal to something else. The other way you could do this is to just move like this:

```python
hero.moveXY(item.pos.x, item.pos.y)

```

---

<div class="post-metadata">

**Author:** ![King\_RaiderVII](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/king_raidervii/32/22594_2.png) [@King\_RaiderVII](https://discourse.codecombat.com/u/King_RaiderVII)\
**Post date:** [May 19, 2021, 6:30pm UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997/6 "2021-05-19T18:30:47Z")

</div>

Thank You! It worked!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [May 20, 2021, 6:31am UTC](https://discourse.codecombat.com/t/codecombat-salted-earth-solved/28997/7 "2021-05-20T06:31:32Z")

</div>

Closed on May 20, 2021, 6:31am UTC

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