Library Tactician Problems


I am having problems with Library Tactician, I have done exactly what they told me to do (except the part that says “-- Create a variable containing your archers.” which I don’t understand because that variable already exists…) for some reason my soldiers still cannot survive in spite of following their instructions to the letter (along with trying various things of my own) here is my code;

-- Hushbaum has been ambushed by ogres!
-- She is busy healing her soldiers, you should command them to fight!
-- The ogres will send more troops if they think they can get to Hushbaum or your archers, so keep them inside the circle!

-- Soldiers spread out in a circle and defend.
local function commandSoldier(soldier, soldierIndex, numSoldiers)
    local angle = Math.PI * 2 * soldierIndex / numSoldiers
    local defendPos = {"x"= 41, "y"= 40}
    defendPos.x = defendPos.x + 10 * Math.cos(angle)
    defendPos.y = defendPos.y + 10 * Math.sin(angle)
    self:command(soldier, "defend", defendPos)

-- Find the strongest target (most health)
-- This function returns something! When you call the function, you will get some value back.
local function findStrongestTarget()
    local mostHealth = 0
    local bestTarget = nil
    local enemies = self:findEnemies()
    -- Figure out which enemy has the most health, and set bestTarget to be that enemy.
    for _, enemy in pairs(enemies) do
        if not bestTarget or > mostHealth then
            bestTarget = enemy
            mostHealth =
    -- Only focus archers' fire if there is a big ogre.
    if bestTarget and > 15 then
        return bestTarget
        return nil

-- If the strongestTarget has more than 15 health, attack that target. Otherwise, attack the nearest target.
local function commandArcher(archer)
    local nearest = archer:findNearest(archer:findEnemies())
    if archerTarget then
        self:command(archer, "attack", archerTarget)
    elseif nearest then
        self:command(archer, "attack", nearest)

local archerTarget = nil
local archers = self:findByType("archer")
local soldiers = self:findByType("soldier")
-- Create a variable containing your archers.

    -- If archerTarget is defeated or doesn't exist, find a new one.
    if not archerTarget then 
        archerTarget = findStrongestTarget()
    if archerTarget then
        if <= 0 then 
            -- Set archerTarget to be the target that is returned by findStrongestTarget()
            archerTarget = findStrongestTarget()
    for i, soldier in pairs(soldiers) do
        commandSoldier(soldier, i, #soldiers)

    -- use commandArcher() to command your archers
    for _, archer in pairs(archers) do


Solved…Had to re-write my code in Javascript(Python didn’t work either, I didn’t try coffee script)…apparently the lua interpreter is too slow to run the code. :frowning:


@deeredman1991 I had to change the source code and then submit about 100 times :angry: