Game Grove level help


#1

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.

-- 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)


#2

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.


#3

Always post code with Beautiful Formatting
i.e.

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

#4

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

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