Dumb timer problem!

Ok, this should be so simple, but for some reason I’m getting this error:

[lua]Copyright © 2009-2011 A n s c a , I n c .
Version: 2.0.0
Build: 2011.704
The file sandbox for this project is located at the following folder:
(/Users/eudoxus/Library/Application Support/Corona Simulator/Connector-AB581F2F8E5C2B5EEDCB19B1A1D6A42A)
Runtime error
?:0: attempt to index global ‘system’ (a function value)
stack traceback:
[C]: ?
?: in function ‘performWithDelay’
…s/eudoxus/Documents/Corona/MyApps/Connector/main.lua:34: in function ‘newPiece’
…s/eudoxus/Documents/Corona/MyApps/Connector/main.lua:51: in main chunk
Runtime error: ?:0: attempt to index global ‘system’ (a function value)
stack traceback:
[C]: ?
?: in function ‘performWithDelay’
…s/eudoxus/Documents/Corona/MyApps/Connector/main.lua:34: in function ‘newPiece’
…s/eudoxus/Documents/Corona/MyApps/Connector/main.lua:51: in main chunk[/lua]

This is being generated by the following code (full listing):

[lua]–local pieceapi = require(“pieces”)
– remove status bar
display.setStatusBar( display.HiddenStatusBar )

function system( event )
native.showAlert( “event.type”, event.type, {“OK”} )
end

–Runtime:addEventListener( “system”, system )
function newPiece( parent, x, y, ptype )
local piece = display.newGroup()
parent:insert( piece )

piece.x, piece.y, piece.ptype = x, y, ptype

display.newCircle( piece, 0, 0, 5 )
local len, dist = 20, 30
for i=0, 5 do
local group = display.newGroup()
piece:insert( group )
group.rotation = (360/6)*i
local line = display.newLine( group, -len, -dist, len, -dist )
line.width = 4
line:setColor( 255, 255, 255 )
end

function piece:timer( event )
– print(“called”)
end
piece.t = timer.performWithDelay( 1000, piece, 1 )

return piece
end

local types = { default=1, blocker=2 }
local grid = display.newGroup()
grid.x, grid.y = display.contentCenterX, display.contentCenterY

for r=1, 10 do
for c=1, 10 do
local x = -380 + c*70
local y = -380 + r*70
newPiece( grid, x, y, types.default )
end
end[/lua]

If anyone could help me with this it would be fantastic - I just can’t believe I’m making what is probably a dumb error.

Thanks,

Matt. [import]uid: 8271 topic_id: 19631 reply_id: 319631[/import]

You have a function named “system”. This is a no-no as system is a reserved word. I changed the function name to systemA and it worked for me. [import]uid: 70391 topic_id: 19631 reply_id: 75833[/import]

Thank you. I’m an idiot.

m [import]uid: 8271 topic_id: 19631 reply_id: 75966[/import]