Ok, almost there…
Still have nil for both mouse x and mouse y?
function on_input(self, action_id, action)
-- Add input-handling code here
-- Remove this function if not needed
if action_id == hash("GotoNextScreen") then
if CurrentScreen == 1 then Screen1FadeStatus = 1
end
end
label.set_text( "#MouseXY", "X:" .. tostring(screen_x) .. "/Y:" .. tostring(screen_y) ) -- Always nil for both values?
end
That means that you define a function called on_input() that takes three arguments: self, action_id and action. There are no other magic global variables that are set.
The engine calls your function and provides values for the arguments. The page you linked says this:
Mouse and touch inputs set fields in the action table…
This means that a table is passed to the function. The table contains the values you need. Try this:
function on_input(self, action_id, action)
pprint(action) -- pretty print table "action".
end
If you wonder what a table is, we have a brief Lua manual (Lua programming in Defold), but you should probably get hold of a copy of “Programming in Lua” and work with that.