Please help! Can I call a function without a listener of any sort?

Is it possible to directly call on a function from within another function? For example
[lua]local function secondFunction (e)
statement1 = true

–For example:
callFunction (mainFunction)

end

btn:addEventListener (“touch”, mainfunction1)
[/lua]

I say this because my main function is separated by a true/false statements from another source. So I’m making a separate function to change a statement into being true and then calling on the main function.

Thanks for any help!! [import]uid: 35535 topic_id: 31451 reply_id: 331451[/import]

yep! this is basic programming. You can call any function that is in the same scope of the function from which you are calling. You just cant call functions that are local to other modules (ie have local as part of their declaration)

one thing to watch out for when calling functions from other functions is that is there are too many functions chained together it can cause performance problems and stack issues. In this situation you should consider using OO programming principles and implementing events. I’ve written a handy library for this at https://github.com/open768/library/blob/master/lib/lib-events.lua

[import]uid: 74338 topic_id: 31451 reply_id: 125716[/import]

yep! this is basic programming. You can call any function that is in the same scope of the function from which you are calling. You just cant call functions that are local to other modules (ie have local as part of their declaration)

one thing to watch out for when calling functions from other functions is that is there are too many functions chained together it can cause performance problems and stack issues. In this situation you should consider using OO programming principles and implementing events. I’ve written a handy library for this at https://github.com/open768/library/blob/master/lib/lib-events.lua

[import]uid: 74338 topic_id: 31451 reply_id: 125716[/import]