My code does not work. In the lua version of this level, functions are not documented yet and the sample code has not been translated to lua. This aside, I have attempted to figure out how to use functions from external sources. the issues i am having are that my character does not respond at all. Apparently I don’t know how to call functions in lua. Here is my code, can any more experienced players and coders tell me what i’m doing wrong?
local function pickUpNearestCoin()
local items = self.findItems()
local nearestCoin = self.findNearest(items)
if nearestCoin then
self:move(nearestCoin.pos)
end
end
-- This function has your hero summon a soldier.
local function summonSoldier()
-- Fill in code here to summon a soldier if you have enough gold.
if self.gold > self:costOf("soldier") then
self:summon("soldier")
else
end
-- pass
end
-- This function commands your soldiers to attack their nearest enemy.
local function commandSoldiers()
local friends = self:findFriends()
for x=1, #friends do
local soldier = friends[x]
local enemy = soldier:findNearestEnemy()
if enemy then
self:command(soldier, "attack", enemy)
end
end
end
loop
-- In your loop, you can "call" the functions defined above.
-- The following line causes the code inside the "pickUpNearestCoin" function to be executed.
pickUpNearestCoin()
self:summonSoldier()
self:commandSoldiers()
end
can anyone see what i’m doing wrong? Thanks in advance.