/Users/jenkins/slaveroot/workspace/templates/label/android/subrepos/widget/widgetLibrary/widget_button.lua:680: attempt to preform arithmetic on field

i created a game for android but when i play it after a little while it shows this message “/Users/jenkins/slaveroot/workspace/templates/label/android/subrepos/widget/widgetLibrary/widget_button.lua:680: attempt to preform arithmetic on field ‘x’ (a nil value)” 

​does anyone know i can fix this ?

What version of Corona are you using?

Can you post your code where you are creating your button? I’m assuming “Words Completed” is the button in question.

Also, I looked at the code for the widget library and that error is in the :setLabel() function which could be called when the button is created or later by actually calling :setLabel().

Please also post any code where you’re changing the label.  Please use the blue <> button in the row with Bold & Italic to popup a window to paste your code into.

Thanks

Rob

i am using Version 2017.3184 (2017.12.8) (thats what my mac says)      i do not have a button called “words Completed”

 for i=1,#playerLetters do playerLetters[i]:setLabel(string.upper(currentWordTable[i])) playerLetters[i].value = currentWordTable[i] end

Can you post the code where you’re calling widget.newButton()?

here you go :slight_smile:    

for i=1,5 do answerLetters[i] = display.newText(sceneGroup, "", 0, 0, native.systemFontBold, 72) answerLetters[i].x = i \* 155 - 65 answerLetters[i].y = lifebarBoxes.y - 30 answerLetters[i]:setFillColor(1) playerLetters[i] = widget.newButton({ width = 178, height = 158, defaultFile = "images/game/blank-box.png", overFile = "images/game/blank-box.png", font = native.systemFontBold, fontSize = 68, labelColor = { default={ 1, 1, 1 }, over={ 1, 1, 1, 0.5 } }, onEvent = onLetterTouch }) playerLetters[i].id = i playerLetters[i].assignment = 0 sceneGroup:insert(playerLetters[i]) end

local btn\_play = widget.newButton({ -- add the play button width = 552, height = 196, defaultFile = "images/menu/play\_btn.png", overFile = "images/menu/play\_btn\_pressed.png", onEvent = onMenuTouch }) btn\_play.x = \_S.CX btn\_play.y = txt\_bestScore.y + 275 sceneGroup:insert(btn\_play)

Since you’re on a Mac, are you having Corona install the build to your test device via a USB cable?  If so, and you don’t close the dialog box that says when it’s done installing, then the Corona console log, should be displaying messages from the device’s console log. There is likely a longer stack trace that could provide more information as to what the problem is.  You may have to use the “adb logcat” command (which may require you to install the adb tools) or you can use Android Studio to view the device’s log.

The error seems like it can only happen if you’re trying to set the label on a button that’s been removed.

Rob

What version of Corona are you using?

Can you post your code where you are creating your button? I’m assuming “Words Completed” is the button in question.

Also, I looked at the code for the widget library and that error is in the :setLabel() function which could be called when the button is created or later by actually calling :setLabel().

Please also post any code where you’re changing the label.  Please use the blue <> button in the row with Bold & Italic to popup a window to paste your code into.

Thanks

Rob

i am using Version 2017.3184 (2017.12.8) (thats what my mac says)      i do not have a button called “words Completed”

 for i=1,#playerLetters do playerLetters[i]:setLabel(string.upper(currentWordTable[i])) playerLetters[i].value = currentWordTable[i] end

Can you post the code where you’re calling widget.newButton()?

here you go :slight_smile:    

for i=1,5 do answerLetters[i] = display.newText(sceneGroup, "", 0, 0, native.systemFontBold, 72) answerLetters[i].x = i \* 155 - 65 answerLetters[i].y = lifebarBoxes.y - 30 answerLetters[i]:setFillColor(1) playerLetters[i] = widget.newButton({ width = 178, height = 158, defaultFile = "images/game/blank-box.png", overFile = "images/game/blank-box.png", font = native.systemFontBold, fontSize = 68, labelColor = { default={ 1, 1, 1 }, over={ 1, 1, 1, 0.5 } }, onEvent = onLetterTouch }) playerLetters[i].id = i playerLetters[i].assignment = 0 sceneGroup:insert(playerLetters[i]) end

local btn\_play = widget.newButton({ -- add the play button width = 552, height = 196, defaultFile = "images/menu/play\_btn.png", overFile = "images/menu/play\_btn\_pressed.png", onEvent = onMenuTouch }) btn\_play.x = \_S.CX btn\_play.y = txt\_bestScore.y + 275 sceneGroup:insert(btn\_play)

Since you’re on a Mac, are you having Corona install the build to your test device via a USB cable?  If so, and you don’t close the dialog box that says when it’s done installing, then the Corona console log, should be displaying messages from the device’s console log. There is likely a longer stack trace that could provide more information as to what the problem is.  You may have to use the “adb logcat” command (which may require you to install the adb tools) or you can use Android Studio to view the device’s log.

The error seems like it can only happen if you’re trying to set the label on a button that’s been removed.

Rob