This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
billysback's profile picture

syntax error

Started by billysback, 11 November 2012 - 11:10 AM
billysback #1
Posted 11 November 2012 - 12:10 PM
The error is on this line:

local choice, price, stuff = getShop(selc, data)

getShop is:

local choices = {}
    choices = {
                 {"|==========|",
                  "| REPAIR 1 |",
                  "|==========|"},
                 {"|============|",
                  "| REPAIR ALL |",
                  "|============|"},
                 {"|==============|",
                  "|UPGRADE ARMOUR|",
                  "|==============|"},
                 {"|==============|",
                  "|UPGRADE DAMAGE|",
                  "|==============|"},
                 {"|================|",
                  "|UPGRADE ACCURACY|",
                  "|================|"},
                 {"|=============|",
                  "|UPGRADE SPEED|",
                  "|=============|"},
                 {"|=================|",
                  "|UPGRADE WEP-SPEED|",
                  "|=================|"},
                 {"|==============|",
                  "|UPGRADE HEALTH|",
                  "|==============|"},
                 {"|===================|",
                  "|UPGRADE EVASIVENESS|",
                  "|===================|"},
              }
    prices = {
                1,
                shp.stat.maxhealth - shp.stat.health,
                150,
                250,
                400,
                100,
                300,
                100,
                350
             }
    
    local pixels = {}
    local choice = choices[sel]
    local price = prices[sel]
    for y=1,#choice do
        local l = choice[i]
        for x=1,string.len(l) do
            local ch = string.sub(l, x, x)
            pixels[#pixels + 1] = art.setPixel(x, y, nil, colors.blue, ch)
        end
    end    
    local pixarr = art.createPixelArray(pixels)
    return choice, price, pixarr

I am so close to releasing this FTL like clone, this is almost the only thing left until I can release it D:)
PixelToast #2
Posted 11 November 2012 - 12:18 PM
i dont see anything wrong
can we see the full error and all the code before the error
billysback #3
Posted 11 November 2012 - 12:19 PM
The function that the getShop() is in:

local doShop(selc)
    local choice, price, pixarr = getShop(selc, data)
    if data.money - price < 0 then
        msg = "Not enough money!"
    else
        data.money = data.money - price
        if selc == 1 then
            if data.stats.health + 1 > data.stats.maxhealth then
                data.money = data.money + price
            else
                data.stats.health = data.stats.health + 1
            end
        elseif selc == 2 then
            data.stats.health = data.stats.maxhealth
        elseif selc == 3 then data.stats.armour = data.stats.armour + 1
        elseif selc == 4 then data.stats.damage = data.stats.armour + 1
        elseif selc == 5 then data.stats.accuracy = data.stats.accuracy + 1
        elseif selc = 6 then data.stats.speed = data.stats.speed + 1
        elseif selc = 7 then data.stats.wepspeed = data.stats.wepspeed + 1
        elseif selc = 8 then data.stats.health = data.stats.health + 1
        elseif selc = 9 then data.stats.evasivness = data.stats.evasivness + 1 end
    end
end
billysback #4
Posted 11 November 2012 - 12:20 PM
EDIT: nvm, I forgot to put function…
PixelToast #5
Posted 11 November 2012 - 03:16 PM
i can not emagine a more epic fail

elseif selc = 9 then
= is the assignment operator
not the equal operator