Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Jun 9th, 2009 | Syntax: None | Size: 0.62 KB | Hits: 82 | Expires: Never
Copy text to clipboard
  1.  
  2. --Placing the phone face down will disable the ringer. Turning it face up again will enable
  3. --the ringer.
  4. require "android"
  5. android.startSensing()
  6. android.sleep(1)  --Give the sensors a moment to come online.
  7. silent = false
  8. while true do
  9.   s = android.readSensors()
  10.   facedown = s.result and s.result.zforce and s.result.zforce > 9
  11.   if facedown and not silent then
  12.     android.vibrate()  --A short vibration to indicate we're in silent mode.
  13.     android.setRingerSilent(true)
  14.     silent = true
  15.   elseif not facedown and silent then
  16.     android.setRingerSilent(false)
  17.     silent = false
  18.   end
  19.   android.sleep(1)
  20. end