Lua arguments OO:style
Posted: Tue Jun 19, 2007 08:37
Hi.
Im wondering how people uses the lua scripting for handling callbacks...
A brief example
function colourChangeHandler(args)
local scroller = CEGUI.toScrollbar(CEGUI.toWindowEventArgs(args).window)end
local value = scroller:getScrollPosition()
etc...
end
winMgr:getWindow("root/Window/MySlider"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
Now what if I would like some more information associated to this slider/callback?
Then I would have to use scope, hope that variables are not removed by garbage collection:
function setupSlider()
local my_car_wheel = createCarWheel()
function colourChangeHandler(args)
local scroller = CEGUI.toScrollbar(CEGUI.toWindowEventArgs(args).window)end
local value = scroller:getScrollPosition()
--
my_car_wheel:setVelocity(value)
etc...
end
winMgr:getWindow("root/Window/MySlider"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
end
So my question is, how do you all handle "additional data" when it comes to callbacks?
/Anders
Im wondering how people uses the lua scripting for handling callbacks...
A brief example
function colourChangeHandler(args)
local scroller = CEGUI.toScrollbar(CEGUI.toWindowEventArgs(args).window)end
local value = scroller:getScrollPosition()
etc...
end
winMgr:getWindow("root/Window/MySlider"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
Now what if I would like some more information associated to this slider/callback?
Then I would have to use scope, hope that variables are not removed by garbage collection:
function setupSlider()
local my_car_wheel = createCarWheel()
function colourChangeHandler(args)
local scroller = CEGUI.toScrollbar(CEGUI.toWindowEventArgs(args).window)end
local value = scroller:getScrollPosition()
--
my_car_wheel:setVelocity(value)
etc...
end
winMgr:getWindow("root/Window/MySlider"):subscribeEvent("ScrollPosChanged", "colourChangeHandler")
end
So my question is, how do you all handle "additional data" when it comes to callbacks?
/Anders