What does "attempt to call upvalue 'removeEventListener3' " mean?

When I try to remove some event listeners in case something didn’t run (checking it with didRun3, a value I set to true when my something doesn’t run)

else if didRun3 == false then removeEventListener3() print("removed event listener for dot 3")

and when I check it with this didRun3 == false, what I get is:

Corona Runtime Error ...ts(builds)\dots(default)\dots\main.lua:189: attempt to call upvalue 'removeEventListener3' (a nil value)

But, it’s not a nil value. What does this mean?

EDIT: The title should be

What does "attempt to call upvalue ‘removeEventListener3’ (a nil value) " mean?

And if I don’t forward reference it, it says:

Corona Runtime Error ...ts(builds)\dots(default)\dots\main.lua:189: attempt to index global 'removeEventListener3' (a nil value)

Can you post more of your code?  Specifically where you add the event listener and where didRun3 gets set.

sounds like a local issue

removeEventListener3() is out of scope

maybe you set it to local inside a function instead of local to the app/module

try inserting at top of code

local removeEventListener3()

and remove local from the

local function removeEventListener3() line so it just reads

function removeEventListener3()

Hi, it’s already like that - I mean my code has that, but if I take away the local removeEventListener3() I get

Corona Runtime Error ...ts(builds)\dots(default)\dots\main.lua:189: attempt to index global 'removeEventListener3' (a nil value)  

If I do what you suggested I get

Corona Runtime Error ...ts(builds)\dots(default)\dots\main.lua:189: attempt to call upvalue 'removeEventListener3' (a nil value)

really need to see code

i was just guessing without seeing any code

--This is checkIfScore() --Basically it checks whether the user's touch is the same as a pre-selected dot and, --if a dot wasn't pressed, it tries to remove the listeners (which isn't working!!!)

local function checkIfScore()     if didRun1 == false then         removeEventListener1()         else if didRun2== false then             removeEventListener2()             else if didRun3 == false then                 removeEventListener3()             end         end     end     print ("didRun1 is " .. tostring(didRun1))     print ("didRun2 is " .. tostring(didRun2))     print ("didRun3 is " .. tostring(didRun3))     if userSelectCorrect1 == true and userSelectCorrect2 == true and userSelectCorrect3 == true then         score = score + 1         scoreText.text = score         audio.play(successSound)         timer.performWithDelay(1000, compDotSelect)     else          lostLife()     end end  

--Below, that's where didRun3 gets set: function onTouch3(obj) didRun3 = true local function glowRemove3(obj) transition.to(obj, {alpha = 1, onComplete = checkIfScore}) end transition.to(obj,{alpha = 0.2, onComplete = glowRemove3}) userSelectCorrect3 = true -- for a reason, but I don't need to explain function removeEventListener3() -- removes previous listeners, works here if called but in checkIfScore it doesn't print("removed event listener for dot 3") dot1:removeEventListener("touch", onTouch3) dot2:removeEventListener("touch", onTouch3) dot3:removeEventListener("touch", onTouch3) end removeEventListener3() end --Here are event listeners added to some dots dot1:addEventListener("touch", onTouch3) dot2:addEventListener("touch", onTouch3) dot3:addEventListener("touch", onTouch3)

are they in that order in your code

Yes, I just edited them to be

and where is

local removeEventListener3

located

[quote name=“jstrahan” post=“193452” timestamp=“1374106570”]and where is   local removeEventListener3   located[/quote] In onTouch3

try moving

local function removeEventListener3() -- removes previous listeners, works here if called but in checkIfScore it doesn't print("removed event listener for dot 3") dot1:removeEventListener("touch", onTouch3) dot2:removeEventListener("touch", onTouch3) dot3:removeEventListener("touch", onTouch3) end

above

local function checkIfScore()
 

Hi,

I finally found a solution. Look at this link:

http://www.ludicroussoftware.com/blog/2011/08/24/remove-all-listeners/

yes that will do it but its really a work around not a fix but anyway glad it works for you

And if I don’t forward reference it, it says:

Corona Runtime Error ...ts(builds)\dots(default)\dots\main.lua:189: attempt to index global 'removeEventListener3' (a nil value)

Can you post more of your code?  Specifically where you add the event listener and where didRun3 gets set.

sounds like a local issue

removeEventListener3() is out of scope

maybe you set it to local inside a function instead of local to the app/module

try inserting at top of code

local removeEventListener3()

and remove local from the

local function removeEventListener3() line so it just reads

function removeEventListener3()

Hi, it’s already like that - I mean my code has that, but if I take away the local removeEventListener3() I get

Corona Runtime Error ...ts(builds)\dots(default)\dots\main.lua:189: attempt to index global 'removeEventListener3' (a nil value)  

If I do what you suggested I get

Corona Runtime Error ...ts(builds)\dots(default)\dots\main.lua:189: attempt to call upvalue 'removeEventListener3' (a nil value)