hello guys i need a help with module in lua, i’m newbie with programming.
i have a scene.lua where i can get a player table. like this:
local controller = require("controller")
player = {}
player.name = “player”
As its possible to see i have a modules controller.lua that helps me
now comes the problem … i used i touch function to get touch x and y but since the code was becaming big i decided to create a controler script to it, and even my player table been global the controler cant get it here is the code:
\_c = {} function \_c.onTouch(event) local tx = event.x local ty = event.y print(player.name) end return \_c
when i touch the print result is “nil”. i already try change the listener to create a function inside another like this:
Runtime:addEventListener("touch", function() controller.onTouch(event,player) end)
to see if i can pass player as parameter but that dint solve the problem.
I would like if possible some explanation to learn how pass the variable in the right way through modules.