Stack Traceback NIL?

I am following this tutorial:

http://codeatuts.blogspot.com/2012/07/tutorial-5-finite-state-machines.html

After gathering the code for the interlude 5, mentioned in the guide, now I am receiving the following error:

Main: 39: attempt to call a nil
value (global ‘drawButton’)
Stack traceback:
Main: 39: in function ‘draw’

I have attached the images of both the error and my code. I didn’t type it, I just copied and pasted what was on the site.

I also noticed someone else in the comments, below the lesson, has same issue I describe above. They mentioned it had something to do with spelling. Since I am new to all of this, I have no idea what would be wrong with the spelling, since I am copying and pasting the code.

Can anybody guide me on what I am supposed to do here?
I even checked the twinkle class (maybe error is in there?), but I have no idea what I am looking for.

Here are BOTH of my codes (Main & Twinkle Class):

MAIN CODE:

function setup()

    -- Keep track of Game State

    stateSplash = 0
    stateMenu = 1
    stateRun = 2
    stateWon = 3
    stateLost = 4

    gameState = stateSplash

    -- Create our menu button

    button = Button("    Start    ")
    button.action = function() buttonPressed() end

    -- Create the splash screen

    splashScreen = SplashScreen("Spacewar!", 10)

    -- Create the twinkling star background

    twinkleBackground = Twinkle(100)

end

function draw()

    -- Set background to black

    background(0, 0, 0)

    -- Draw the appropriate screen based on gameState

    if gameState == stateSplash then
        splashScreen: draw()
    elseif gameState == stateMenu then
        drawButton()
    elseif gameState == stateRun then
        twinkleBackground: draw()
    end

end


function buttonPressed()

    -- If the menu button is pressed we transition to the next state.

    gameState = stateRun

end

function fadeAnimationDone()

-- Call back function for Fader complete
-- Splash screen done, transition to menu state

gameState = stateMenu
end

TWINKLE CLASS CODE

Twinkle = class()

function Twinkle:init(numberOfStars)
    -- you can accept and set parameters here
    st = {}
    ns = numberOfStars -- number of stars
    for i = 1,ns do
        if math.random(2) == 1 then g = .25 else g = -.25 end
        i = 5 + (math.random(39)/4)
        st[i] = {g=g,l=l,x=math.random(WIDTH),y=math.random(HEIGHT)}
    end
end

function Twinkle:draw()
    -- Codea does not automatically call this method
pushStyle()
    rect(0,0,1,1)
    -- background(20, 46, 181, 255), this is Ipad41001 original background colour
    background(0, 0, 0)
    strokeWidth(3)
    lineCapMode(SQUARE)
    stroke(255, 255, 255, 255)
    fill(255, 255, 255, 255)
    for i = 1,ns do
        if st[i].l <= 5 and math.random(2) == 1 then st[i].g = .25
        elseif st[i].l >= 15 and math.random(2) == 1 then st[i].g = -.25 end
        st[i].l = st[i].l + st[i].g 
        ll = (15 - st[i].l)/2
        line(st[i].x-st[i].l,st[i].y,st[i].x+st[i].l,st[i].y)
        line(st[i].x,st[i].y-st[i].l,st[i].x,st[i].y+st[i].l)
        line(st[i].x-ll,st[i].y-ll,st[i].x+ll,st[i].y+ll)
        line(st[i].x+ll,st[i].y-ll,st[i].x-ll,st[i].y+ll)
        ellipse(st[i].x,st[i].y,6,6)
    end
    popStyle()
end

Ah I think you might need the code from the previous tutorial? There is a note in the tutorial you linked stating

The drawButton() and touched(touch) functions are unchanged from the previous tutorial. Modify buttonPressed so that it looks like this:

Ah, damn it. It’s me causing this unnecessary drama.

4 hours and I couldn’t detect that? Man, that’s super embarrassing.

What you said makes perfect sense. I did overwrite the existing code, by copying and pasting the new code he demonstrated in this current tutorial I am working on.

Wow @Simeon I truly apologize for pulling you off the work you are doing with Codea, The Shader and your family (saw the images you put up on twitter) beautiful child. I truly apologize man.

I will try better before you pulling you in again. Thank you.

@tactfulgamer no problem! This place is here so you can ask questions

RESOLVED!
Image attached. Wow! As a noob, this stuff really plays the minds perspective, goes deep into those channels, so many small things to stay on top of.

What a exercise for the mental synapses, keep those electric impulses moving! Image of resolved attached.

Original Post (Want to see my mistakes with my future improved self - will leave here)
Yep tried it. Still same issue. I will try to find the answer then share. At least I am learning “debugging” I think it’s called.

I’m down. New energy has entered me to fight this problem.

Awesome! Well done