Uhh... this error confuses me...

Started by QuickMuffin8782, Jun 21, 2020, 03:36 pm

Previous topic - Next topic

QuickMuffin8782

Jun 21, 2020, 03:36 pm Last Edit: Jun 21, 2020, 03:49 pm by QuickMuffin8782
I have this error: .eRageAPI:101: unexpected symbol near end
And this: .eRageAPI:50: attempt to index local file (a nil value)

And the code lies here:
Code Select
active = false
level = 0

os.pullEvent = os.pullEventRaw

wide, high = term.getSize()

local function isActive()
    return active
end

local function startRage()
    active = true
    level = 0   
end

function randomColor(text)
    i = math.random(1,10)
    color = {
        [1] = colors.red,
        [2] = colors.orange,
        [3] = colors.yellow,
        [4] = colors.green,
        [5] = colors.lime,
        [6] = colors.cyan,
        [7] = colors.lightBlue,
        [8] = colors.blue,
        [9] = colors.purple,
        [10] = colors.magentat
    }
    if text then
        term.setTextColor(color[i])
    else
        term.setBackgroundColor(color[i])
    end
end

function centerText(msg, y)
    local w, _ = term.getSize()
    term.setCursorPos((w / 2) - (msg:len() / 2), y)
    write(msg)
end

function writeToStartup(txt)
local num = 0
    local file = fs.open("startup", "r")
     -- table to store lines
    local tLines = {}
    -- get a line from the file
    local sLine = file:readLine()
    while sLine do
    -- store it in the table
        table.insert(tLines, sLine)
num = num + 1
    -- get the next line
        sLine = file:readLine()
    end
    -- get the text to write
    -- check if the line number is greater than the file lines
    if nLine > #tLines then
      -- add some empty lines
       for i = #tLines, nLine - 1 do
                tLines[i] = ""
       end
        end
num = num + 1
      -- set the line to the new text
        tLines[num] = text
      -- open the file to write
        local file = fs.open("startup", "w")
      -- check if the file is open
        if file then
      -- write every line
          for _,line in ipairs(tLines) do
                file:writeLine(line)
          end
      file.close()
        end
end

function randomPopup() -- Only when CCWindows is installed.
if win then
if math.random(1,100) <= 10 then
local randomPopupNum = math.random(1,5)
if randomPopupNum == 1 then
    self:getDesktop():msgBox("The army of E", "You will be taken down mister!")
elseif randomPopupNum == 2 then
    self:getDesktop():msgBox(os.getComputerLabel() .. "'s message", "Oh hell naw! EEEE EEEE EEE EEEE E EEEE? Oh my goodness!")
elseif randomPopupNum == 3 then
self:getDesktop():msgBox("The E police", "E police: EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n\nThey grab you and sends you to a cell with a lot of bois who say EEEEEEEEEEEEE all the time, so do the E police. You wonder why they are doing it.")
elseif randomPopupNum == 4 then
self:getDesktop():msgBox("Next-E", "E EoE EEur EEck!")
elseif randomPopupNum == 5 then
self:getDesktop():msgBox("E RAGING PEOPLE", "Ohh, suffer the pain of this!")
end
end
end
end

writeToStartup("os.loadAPI(\".eRage/.eRageAPI\")")

while true do
    if active then
        level = level + 1
        repeatNum = (level / 10) + 1
        curX, curY = term.getCursorPos()
        oldBack = term.getBackgroundColor()
        oldText = term.getTextColour()
        oldBlink = term.getCursorBlink()
        term.setCursorBlink(false)
        if level > 100 then
            level = 100
        end
        repeat
            randomNum = math.random(1,4)
            term.setCursorPos(math.random(1, wide), math.random(1, high))
            if math.random(1,2) == 1 then
                term.setBackgroundColor(oldBack)
                randomColor(true)
            else
                term.setTextColor(oldBack)
                randomColor(false)
            end
            if randomNum == 1 then
                write("E")
            elseif randomNum == 2 then
                write(string.char(math.random(129,159)))
            elseif randomNum == 3 then
                if math.random(1,2) == 1 then
                    write(string.char(math.random(200,203)))
                else
                    write(string.char(math.random(232,235)))
                end
            elseif randomNum == 4 then
                write(string.char(math.random(24,27)))
            else
                write("e")
            end
        until repeatNum < 1
        if level >= 26 and level <= 50 then
            scroll(math.random(-1,1))
        end
        if level >= 51 and level <= 75 then
            scroll(math.random(-2,2))
        end
        if level >= 76 then
            scroll(math.random(-3,3))
            centerText(string.char(7) .. "E RAGE!" .. string.char(7), math.random(1,(high / 2) + math.random(-1,1)))
        end
        term.setBackgroundColor(oldBack)
        term.setTextColor(oldText)
        term.setCursorPos(x,y)
        term.setCursorBlink(oldBlink)
    end
    sleep(1 - (level / 100))
end
Any help with this? I am terribly confused on this error, and I want to make a fun program that messes with your computer
Sonic Classic applications afoot!

Lupus590

fs.open returns file handles which use . not :