# Help on seek and hide

**URL:** <https://discourse.codecombat.com/t/help-on-seek-and-hide/26837>\
**Category:** Level Help\
**Created:** [January 20, 2021, 4:11pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837 "2021-01-20T16:11:13Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 4:11pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/1 "2021-01-20T16:11:13Z")

</div>

This is my code:

```python
# Gather 4 lightstones to defeat the Brawler.
# If you find a lightstone, hide.

def checkTakeHide(item):
    if item:
        # The item is here, so take it.
        hero.moveXY(item.pos.x, item.pos.y)
        # Then move to the center of the camp (40, 34)
        hero.moveXY(40, 34)

# Move to the top right X mark.
hero.moveXY(54, 53)
hero.moveXY(68, 56)
 # Search for a lightstone there.
while true:
    lightstone = hero.findNearestItem()
     # Call checkTakeHide with the argument: lightstone
    checkTakeHide(lightstone)
        # Move to the top left mark.
    
    # Search for a lightstone.
    
    # Call the checkTakeHide function.
    # Pass in the result of your search as an argument.
    
    

```

---

<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:** [January 20, 2021, 4:12pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/2 "2021-01-20T16:12:16Z")

</div>

> [@phantomofthedark2](#):
>
> ```python
> while True:
> # Move to the top right X mark.
> hero.moveXY(54, 53)
> hero.moveXY(68, 56)
> break
> 
> ```

Delete the while True loop here. Also delete the break.

---

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 4:14pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/3 "2021-01-20T16:14:09Z")

</div>

I did that but then he just stands there

---

<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:** [January 20, 2021, 4:15pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/4 "2021-01-20T16:15:15Z")

</div>

Once you do that, what is your code?

---

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 4:16pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/5 "2021-01-20T16:16:11Z")

</div>

```python
while True:
    # Search for a lightstone there.
    lightstone = hero.findNearestItem()
    # Call checkTakeHide with the argument: lightstone
    checkTakeHide(lightstone)
    # Move to the top left mark.
    
    # Search for a lightstone.

```

[/quote]

---

<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:** [January 20, 2021, 4:18pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/6 "2021-01-20T16:18:47Z")

</div>

What is your full code (including the function)?

---

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 4:25pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/7 "2021-01-20T16:25:31Z")

</div>

```python
# Gather 4 lightstones to defeat the Brawler.
# If you find a lightstone, hide.

def checkTakeHide(item):
    if item:
        # The item is here, so take it.
        hero.moveXY(item.pos.x, item.pos.y)
        # Then move to the center of the camp (40, 34)
        hero.moveXY(40, 34)

# Move to the top right X mark.
hero.moveXY(54, 53)
hero.moveXY(68, 56)
 # Search for a lightstone there.
while true:
    lightstone = hero.findNearestItem()
     # Call checkTakeHide with the argument: lightstone
    checkTakeHide(lightstone)
        # Move to the top left mark.
    
    # Search for a lightstone.
    
    # Call the checkTakeHide function.

```

---

<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:** [January 20, 2021, 4:29pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/8 "2021-01-20T16:29:42Z")

</div>

Delete the two move statements outside the while true loop. In your while true loop, move to (68,56) and check for the nearest item. Then use checkTakeHide(item) replacing item with your variable. Do the same thing again within your while true loop except this time instead of moving to (68,56), move to the coordinates (12,56).

---

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 4:31pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/9 "2021-01-20T16:31:30Z")

</div>

I cant get there()()

---

<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:** [January 20, 2021, 4:33pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/10 "2021-01-20T16:33:44Z")

</div>

What do you mean you can’t get there. Can you take a screenshot and post your updated code?

---

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 4:40pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/11 "2021-01-20T16:40:04Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/7/6/76e00b8b75be2b0bfc65f29ce2e0d2d52b48af99.jpeg)

---

<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:** [January 20, 2021, 4:45pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/12 "2021-01-20T16:45:11Z")

</div>

Try using a different hero.

---

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 4:51pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/13 "2021-01-20T16:51:52Z")

</div>

Ok i got there but then i just stay still

---

<div class="post-metadata">

**Author:** ![Greninja714](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/greninja714/32/17914_2.png) [@Greninja714](https://discourse.codecombat.com/u/Greninja714)\
**Post date:** [January 20, 2021, 6:23pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/14 "2021-01-20T18:23:23Z")

</div>

I think I found the problem. You need to put your 2 moveXY commands inside the while true loop, like this:

```python
while true:
moveXY(54, 53)
lightstone = hero.findNearestItem()
checkTakeHide(lightstone)
moveXY(68, 56)
lightstone = hero.findNearestItem()
checkTakeHide(lightstone)

```

---

<div class="post-metadata">

**Author:** ![Greninja714](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/greninja714/32/17914_2.png) [@Greninja714](https://discourse.codecombat.com/u/Greninja714)\
**Post date:** [January 20, 2021, 6:23pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/15 "2021-01-20T18:23:51Z")

</div>

and include the function  
(sorry for my bad formatting)

---

<div class="post-metadata">

**Author:** ![phantomofthedark2](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/phantomofthedark2/32/17807_2.png) [@phantomofthedark2](https://discourse.codecombat.com/u/phantomofthedark2)\
**Post date:** [January 20, 2021, 6:29pm UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/16 "2021-01-20T18:29:30Z")

</div>

Thanks. But the first move xy was unnecessary. After you take that out you put move 12 56.

---

<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:** [January 21, 2021, 6:29am UTC](https://discourse.codecombat.com/t/help-on-seek-and-hide/26837/17 "2021-01-21T06:29:34Z")

</div>

Closed on January 21, 2021, 6:29am UTC

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