Going crazy: when is an event not an event?

Says it all…

Slightly anonymized, should be no trade secrets here…

[code]-- in main.lua
local function movePlayer(event)
helper.screenToGridPosition(map, event)
end
Runtime:addEventListener(“touch”, movePlayer)

– in otherfile-helper.lua
function helper:screenToGridPosition(map, location)
print("map = ", map, "location = ", location)
end[/code]

map comes up as a table (as expected)
location comes up as nil, instead of a table.

Any ideas? Am I somehow destroying some basic Lua principle here?

(The only thing I can think of is that maybe : is a way of forcing the second argument of any function to be …) [import]uid: 41884 topic_id: 28749 reply_id: 328749[/import]

Just by a passing glance, you have helper:screenToGridPosition with a colon : in your module and you have helper.screenToGridPosition with a period in your main.lua, try to match the colon in your main.lua. Also the event you are trying to access is a location on the screen so you need to grab that location by using .x and .y for instance event.x and event.y to get the exact x,y coords that you are trying to access.

Now i have not had to call a module function with :, i use table values with mine so i cannot guarantee it will fix it. Also i see you are using a global function in your external module. Have you seen the table value method that keeps everything local?

for instance:
External Module
[lua]–External Module

–Create a table to store the external modules functions
local exterTable = {}

–Create a function to access outside of the module
local function extFunction ()
print (“hey it works”)
end
–Insert the function into the module table
exterTable.extFunction = extFunction

–Lastly return the module table
return exterTable[/lua]

Main.lua
[lua]–Main.lua

–Require in the external module
local extModule = require (“extModule”)

local extFunction = extModule.extFunction

extFunction()[/lua]
I hope this helps, if not ill see what i can come up with.
[import]uid: 126161 topic_id: 28749 reply_id: 115862[/import]

Yeah, it was the colon. I understand your optimization suggestions, but I’m actually just working with a certain major Corona Addon that has been somewhat abandoned. (Or at least is behind to the point that most of the documentation is problematic.). So many thanks for helping me cross this bridge!

I really need to read up on the functionality behind the colon referencing; I understood it within other functions but in a file wide context has been pretty confusing. [import]uid: 41884 topic_id: 28749 reply_id: 115868[/import]

No problem, glad i could help! [import]uid: 126161 topic_id: 28749 reply_id: 115879[/import]