# Game Grove level help

**URL:** <https://discourse.codecombat.com/t/game-grove-level-help/13134>\
**Category:** Archmage\
**Created:** [December 5, 2017, 9:01pm UTC](https://discourse.codecombat.com/t/game-grove-level-help/13134 "2017-12-05T21:01:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_F\_Morrison\_Jr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/john_f_morrison_jr/32/7149_2.png) [@John\_F\_Morrison\_Jr](https://discourse.codecombat.com/u/John_F_Morrison_Jr)\
**Post date:** [December 5, 2017, 9:01pm UTC](https://discourse.codecombat.com/t/game-grove-level-help/13134/1 "2017-12-05T21:01:53Z")

</div>

I have converted this to LUA as much as I know. I have marked where in the code I do not understand. It is always hard to figure out if I need a . or : when converting to lua. Any help will be appreciated.

```python
-- Make your own game by changing the code below!
-- Spawn a maze. Change the number for a different maze!
game:spawnMaze(1)

-- Spawn a hero with spawnHeroXY()
local player = game:spawnHeroXY("raider", 28, 60)
player.attackDamage = 10
player.maxHealth = 200

-- Add at least one goal!
game:addCollectGoal()
game:addSurviveGoal()

-- Spawn some things to collect!
game:spawnXY("gem", 28, 27)
-- You need a key to collect a locked chest.
game:spawnXY("locked-chest", 44, 28)
game:spawnXY("silver-key", 43, 60)
game:spawnXY("potion-medium", 60, 12)

-- Spawn some enemies!
local s1 = game:spawnXY("skeleton", 43, 50)
s1.behavior = "Defends"
local s2 = game:spawnXY("skeleton", 49, 59)
s2.behavior = "Defends"
game:spawnXY("lightstone", 60, 44)

local gen = game:spawnXY("generator", 26, 44)
gen.spawnType = "munchkin"
gen.spawnDelay = 4

game:spawnXY("munchkin", 28, 19)
-- Ogre Spear Throwers have a ranged attack!
game:spawnXY("thrower", 48, 28)
-- This gargoyle shoots fire!
local spewer = game:spawnXY("fire-spewer", 37, 12)
spewer.direction = "horizontal"

-- Track plays and ogres defeated in the database.

--[[Need Help with what below this
--]]
db.add("plays", 1)
ui.track(db, "plays")
ui.track(db, "defeated")

function onVictory() 
    db.add("defeated", game.defeated)
end

game:on("victory", onVictory)

```

 ![Game Grove](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/ae025fe4e963dcd5266336afcc690479fecc5c3e.PNG)

---

<div class="post-metadata">

**Author:** ![Keir\_G](https://avatars.discourse-cdn.com/v4/letter/k/e56c9b/32.png) [@Keir\_G](https://discourse.codecombat.com/u/Keir_G)\
**Post date:** [December 9, 2017, 6:34am UTC](https://discourse.codecombat.com/t/game-grove-level-help/13134/2 "2017-12-09T06:34:47Z")

</div>

1st…  
local player = game:spawnHeroXY(“raider”, 28, 60)

“raider” needs to be changed to “champion”, the "champion I believe is intended to be the default hero for most of the last levels of the game development area. Though it can be changed to anyone of the hero’s the knight, guardian, captain, duelist, goliath, or champion.

As for the area your having trouble with code whats in ( )…

(  
– Track plays and ogres defeated in the database.  
db:add(“plays”, 1)  
ui:track(db, “plays”)  
ui:track(db, “defeated”)  
)

This properly adds and shows the plays, but the defeated amount never changes so I am not sure whats with that a the moment.

I am having a problem with the tail end of the code with getting …  
ReferenceError: onVictory is not defined.  
Same error on Persistence pays level.

---

<div class="post-metadata">

**Author:** ![SuperSmacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/supersmacker/32/8385_2.png) [@SuperSmacker](https://discourse.codecombat.com/u/SuperSmacker)\
**Post date:** [December 9, 2017, 3:55pm UTC](https://discourse.codecombat.com/t/game-grove-level-help/13134/3 "2017-12-09T15:55:15Z")

</div>

Always post code with `Beautiful Formatting`  
i.e.

```python
while True:
    hero.say("HI!")

```

---

<div class="post-metadata">

**Author:** ![John\_F\_Morrison\_Jr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/john_f_morrison_jr/32/7149_2.png) [@John\_F\_Morrison\_Jr](https://discourse.codecombat.com/u/John_F_Morrison_Jr)\
**Post date:** [December 12, 2017, 4:47pm UTC](https://discourse.codecombat.com/t/game-grove-level-help/13134/4 "2017-12-12T16:47:01Z")

</div>

> [@Keir\_G](#):
>
> champion

Thank you. for onVictory not defined: In my example I forgot to add local in front of function. It should be.

```python
local function onVictory() 
    db:add("defeated", game.defeated)
end

```
