Error Help!

I’m trying to combine a gravity moved paddle and a random falling object code, and I need help. The code just doesn’t seem to fit. Please help as soon as possible!
The Main Tab(Where the error is):

GravityX = 0
GravityY = 0 -- we are just using this for the watch()

-- Only support one orientation so you can tilt a lot
supportedOrientations(LANDSCAPE_LEFT)    

-- Use this function to perform your initial setup
function setup()
    displayMode(FULLSCREEN)
    pColor = color(67, 132, 128, 255)
    paddle = Paddle(WIDTH/2,5,80,15,pColor)    
    watch("Gravity.x")
    watch("Gravity.y")
end

 


-- This function gets called once every frame
function draw()
       background(0, 0, 0, 255)
    rect(WIDTH/2,HEIGHT - 20, 80,15)

    drawPaddle()

end

function drawPaddle()    
    paddle:draw()
end
    GravityX = Gravity.x -- a bit not nice
    GravityY = Gravity.y

    background(127, 127, 127, 255)

    stroke(255, 255, 255, 255)
    strokeWidth(15)

    lineCapMode(ROUND)

    pushMatrix()

    translate(WIDTH/2, HEIGHT/2)

    grav = vec2(Gravity.x * 300, Gravity.y * 300)

    --print(grav)

    line(0, 0, grav.x, grav.y)

    -- Arrowhead
    down = vec2(1, 0)
    orient = down:angleBetween(grav)

    pushMatrix()
    resetMatrix()

    translate(WIDTH/2,HEIGHT/2)
    translate(grav.x,grav.y)
    rotate(math.deg(orient))

    line(0, 0, -25, -20)
    line(0, 0, -25,  20)    

    popMatrix()
    -- End Arrowhead

    popMatrix()
 end

--Main

supportedOrientations(LANDSCAPE_ANY)

function setup()

    displayMode(FULLSCREEN)  
    objectTable = {}
    lastGenerated = ElapsedTime
    interval = 0.1
    num = 1  
    table.insert(objectTable,Objects(math.random(1,WIDTH-1),math.random(1,4),num))
   
end

function draw()
  
    spriteMode(CENTER)
    sprite("Documents:Black Background",WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
    pushStyle()

    spriteMode(CENTER)
    randomObjectGenerate(1)   
    popStyle()       
end

function randomObjectGenerate()
    for k,v in pairs(objectTable) do 
        v:draw()    
    end
    if ElapsedTime - lastGenerated > interval then
        lastGenerated = ElapsedTime
        num = num + 1
        table.insert(objectTable,Objects(math.random(1,WIDTH-1),math.random(1,4),num))   
    end
    for k,v in pairs(objectTable) do 
        if v.a.y < 0 or (v.a.x > WIDTH or v.a.x< 0) or v.a.info.id == 0 then
            table.remove(objectTable,k)
            v.a:destroy()
            v.a = nil
            v=nil           
        end             
    end
end


--Objects

Objects = class()

function Objects:init(x,cat,id)
    -- you can accept and set parameters here
    
    self.a = physics.body(CIRCLE,20)
    self.a.x = x
    self.a.y = HEIGHT
    self.a.gravityScale = 1
    self.a.restitution = 0.0
    self.a.interpolate = true
    self.asleepingAllowed = true
    self.flag = true
    self.category = cat
    self.a.info = {}
    self.a.info.id = id
    
end

function Objects:draw()
    pushMatrix()
    translate(self.a.x, self.a.y)
    if self.category == 1 then
        sprite("Cargo Bot:Condition Blue",0,0,50,50)
    elseif self.category == 2 then
        sprite("Cargo Bot:Condition Green",0,0,50,50)
    elseif self.category == 3 then
        sprite("Cargo Bot:Condition Red",0,0,50,50)
    elseif self.category == 4 then
        sprite("Documents:Coin",0,0,50,50)         
           
    
    
    end
    popMatrix()
end
    
function Objects:touched(touch)
    -- Codea does not automatically call this method
end
----------------
Paddle Tab:
Paddle = class()
    -- Austin Wiltse
    -- 01/01/13 
    --
    -- This is a paddle class that moves based on gravity. 
    -- I would like to hear any suggestions as to the 'elegence' of the code.
    --
    -- I wanted to pass in posx and posy as position (vec2) but kept getting an nil error?
    -- And self.pos.x doesn't seem to work
    -- Anyone know why or how to pass in vector properly?

function Paddle:init(posx,posy,pWidth,pHeight,pColor)

    self.pWidth = pWidth
    self.pHeight = pHeight
    self.posx = posx
    self.posy = posy
    pos = vec2(posx,posy)
    size = vec2(pWidth,pHeight)

    self.pColor = pColor
end

function Paddle:draw()

    checkGrav()

    fill(pColor)   
    -- I really don't like having some of the varables self.blah or others not.  
    rect(pos.x,pos.y,self.pWidth,self.pHeight)

end
-- It just feels like there are alot of 'if's in this function...any ideas?
function checkGrav()
    -- This function checks boundaries first to avoid 'bouncing' on the edges
    if pos.x >= 0 and pos.x <= WIDTH - size.x then
        if Gravity.x > 0 then
            pos.x = pos.x + (20 * Gravity.x)
        end  
        if Gravity.x < 0 then
            pos.x = pos.x - (-20 * Gravity.x)
        end    
    end 

    if pos.x < 0 then
        pos.x = 0
    end

    if pos.x > WIDTH - size.x then
        pos.x = WIDTH - size.x
    end
end

function Paddle:touched(touch)
    -- Codea does not automatically call this method
end

You have 2 programs that work, and part of a 3rd program that doesn’t do anything but cause errors. The 1st program draws a paddle that moves back and forth as you tilt the iPad. The 3rd program draws a bunch of colored squares that fall down the screen due to gravity. The 2nd program is just parts of a program that would draw an arrow pointing down due to gravity as the iPad is tilted if all of it was there. You can’t take multiple programs that work alone and combine them into one program and expect them to work together. You need to take only the functions you need from each program and combine them into one, but not the whole program of each.

Hello @CodeaNoob. You can help others on this forum read and copy your code to Codea by following the advice in the Codea Wiki here.

The fences that you need to put to format the code are three tildes: ~~~. You’d put a load of dashes. I fixed it for you.