Attempt to call global 'T1' (a table value)

A week that I’m done with this problem: an error message appears and I think the problem is related to the scope of the variable.

Left part of the code:

function CuentaregresivaCiencia (event)

Banda.y = 60

categoria.text= “Ciencia & Tecnología”

categoria.y=192

puntaje.y=192

Nvidas.y=192

Logociencia.y=60

Aguja.y=60

Dial.y=61

Valorrespuesta.y=245

CCR.y=450

function Temporizador( event )

Cuenta=Cuenta-1

    if Cuenta> -1 then

    CCR.text= Cuenta

    

    media.playSound( ‘Tan.mp3’ )

    end

if Cuenta==-1 then

Puerta1.x=150

Puerta1.y=450

Puerta2.x=390

Puerta2.y=450

Puerta3.x=625

Puerta3.y=450

Puerta4.x=860

Puerta4.y=450

path = system.pathForFile( “TextoCiencia.txt” )

file = io.open( path, “r” )

– En la línea siguiente se provoca el error. Cuando hace la llamada a T1()

T1()  

leer()

CCR.y=-600

Intro = audio.stop( Intro, { channel=2, loops=-1, fadein=0 } )

end

    

end

timer.performWithDelay( 1000, Temporizador,5 )

end

function T1Reinicio ()

timer.cancel (T1)

Aguja:rotate (-J)

J=0

Nivel :setFillColor(0,0.5,1,0.45)

Aguja :setFillColor(0,0.5,1,0.95)

function Temp1( event )

B=1

J=J+1

if J<51 then

valor=1000

Valorrespuesta.text= “+”…valor

end

if J>50 and J<100 then

valor=500

Valorrespuesta.text= “+”…valor

end

if J>99 and J<181 then

valor=100

Valorrespuesta.text= “+”…valor

end

if J>180 and J<271 then

valor=50

Valorrespuesta.text= “+”…valor

end

if J>270 then

valor=5

Valorrespuesta.text= “+”…valor

end

if J==300 then

media.playSound( ‘Tan.mp3’ )

end

if J==330 then

media.playSound( ‘Tan.mp3’ )

end

if J==360 then

media.playSound( ‘Tan.mp3’ )

end

if J==360 then

timer.cancel (T1)

J=0

Psincontestar=Psincontestar+1

leer()

end

Aguja:rotate ( B)

Nivel.y= 96 - (J/10)

end

T1= timer.performWithDelay( 32.55,Temp1,360 )

end

– Esta es la función T1

function T1 ()

Nivel :setFillColor(0,0.5,1,0.45)

Aguja :setFillColor(0,0.5,1,0.95)

function Temp1( event )

B=1

J=J+1

if J<51 then

valor=1000

Valorrespuesta.text= “+”…valor

end

if J>50 and J<100 then

valor=250

Valorrespuesta.text= “+”…valor

end

if J>99 and J<181 then

valor=100

Valorrespuesta.text= “+”…valor

end

if J>180 and J<271 then

valor=50

Valorrespuesta.text= “+”…valor

end

if J>270 then

valor=5

Valorrespuesta.text= “+”…valor

end

if J==300 then

media.playSound( ‘Tan.mp3’ )

end

if J==330 then

media.playSound( ‘Tan.mp3’ )

end

if J==360 then

media.playSound( ‘Tan.mp3’ )

end

if J<181 then

–Aguja :setFillColor(0,0.54,0,0.75)

–Nivel :setFillColor(0,0.54,0,0.45)

end

if J>179 and J<271 then

–Aguja :setFillColor(1,1,0,0.75)

–Nivel :setFillColor(1,1,0,0.45)

end

if J>270 then

–Aguja :setFillColor(1,0,0,0.75)

–Nivel :setFillColor(1,0,0,0.45)

end

if J==360 then

timer.cancel (T1)

J=0

Psincontestar=Psinconstestar+1

leer()

end

Nivel.y= 96- (J/10)

Aguja:rotate ( B)

end

T1= timer.performWithDelay( 32.55, Temp1,360 )

end

First, your code is really hard to read.  Please enter and (without the spaces) and past your code in between them.  Also make sure your code is indented. 

But from a quick scan, you seem to use T1 as a function and then later use it as a variable to hold the handle to a timer.  You may also have scope issues but because I can’t figure out where  your functions begin and end, I can’t confirm that.

Rob

First, your code is really hard to read.  Please enter and (without the spaces) and past your code in between them.  Also make sure your code is indented. 

But from a quick scan, you seem to use T1 as a function and then later use it as a variable to hold the handle to a timer.  You may also have scope issues but because I can’t figure out where  your functions begin and end, I can’t confirm that.

Rob