I am trying to pass variables from one function to another. In the example below the code will not work. I have truncated it to make it readable and pretain specificly to my issue.
popupPartA consists of a single display object with other display objects added to the table.
Example=
popupPartA = displayobject
popupPartA.background = displayobject
popupPartA.foreground = displayobject
The issue is that when popupPartA.acceptFunction() is called it removes the display objects but the variable popupPartA isn’t cleared. If I print the variable it isn’t nil.
How can I fix this? Ideas?
local popupPartA, popupPartB local function cancelPopUpNotice( popupNotice, popupBlackOut ) popupNotice:removeSelf() popupNotice = nil popupBlackOut:removeSelf() popupBlackOut = nil end local function buildTutorialPopup( popupVars ) local params local popupNotice, popupBlackOut = nil, nil --Sets optional parameters for popUp window in local function setPopUpParams( params ) params = { type = popupVars.popupToBuild, style = popupVars.style } params.acceptFunction = function() cancelPopUpNotice( popupNotice, popupBlackOut ) end return params end params = setPopUpParams( params ) --Builds the requested popUp local function buildPopUpNotice( params ) popupBlackOut = gameUi.buildBlackOut() popupNotice = gameUi.buildPopupNotice( params ) end buildPopUpNotice( params ) return popupNotice, popupBlackOut end popupPartA, popupPartB = buildTutorialPopup( popupVars ) popupPartA.acceptFunction() print("popupPartA",popupPartA) --Not Nil