GlovePIE:Ultimate Flick Script Tidbit

From WiiLi

Jump to: navigation, search

Detects directional flicks for both wiimote and nunchuk

/*           Ultimate Flick Script Tidbit v1.1
***********************************************************
*                 Created by Rhys Legault                 *
*                 rhyslegault@hotmail.com                 *
*             Last Modified: June 5th, 2007               *
***********************************************************
*  Feel free to use, modify and redistribute this script  *
***********************************************************
*
* About:
* This script detects directional flicks of the Wiimote and Nunchuk.
* Example functionality translates flick actions to similar directional
* key presses(up, down, left, right) & speaks the action out loud.
*
* Just copy and paste required script section(s) into your script and
* add your own custom functionality.
*/

//Amount of time allowed between sequence actions
PIE.SeqReadGap = 50ms

//Amount of accelation required for action to occur
var.AccelerationThreshold = 1.5

//Amount of time between a flick action
var.ActionGap = 150ms

//Amount of time to hold key press
//Used in example functionality (Delete if unused in custom functionality)
var.HoldKey = 50ms

if var.WiimoteFlick = false

   //Flick Wiimote up
   if (Wiimote.gy > var.AccelerationThreshold, Wiimote.gy < -var.AccelerationThreshold)
      var.WiimoteFlick = true

      //Custom script functionality starts here
      say "Wiimote up"
      Press(Up)
      wait var.HoldKey
      Release(Up)
      //Custom script functionality ends here

      wait var.ActionGap
      var.WiimoteFlick = false

   //Flick Wiimote down
   elseif (Wiimote.gy < -var.AccelerationThreshold, Wiimote.gy > var.AccelerationThreshold)
      var.WiimoteFlick = true

      //Custom script functionality starts here
      say "Wiimote down"
      Press(Down)
      wait var.HoldKey
      Release(Down)
      //Custom script functionality ends here

      wait var.ActionGap
      var.WiimoteFlick = false

   //Flick Wiimote left
   elseif (Wiimote.gx < -var.AccelerationThreshold, Wiimote.gx > var.AccelerationThreshold)
      var.WiimoteFlick = true

      //Custom script functionality starts here
      say "Wiimote Left"
      Press(Left)
      wait var.HoldKey
      Release(Left)
      //Custom script functionality ends here

      wait var.ActionGap
      var.WiimoteFlick = false

   //Flick Wiimote right
   elseif (Wiimote.gx > var.AccelerationThreshold, Wiimote.gx < -var.AccelerationThreshold)
      var.WiimoteFlick = true

      //Custom script functionality starts here
      say "Wiimote Right"
      Press(Right)
      wait var.HoldKey
      Release(Right)
      //Custom script functionality ends here

      wait var.ActionGap
      var.WiimoteFlick = false
   endif
endif

if var.NunchukFlick = false

   //Flick Nunchuk up
   if (Wiimote.Nunchuk.gy > var.AccelerationThreshold, Wiimote.Nunchuk.gy < -var.AccelerationThreshold)
      var.NunchukFlick = true

      //Custom script functionality starts here
      say "Nun chuk up"
      Press(Up)
      wait var.HoldKey
      Release(Up)
      //Custom script functionality ends here

      wait var.ActionGap
      var.NunchukFlick = false

   //Flick Nunchuk down
   elseif (Wiimote.Nunchuk.gy < -var.AccelerationThreshold, Wiimote.Nunchuk.gy > var.AccelerationThreshold)
      var.NunchukFlick = true

      //Custom script functionality starts here
      say "Nun chuk down"
      Press(Down)
      wait var.HoldKey
      Release(Down)
      //Custom script functionality ends here

      wait var.ActionGap
      var.NunchukFlick = false

   //Flick Nunchuk left
   elseif (Wiimote.Nunchuk.gx < -var.AccelerationThreshold, Wiimote.Nunchuk.gx > var.AccelerationThreshold)
      var.NunchukFlick = true

      //Custom script functionality starts here
      say "Nun chuk Left"
      Press(Left)
      wait var.HoldKey
      Release(Left)
      //Custom script functionality ends here

      wait var.ActionGap
      var.NunchukFlick = false

   //Flick Nunchuk right
   elseif (Wiimote.Nunchuk.gx > var.AccelerationThreshold, Wiimote.Nunchuk.gx < -var.AccelerationThreshold)
      var.NunchukFlick = true

      //Custom script functionality starts here
      say "Nun chuk Right"
      Press(Right)
      wait var.HoldKey
      Release(Right)
      //Custom script functionality ends here

      wait var.ActionGap
      var.NunchukFlick = false
   endif
endif

Personal tools