如何使用参数在Lua中执行回调

如何使用参数在Lua中执行回调,lua,callback,coronasdk,Lua,Callback,Coronasdk,我正在尝试向回调函数附加附加逻辑。问题是回调还需要一个参数 我有这个函数,最后一个参数是回调: game.showAlert( "Title", "Message", function( event ) if (event.action == "clicked") then --Do stuff end end ) 我尝试在回调后注入一些额外的逻辑,方法如下: game.showAlert = function (title, message,

我正在尝试向回调函数附加附加逻辑。问题是回调还需要一个参数

我有这个函数,最后一个参数是回调:

game.showAlert( 
  "Title", 
  "Message",
  function( event )
    if (event.action == "clicked") then
      --Do stuff
    end
  end
)
我尝试在回调后注入一些额外的逻辑,方法如下:

game.showAlert = function (title, message, tblButtons, tblListener) 
  function onComplete()
    --Execute listener that was passed in
    if (tblListener and type(tblListener) == "function") then
        tblListener()
    end

    --Do other stuff
  end

  native.showAlert(title, message, tblButtons, onComplete)
end
当我调用
tblListener()
时,我得到一个错误,指出
event
nil
,这是有意义的


问题是,我如何使用正确的参数和上下文执行回调?

函数onComplete(event)
替换
函数onComplete()
,当然用
tblListener(event)
替换
函数onComplete()
。。非常感谢你。有点尴尬。。Lol用
函数onComplete(事件)
替换
函数onComplete()
,当然用
tblListener(事件)
替换
tblListener()
。。非常感谢你。有点尴尬。。英雄联盟