I have the main.lua file where I do this:
--...
local \_functions = require("functions")
--...
local startGridPos = nil
local onMapClick = function(event)
if not startGridPos then
startGridPos = \_functions:screenToGridPosition(map, event)
end
--...
end
And on functions.lua:
module(..., package.seeall)
local lime = require("lime")
--...
function screenToGridPosition( map, e )
print("Screen to grid Position")
print(e.x)
local screenPosition = { x = e.x, y = e.y }
-- Now convert that to a world position
local worldPosition = lime.utils.screenToWorldPosition( map, screenPosition )
-- And finally convert the world position to a grid position and return it
return lime.utils.worldToGridPosition( map, worldPosition )
end
--...
But when I run it, the terminal tells me e.x is nil. I’ve tried calling it and working it out with various ideas, but it never works. I dont understand why if I send the event Object(sometimes I make a new table and set the x an y variables) to the function, it tells me the Object exists, but not x or y.
I would appreciate any help [import]uid: 109816 topic_id: 19474 reply_id: 319474[/import]