# LUA code patch for - Forest - Seek-and-Hide - posted intro/ overview / and default code

**URL:** https://discourse.codecombat.com/t/lua-code-patch-for-forest-seek-and-hide-posted-intro-overview-and-default-code/9422
**Category:** Artisan
**Created:** [October 22, 2016, 1:23am UTC](https://discourse.codecombat.com/t/lua-code-patch-for-forest-seek-and-hide-posted-intro-overview-and-default-code/9422 "2016-10-22T01:23:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Harry\_the\_Wanderer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/harry_the_wanderer/32/5369_2.png) [@Harry\_the\_Wanderer](https://discourse.codecombat.com/u/Harry_the_Wanderer)
#### Post date: [October 22, 2016, 1:23am UTC](https://discourse.codecombat.com/t/lua-code-patch-for-forest-seek-and-hide-posted-intro-overview-and-default-code/9422/1 "2016-10-22T01:23:33Z")

</div>

**_Default code for LUA - - Copy-Paste into the editor to start_**

* * *

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

local checkTakeHide = function(item)
    if item then
        -- 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)
        
    end
end    

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

```

* * *

_ **Overview for LUA** _

* * *
You can use a function parameter as a variable inside the function. But also you can add additional instructions, which are not related to the parameter. For example:

```python
local checkAndHit = function(unit)
    if unit then
        hero:attack(unit)
        -- An additional instruction without 'unit'.
        hero:say("I'm dangerous!")
    end
end

```

Also, don’t forget you can call the same function as many times as you want.

```python
hero:moveXY(10, 10)
local enemy = hero:findNearestEnemy()
checkAndHit(enemy)
-- Next point.
hero:moveXY(70, 10)
enemy = hero:findNearestEnemy()
checkAndHit(enemy)

```

* * *

_ **Please feel free to use this to help you with the level until the patch is applied.** _

---

<div class="post-metadata">

### Author: ![Sam\_Rosenfeld](https://avatars.discourse-cdn.com/v4/letter/s/77aa72/32.png) [@Sam\_Rosenfeld](https://discourse.codecombat.com/u/Sam_Rosenfeld)
#### Post date: [November 8, 2016, 8:18pm UTC](https://discourse.codecombat.com/t/lua-code-patch-for-forest-seek-and-hide-posted-intro-overview-and-default-code/9422/2 "2016-11-08T20:18:52Z")

</div>

My student is trying to do the “Seek-and-Hide” lesson in Lua but every time he starts the level he gets the following error message( I’m hoping that your solution above helps him out):

“Expected “#”, “(”, “-”, “–”, “–[”, “…”, “0”, “;”, “[”, “break”, “debugger”, “do”, “false”, “for”, “function”, “if”, “local”, “nil”, “not”, “repeat”, “return”, “that”, “true”, “while”, “{”, [\r\t\n], [’’], [’], [0-9] or end of imput but “/” found.”

 ![](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/0/0275c6138804492cfad663728974c5cb2d78f4f1.png)
