Trouble with input

FMOD / Untz / Native

Moderators: ezraanderson, ibisum

Trouble with input

Postby broski » Fri Feb 10, 2017 2:09 pm

I'm early in the process of learning to use MOAI but am liking it so far!
Came upon my first problem today however that I was hoping someone could help me with.
I want to add a callback for touch events and found code doing it like this:
function(eventType, id, x, y, tapCount)
When I'm adding this to my code I get an error saying:
"unprotected error in call to Lua API (attempt to index field 'touch' (a nil value))"
I'm pretty new to Lua as well, so I'm not sure whether this is something I've done wrong in Lua or Moai..
Last edited by broski on Fri Apr 28, 2017 10:58 am, edited 2 times in total.
Posts: 1
Joined: Fri Feb 10, 2017 2:01 pm

Re: Trouble with input

Postby rosendo » Fri Feb 10, 2017 11:35 pm

You may not be set up to receive touch events. You can first check that you have access to MOAIInputMgr.device.touch like the following

if MOAIInputMgr.device.touch then

so without this check and you try to access touch, touch is not pointing to anything and is just nil

If you go through the samples in moai, you'll see examples where this check is made when you have access to touch events, otherwise you check to see if you have access to a mouse pointer.
Posts: 5
Joined: Thu Oct 22, 2015 11:23 am

Return to Sound + Music

Who is online

Users browsing this forum: No registered users and 1 guest