I am attempting to loop through function randomly as a work around for a game i am working on but i keep receiving the error " main.lua:53 attempt to get length of upvalue ‘funcTable’ (a function value).
here is a screen shot of the exact error message. https://gyazo.com/2edbe62cfe5291b62973ccec204c04c5
i am not sure what is causing this error or how to fix it.
any help is appreciated!
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- local backGround = display.newImageRect("HardGameBackground.png", display.contentWidth, display.contentHeight) backGround.x = display.contentCenterX backGround.y = display.contentCenterY math.randomseed(os.time()) local Text1 local Text2 local Text3 local Text4 local Text5 local textLoopTimer local function displayText1 () Text1 = display.newText( "This is Text 1", display.contentCenterX ,display.contentCenterY, native.systemFont, 180) Text1:setFillColor(0,0,0) end local function displayText2 () Text1 = display.newText( "This is Text 2", display.contentCenterX ,display.contentCenterY, native.systemFont, 180) Text1:setFillColor(1,0,0) end local function displayText3 () Text1 = display.newText( "This is Text 3", display.contentCenterX ,display.contentCenterY, native.systemFont, 180) Text1:setFillColor(0,255,0) end local function displayText4 () Text1 = display.newText( "This is Text 4", display.contentCenterX ,display.contentCenterY, native.systemFont, 180) Text1:setFillColor(255,255,0) end local function displayText5 () Text1 = display.newText( "This is Text 5", display.contentCenterX ,display.contentCenterY, native.systemFont, 180) Text1:setFillColor(0,0,255) end local funcTable = ({displayText1,displayText2,displayText3,displayText4,displayText5})[math.random(5)]; local function textLoop() for i = #funcTable, 1, -1 do local thisText = funcTable[i] end end textLoopTimer = timer.performWithDelay( 100, textLoop, 0 )