Jump to content




Is there a blacklist for os.pullEvent()


  • You cannot reply to this topic
3 replies to this topic

#1 gril002

  • Members
  • 38 posts

Posted 07 April 2016 - 05:00 PM

So I am using os.pullEvent() for touch screen, but I also have to prevent people from terminating my program. If I use os.pullEvent = os.pullEventRaw then the touch screen does not work. So can I just have it so it completely ignores the terminate command?

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 07 April 2016 - 06:42 PM

os.pullEventRaw will always return terminate events, no matter what filter you set. When you say your "touch screen does not work", I assume you mean "your script crashes when hitting terminate", in which case your fix is to have your code check that your received event data represents a monitor_touch event was received before trying to treat it like a monitor_touch event.

Post your code if you're still stuck.

#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 07 April 2016 - 07:16 PM

You could modify os.pullEvent to ignore "terminate" events.

local unpack = unpack or table.unpack --#compatibility with 5.1 & 5.2
os.pullEvent = function( sFilter ) --#override os.pullEvent
  local result
  repeat --#pull a raw event until the returned event is not terminate
    result = {os.pullEventRaw( sFilter )}
  until result[ 1 ] ~= "terminate"
  return unpack( result )
end


#4 gril002

  • Members
  • 38 posts

Posted 07 April 2016 - 07:27 PM

ok tnx helped a lot





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users