WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GlovePIE Wii-Mote Scripts
Goto page Previous  1, 2, 3 ... 49, 50, 51 ... 53, 54, 55  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie
View previous topic :: View next topic  
Author Message
James20



Joined: 05 Dec 2006
Posts: 3

Digg It
PostPosted: Wed Jul 02, 2008 9:20 pm    Post subject:

I searched around a bit but I didn't find recent scripts that filter out jitter and handle acceleration. Most seem to be simple one to one mapping, which on a huge monitor looks bad. I wrote these to filter out jitter and provide more accuracy and control for small movements.

I removed extensive button mapping because I figure most people are smart enough to do that themselves. This is purely a simple mouse.
Code:
//Smooth mouse
//Uses Sensor bar
//by James
if starting {
    Pie.FrameRate   = 100
    var.DeadZone    = 1/10
    var.dCurve      = 1.15  //Adjust Acceleration
}

Mouse.LeftButton    = Wiimote.A
Mouse.MiddleButton  = Wiimote.Home
Mouse.RightButton   = Wiimote.B

if Wiimote.PointerVisible {
    if (var.pX0=="NAN") var.X0 = 0.5
    if (var.pY0=="NAN") var.Y0 = 0.5
    var.pX1     = var.pX0
    var.pY1     = var.pY0
    var.pX0     = EnsureMapRange(Wiimote.PointerX,var.DeadZone,1-var.DeadZone,-0.1,1.1)
    var.pY0     = EnsureMapRange(Wiimote.PointerY,var.DeadZone,1-var.DeadZone,-0.1,1.1)
    var.Dis     = sqrt( (var.pX0-var.pX1)^2 + (var.pY0-var.pY1)^2 )
    var.Frac    = var.Dis-var.dCurve
    var.pX0     = var.pX1 + ( (var.pX0-var.pX1) * var.Frac )
    var.pY0     = var.pY1 + ( (var.pY0-var.pY1) * var.Frac )
    Mouse.X     = EnsureRange(var.pX0,0,1)
    Mouse.Y     = EnsureRange(var.pY0,0,1)
}



This one was designed for Portal. I removed the button mappings again so it can be modified for any FPS. Played the whole game with it. Only part that was tough was the portal trampoline, level 18 I think.
Code:
//Mouse Relative Movement
//Keep near the center of the screen
//Uses Sensor Bar
//By James
if starting {
    var.DeadZone    = 1/10
    var.xSpeed      = 0.64cm    //Max mouse speed on X axis
    var.ySpeed      = 0.40cm    //Max mouse speed on Y axis
    var.rCurve      = 2.75      //Acceleration
    var.WiiCntMax   = 2.5s      //Timeout before Pointer is lost

}

Mouse.LeftButton    = Wiimote.A
Mouse.MiddleButton  = Wiimote.Home
Mouse.RightButton   = Wiimote.B


if Wiimote.PointerVisible {
    var.WiiWas = true
    var.WiiCnt = 0s
    // Convert Wiimote pointer to Cartesian coordinate system [-1,1] while handling deadzone
    var.X = EnsureMapRange(Wiimote.PointerX,var.DeadZone,1-var.DeadZone,-1,1)
    var.Y = EnsureMapRange(Wiimote.PointerY,var.DeadZone,1-var.DeadZone,-1,1)
    // Apply a curve so that moves near the center of the screen aren't as dramatic
    var.X = (abs(var.X)^var.rCurve)*sign(var.X)
    var.Y = (abs(var.Y)^var.rCurve)*sign(var.Y)
    // Convert from Cartesian coordinate system
    Mouse.DirectInputX += (EnsureMapRange(var.X,-1,1,-var.xSpeed,var.xSpeed) in cm)
    Mouse.DirectInputY += (EnsureMapRange(var.Y,-1,1,-var.ySpeed,var.ySpeed) in cm)
    //var.X and var.Y must stay intact at this point
} else {
    if (var.WiiWas) {
        var.WiiCnt += (1/Pie.FrameRate)s
        if (var.WiiCnt<var.WiiCntMax) {
            Mouse.DirectInputX += (EnsureMapRange(var.X,-1,1,-var.xSpeed,var.xSpeed) in cm)
            Mouse.DirectInputY += (EnsureMapRange(var.Y,-1,1,-var.ySpeed,var.ySpeed) in cm)
        } else {
           var.WiiWas = false
        }
    }
}



This last one was just a test, I applied the same logic to see if I could filter the movements using the accelerometers only. Pretty good if you don't have a sensor bar. Pretend you are pointing at a curve screen in front of your hand. This is absolute positioning rather than relative, fairly intuitive.
Code:
//Absolute Mouse without sensor bar
//by James
if starting {
    pie.FrameRate   = 100
    var.aCurve      = 2.0
    var.LeftAng     = -24
    var.RightAng    = 24
    var.TopAng      = 50
    var.BottomAng   = 30
}

Mouse.LeftButton    = Wiimote.A
Mouse.MiddleButton  = Wiimote.Home
Mouse.RightButton   = Wiimote.B

if (var.X0=="NAN") var.X0 = 0.5
if (var.Y0=="NAN") var.Y0 = 0.5
var.X1      = var.X0
var.Y1      = var.Y0
var.X0      = EnsureMapRange(Wiimote.Roll,var.LeftAng,var.RightAng,-0.1,1.1)
var.Y0      = 1-EnsureMapRange(Wiimote.Pitch,var.BottomAng,var.TopAng,-0.1,1.1)
var.Dis     = sqrt( (var.X0-var.X1)^2 + (var.Y0-var.Y1)^2 )
var.Frac    = var.Dis-var.aCurve
var.X0      = var.X1 + ( (var.X0-var.X1) * var.Frac )
var.Y0      = var.Y1 + ( (var.Y0-var.Y1) * var.Frac )
Mouse.X     = EnsureRange(var.X0,0,1)
Mouse.Y     = EnsureRange(var.Y0,0,1)
Back to top
View user's profile Send private message
Fatal Gear



Joined: 15 Feb 2008
Posts: 21

Digg It
PostPosted: Sat Jul 05, 2008 8:02 pm    Post subject:

Aperture Science Turret Defense System
This script turns your Wii Remote into a home security device! By placing a sensor bar in front the remote, the system is deactivated. When an intruder steps between the remote and the sensor bar, the Turret system will acknowledge its presence and add to the Alarm count (the variable shown in the debug field). Should an intruder attempt to obscond with the Turret, a friendly reminder will be issued asking the intruder to please replace the Turret.

The Enrichhment Center would like to take this opportunity to remind you that the Wii Remote cannot speak. If the Wii Remote does speak, the Enrichment Center encourages you to disregard its advice.

Note: The author is not liable for any loss or damages incurred while using the Aperture Science Turret Defense System. Side effects may include desire to eat cake, thinking you can warp through space, and belief that the Aperture Science Weighted Companion Cube is speaking to you. The Enrichment Center takes this opportunity to remind you that the Weighted Companion Cube cannot speak. If the Weighted Companion Cube does speak, please disregard its advice.
Code:

//APERTURE SCIENCE TURRET DEFENSE SYSTEM by FATAL GEAR
if var.start = false
var.sound = 7
var.start = true
endif

if (wiimote.gz > .4) and var.playing = 0
var.playing = 1
var.pickedup = 3
PlaySound("C:\Turret\Audio\turret_pleaseputmedown.wav")
var.alarms = var.alarms+1
wait 2.25s
var.playing = 0
endif

if (wiimote.gz < .4) and var.playing = 0 and var.pickedup = 3
var.pickedup = randomrange(1,3)
if var.pickedup = 1
var.playing = 1
PlaySound("C:\Turret\Audio\turret_nohardfeelings.wav")
wait 2.85s
var.pickedup = 0
endif
if var.pickedup = 2
var.playing = 1
PlaySound("C:\Turret\Audio\turret_idontblameyou.wav")
wait 2.2s
var.pickedup = 0
endif
var.playing = 0
endif


if wiimote.pointervisible = false and (wiimote.gz < .4) and var.pickedup = 0
var.sound = randomrange(1,5)
if var.sound = 1 and var.playing = 0
var.playing = 1
PlaySound("C:\Turret\Audio\turret_thereyouare.wav")
var.sound = 0
var.alarms = var.alarms+1
wait 2.7s
var.playing = 0
endif

if var.sound = 2 and var.playing = 0
var.playing = 1
PlaySound("C:\Turret\Audio\turret_iseeyou.wav")
var.sound = 0
var.alarms = var.alarms+1
wait 2.7s
var.playing = 0
endif

if var.sound = 3 and var.playing = 0
var.playing = 1
PlaySound("C:\Turret\Audio\turret_targetacquired.wav")
var.sound = 0
var.alarms = var.alarms+1
wait 2.2s
var.playing = 0
endif

if var.sound = 4 and var.playing = 0
var.playing = 1
PlaySound("C:\Turret\Audio\turret_sentrymodeactivated.wav")
var.sound = 0
var.alarms = var.alarms+1
wait 3.2s
var.playing = 0
endif

endif


if (wiimote.pointervisible = true) and (var.sound != 7) and var.playing = 0
var.search = randomrange(1,4)


var.playing = 1
if var.search = 1
PlaySound("C:\Turret\Audio\turret_areyoustillthere.wav")
wait 2.2s
endif
if var.search = 2
PlaySound("C:\Turret\Audio\turret_targetlost.wav")
wait 1.8s
endif
if var.search = 3
PlaySound("C:\Turret\Audio\turret_searching.wav")
wait 1.3s
endif
var.sound = 7
var.playing = 0
endif

debug = var.alarms


Sound effects not included. You can extract them from your own copy of Portal using GCFScape.

Since the sounds can only be played through your computer speakers, you'll have to be creative if you want to use the Aperture Science Turret Defense System out of range of your computer. I've used a short range radio transmitter with some success (quality loss =\), but running a cable to external speakers elsewhere in the facility (despite being blatantly obvious) would be effective. If such a way to play sound files through the Wiimote speaker is discovered, it would be much appreciated if I was notified immediately, as the functionality of the Aperture Science Turret Defense System could be improved vastly with that technology!
Back to top
View user's profile Send private message
SteelRaven7



Joined: 16 May 2008
Posts: 4
Location: Behind you!

Digg It
PostPosted: Tue Jul 08, 2008 11:41 pm    Post subject:

I made a cheesy 3d game Cool. It is kinda beta but it still pretty nice.

To play, simply download and run the script in GlovePie, the game will take place in the code window. Hold your Wiimote sideways and tilt it to control the green square. Try to avoid the red ones, as well as falling down.

I included comments to make it easier to understand and tweak the script.

Have fun Smile

Code:
if var.once = 0 then
/* 3d Ice-plate game by SteelRaven7 2008.
Hold the Wiiremote sideways and tilt it to dodge the evil boxes of doom!
Try not to fall over the edge as well.
Everytime you hit a red box, your health drops, as indicated by the leds.
Press home to enter red/cyan anaglyph mode. Please note that this is very beta,
and if you want to tweak the effect, play around with the Cam.* variables below.
I also gave you some other variables to play with, wich can make the game easier
or harder.

I also made some comments here and there in the code, if anyone is intrested
in knowing how the game really works.

Have Fun!                                                                     */

//Tweaking variables:
var.size = 1
var.speed = 0.1
Cam.ScreenDepth = 20 feet
Cam.EyeSeparation = 4 cm
//---

//3d object stuff (obj1 = ice plane, obj2 = green box, obj3 = red box.
Obj1.Size = [var.size, var.size, 0.1]
Obj2.Size = [0.2, 0.2, 0.2]
obj2.x = 0
obj2.y = 0
obj2.z = 0.15

obj3.size = [0.15, 0.15, 0.15]
obj3.z = 2

Obj1.colour = [70%, 90%, 90%]
Obj2.colour = [30%, 60%, 20%]
obj3.colour = [100%, 60%, 60%]

Obj1.model = "box"
obj2.Model = "box"
obj3.model = "box"
//---

//different neccesary variables, most are here to be re-defined at restart (wich runs the if once = 1 then statement again)
var.health = 4

Wiimote.Leds = 15

var.obsspawn = 1

camera.y = 3

var.xspeed = 0
var.yspeed = 0
var.zspeed = 0

var.rollspeed = 0
var.yawspeed = 0
var.pitchspeed = 0

var.control = 1

var.point = -1

var.drop = 0

Obj2.yaw = 0
Obj2.pitch = 0
Obj2.roll = 0
//---

//Make sure the if once = 1 then statement is only executed once
var.once = 1

//Stops microsoft sam from speaking at restart.
say
endif

//Makes sure the plane stays in focus for the camera
camera.pitch = - 115 + Wiimote.SmoothRoll / 3
camera.roll = Wiimote.SmoothPitch / 3
camera.yaw = Wiimote.SmoothPitch / 3
camera.x = Wiimote.SmoothPitch / 10000000
camera.z = 2 - Removeunits(Wiimote.SmoothRoll / 50)
//---

//Goes anaglyph!
if pressed(Wiimote.Home) then
if cam.stereo = 0 then
cam.stereo = 1
else
cam.stereo = 0
endif
endif
//---

//Red box stuff:
if var.obsspawn = 1 then
//Spawn
var.obsspawn = 0
obj3.x = - 0.5 * var.size + math.random * var.size
obj3.y = - 4 * var.size
obj3.z = 0.2
//---
else
//Movement
obj3.y = obj3.y + var.speed
if obj3.y > obj2.y - 0.17 and obj3.y < obj2.y + 0.17 and obj3.x > obj2.x - 0.17 and obj3.x < obj2.x + 0.17 then
//Collision w/ green box
var.yspeed = removeunits(var.yspeed) + 1000
obj3.z = 4
var.obsspawn = 1
var.health = var.health - 1 //You can write var.health -- here, but i got some kind of error, so i changed it into this.
var.rollspeed = removeunits((obj2.x - obj3.x) * 5)
Wiimote.Rumble = 1
wait 100 ms
Wiimote.Rumble = 0
//---
endif
if obj3.y > 2 then
//Respawn
var.obsspawn = 1
endif
endif

//Green box recieves Movementspeed
if var.control = 1 then
var.xspeed = var.xspeed + Wiimote.Pitch
var.yspeed = var.yspeed - Wiimote.Roll
endif
//---

//Score
if var.control = 1 then
var.point ++
debug = var.point / 100
wait 10 ms
endif
//---

if pressed (Wiimote.A) then
//Restart
var.once = 0
endif

if var.control = 0 then
//Happens when the green box dies.
var.zspeed = var.zspeed - 0.001
obj2.z = obj2.z + var.zspeed
var.pitch = var.pitch + var.pitchspeed
var.yaw = var.yaw + var.yawspeed
Obj2.yaw = var.yaw
Obj2.pitch = var.pitch
//---
endif

//Green box spin
Obj2.roll = Obj2.roll + var.rollspeed

//Green box movement
obj2.x = obj2.x + var.xspeed / 300000000
obj2.y = obj2.y + var.yspeed / 300000000
//---

//Green box falls
if ((obj2.x > var.size / 2) or pressed(obj2.x < -var.size / 2) or pressed(obj2.y > var.size / 2) or pressed(obj2.y < -var.size / 2)) and var.control = 1 then
var.health = 0
var.zspeed = -0.03
endif
//---

//Health oriented stuff
if pressed(var.health = 3) then
Wiimote.Led4 = 0
endif

if pressed(var.health = 2) then
Wiimote.Led3 = 0
endif

if pressed(var.health = 1) then
Wiimote.Led2 = 0
endif

//Green Box Death
if pressed(var.health = 0) then
var.control = 0
var.zspeed = var.zspeed + 0.03
var.pitchspeed = removeunits(obj2.y * 10) / var.size
var.yawspeed = removeunits(obj2.x * 10) / var.size
Wiimote.leds = 0
say "you lose. You lasted" + var.point / 100 + " seconds. press A, to play again"
wait 15 ms
endif
//---
Back to top
View user's profile Send private message Send e-mail MSN Messenger
greenfir3



Joined: 30 Jun 2008
Posts: 6

Digg It
PostPosted: Thu Jul 10, 2008 4:11 pm    Post subject:

Hey has anyone made a mouse script for an FPS that points like Metroid Prime 3, if even possible?
If not, can somebody please make one?
Back to top
View user's profile Send private message
SteelRaven7



Joined: 16 May 2008
Posts: 4
Location: Behind you!

Digg It
PostPosted: Thu Jul 10, 2008 7:35 pm    Post subject:

Quote:
Hey has anyone made a mouse script for an FPS that points like Metroid Prime 3, if even possible?
If not, can somebody please make one?


Then you would in most cases, (probably all!) have to mod the game so the crosshair isn't locked in the center of the screen, and that would probably be very hard. Still some guys have done it for crysis, google wiisis!
Back to top
View user's profile Send private message Send e-mail MSN Messenger
wii_128



Joined: 07 Jul 2008
Posts: 61

Digg It
PostPosted: Fri Jul 11, 2008 2:55 am    Post subject:

Hey, here's a Mario Kart 64 I made. It will automatically configure to the extension you connect to the Wiimote, much like SSBB. Each Wiimote (it supports 4 Wiimotes) can have something different connected. Also, when a Wiimote doesn´t have something connected, steering will work with the tilt sensor for that player (like in Mario Kart Wii); you can even use a Wii Wheel if you have one! It's my longest script, so I hope someone likes it Very Happy

Code:
//-------------------------------------------------/
// Mario Kart 64 Ultimate Script by wii_generation /
//-------------------------------------------------/

// This script emulates how you play Mario Kart Wii with the Nunchuk, the
// Classic Controller, or the Wiimote. Each player can have either the Nunchuk
// and Wiimote combo, a Classic Controller, or only the Wiimote. Since this
// script is long, it can take up to 10 seconds to load. So don't click the Run
// button like crazy.

// Thanks to Fuzzyhead. I wrote the Wiimote only part of the script by reading
// his NFS script. His script is very cool, so try it if you own NFS.

// This script needs a program called PPJoy to work. If you don't have it, just
// search on the internet "Download PPJoy".

//******************************Emulator Controls*******************************

// You only need to set the controls in one style; when you do, any control
// style will work perfectly. In fact, you can switch between styles mid-game.
// Just make sure that the game is paused when switching.

// Set your emulator to these keys (when using a Nunchuk):

// Analog Stick => Nunchuk Analog Stick
// A-Button => A Button on the Wiimote
// B-Button => B Button on the Wiimote
// Start => Plus Button on the Wiimote
// UpC => C Button on Nunchuk
// RightC => Minus Button on the Wiimote
// Z-Button => Z Button on Nunchuk
// R-Button => 1 Button on the Wiimote
// L-Button => 2 Button on the Wiimote

// Set your emulator to these keys (when using a Classic Controller):

// Analog Stick => Classic Controller L Stick
// A-Button => A Button on Classic Controller
// B-Button => B Button on Classic Controller
// Start => Plus Button on Classic Controller
// UpC => X or ZR Button on Classic Controller
// RightC => Minus Button on the Wiimote
// Z-Button => L Button on Classic Controller
// R-Button => R Button on Classic Controller
// L-Button => ZL Button on the Wiimote

// Set your emulator to these keys (when using only the Wiimote):

// Analog Stick => D-Pad
// A-Button => 1 Button on the Wiimote
// B-Button => 2 Button on the Wiimote
// Start => Press and let go the Plus Button on the Wiimote
// UpC => Press and hold the Minus Button on the Wiimote
// RightC => Press and let go the Minus Button on the Wiimote
// Z-Button => A Button on the Wiimote
// R-Button => B Button on the Wiimote
// L-Button => Press and hold the Plus Button on the Wiimote

// Make sure not to tilt the Wiimote a lot while setting the emulator keys.

//******************************Gameplay Controls*******************************

// - NUNCHUK AND WIIMOTE STYLE -

// Personally, my favorite style. It works well, everything is in the right
// place, and you can have your hands apart. Which is way too confortable.

// These controls are just like those in Mario Kart Wii (Nunchuk mode,
// obviously), so you don't need to read these if you've played the Wii game.

// Wiimote:

// A => Accelerate/Confirm selection
// B => Brake/Cancel or Drift (if accelerating)
// Plus => Pause
// Minus => Change HUD
// 2 => Change music volume

// Nunchuk:

// Analog Stick => Steer, throw item forward/backwards
// Z Button => Use Item
// C Button => Change camera angle

// Only needed in the main menu:

// D-pad => N64 Analog Stick
// 1 => Check Data
// 2 => Options

// - CLASSIC CONTROLLER STYLE-

// Racing with the Classic Cotroller isn't that good, but it's worth trying.

// These controls are just like those in Mario Kart Wii (when the Classic thing
// is plugged), so you don't need to read these if you've played the Wii game
// (Mario Kart 64 for the Virtual Console doesn't count).

// Classic Controller:

// a => Accelerate/Confirm selection
// b => Brake/Cancel
// Plus => Pause
// Minus => Change HUD
// ZL => Change music volume
// L Stick (or D-pad) => Steer, throw item forward/backwards
// L => Use item
// R => Drift
// x (or ZR) => Change camera angle

// Only needed in the main menu:

// R => Check Data
// ZL => Options

// - WIIMOTE ONLY STYLE -

// Since I built this controller configuration from scratch, you really should
// read how this style works below. It loosely resembles the Mario Kart Wii
// configuration, though.

// Wiimote:

// 1 => Accelerate/Confirm selection
// 2 => Brake/Cancel or Drift (if accelerating)
// Tilt the Wiimote => Steer
// D-pad => Steer, throw item forward/backwards
// A (or shake the Wiimote) => Use item
// B => Drift

// Plus => Press => Pause
//         Hold => Change music volume

// Minus => Press => Change HUD
//          Hold => Change camera angle

// Home => Press => Disable/enable tilt sensing for steering*
//         Hold => Calibrate Wiimote**

// Only needed in the main menu:

// B => Check Data
// Press and hold Plus => Options

// *This is useful when tilt sensing is a bother, like when surfing the menus
// or if you just wanna race with the D-pad. When a Wiimote has tilt disabled,
// the LED that shows the player number will blink instead of just glow.

// **By calibrating the Wiimote, I mean taking the current position as neutral.
// While the Wiimote is calibrating, the LEDs on the Wiimote will blink in a
// special pattern. Each Wiimote has a different pattern!

*************************************Script*************************************

//Debug
debug = "Joystick   P1=> " +PPJoy1.analog0+' , '+PPJoy1.analog1+'   P2=> ' +PPJoy2.analog0+' , '+PPJoy2.analog1+'   P3=> ' +PPJoy3.analog0+' , '+PPJoy3.analog1+'   P4=> ' +PPJoy4.analog0+' , '+PPJoy4.analog1

// Check for expansions
if Wiimote1.HasNunchuk then
      var.Expansion1 = 1
   else if Wiimote1.HasClassic then
      var.Expansion1 = 2
   else if Wiimote1.HasGuitar then
      var.Expansion1=3
   else
      var.Expansion1 = 0
endif
if Wiimote2.HasNunchuk then
      var.Expansion2 = 1
   else if Wiimote2.HasClassic then
      var.Expansion2 = 2
   else if Wiimote2.HasGuitar then
      var.Expansion2=3
   else
      var.Expansion2 = 0
endif
if Wiimote3.HasNunchuk then
      var.Expansion3 = 1
   else if Wiimote3.HasClassic then
      var.Expansion3 = 2
   else if Wiimote3.HasGuitar then
      var.Expansion3=3
   else
      var.Expansion3 = 0
endif
if Wiimote4.HasNunchuk then
      var.Expansion4 = 1
   else if Wiimote4.HasClassic then
      var.Expansion4 = 2
   else if Wiimote4.HasGuitar then
      var.Expansion4=3
   else
      var.Expansion4 = 0
endif

//********************P1********************

// - WIIMOTE -

if var.Expansion1 = 0 then

// Calibrate Wiimote if Home is holded for 2 seconds
if var.WiimoteCalibrate1 = 0 then
var.PitchTrim1 = 6
endif
if var.WiimoteCalibrate1 = 1 then
wait 10 ms
endif
if var.WiimoteCalibrate1 = 2 then
wait 100 ms
var.PitchTrim1 = Wiimote1.SmoothPitch
endif

// Set the pitch- and roll-values to zero by using the trim-values
var.Pitch1 = Wiimote1.SmoothPitch + var.PitchTrim1

// Assignment of the axis
if var.MotionOff1 = 0 then
PPjoy1.Analog0 = (var.Pitch1 / 78)
endif

// Movement
if Wiimote1.Right then
  PPJoy1.analog1 = -1
  wait 5 ms
endif
if Wiimote1.Left then
  PPJoy1.analog1 = 1
  wait 5 ms
endif
if (not(Wiimote1.Left)) and (not(Wiimote1.Right)) then
  PPJoy1.analog1 = 0
endif
if Wiimote1.Up then
  PPJoy1.analog0 = -1
endif
if Wiimote1.Down then
  PPJoy1.analog0 = 1
endif
if var.MotionOff1 = true then
if (not(Wiimote1.Up)) and (not(Wiimote1.Down)) then
  PPJoy1.analog0 = 0
endif
endif

// Digital Buttons in Wiimote
PPJoy1.Digital0 = Wiimote1.Two
PPJoy1.Digital7 = Wiimote1.A

// Shake Item
if (Wiimote1.RelAccX > 10) or (Wiimote1.RelAccY > 10) or (Wiimote1.RelAccZ > 10) then
   PPJoy1.Digital7 = true
   wait 100 ms
   PPJoy1.Digital7 = false
   wait 250 ms
endif

// Minus Action
var.HeldTime = 180 ms
var.HeldTime2 = 300 ms
if Released(Wiimote1.Minus) then
   if !var.Held1 then
      PPJoy1.Digital4 = true
      PPJoy1.Digital6 = false
      wait 60 ms
      PPJoy1.Digital4 = false
   else
      var.Held1 = false
   endif
else
   if Pressed(HeldDown(Wiimote1.Minus, var.HeldTime)) then
      PPJoy1.Digital4 = false
      PPJoy1.Digital6 = true
      wait 60 ms
      PPJoy1.Digital6 = false
      var.Held1 = true
   endif
endif

// Home Action
if Released(Wiimote1.Home) then
   if !var.Held11 then
      var.ChangeMode1 = true
      wait 60 ms
      var.ChangeMode1 = 0
   else
      var.Held11 = false
   endif
else
   if Pressed(HeldDown(Wiimote1.Home, var.HeldTime2)) then
      var.ChangeMode1 = 0
      var.WiimoteCalibrate1 = 2
      wait 60 ms
      var.WiimoteCalibrate1 = 1
      var.Held11 = true
   endif
endif

// Plus Action
if Released(Wiimote1.Plus) then
   if !var.Held111 then
      PPJoy1.Digital3 = false
      PPJoy1.Digital5 = true
      wait 60 ms
      PPJoy1.Digital5 = false
   else
      var.Held111 = false
   endif
else
   if Pressed(HeldDown(Wiimote1.Plus, var.HeldTime2)) then
      PPJoy1.Digital5 = false
      PPJoy1.Digital3 = true
      wait 60 ms
      PPJoy1.Digital3 = false
      var.Held111 = true
   endif
endif

// Enable/disable motion by pressing Home
if var.ChangeMode1 = true and var.MotionOff1 = 0 and var.XD1 = 0 then
var.XD1 = true
var.MotionOff1 = true
wait 100 ms
var.XD1 = 0
endif
if var.ChangeMode1 = true and var.MotionOff1 = true and var.XD1 = 0 then
var.XD1 = true
var.MotionOff1 = 0
wait 100 ms
var.XD1 = 0
endif

// 1 Actions
if ((Wiimote1.Two = true) and (Wiimote1.One = true)) or (Wiimote1.B = true) then
  PPJoy1.Digital2 = true
  PPJoy1.Digital1 = false
endif

if (Wiimote1.Two = false) and (Wiimote1.One = true) and (Wiimote1.B = false) then
  PPJoy1.Digital1 = true
  PPJoy1.Digital2 = false
endif

if (Wiimote1.Two = false) and (Wiimote1.One = true) and (Wiimote1.B = true) then
  PPJoy1.Digital1 = true
  PPJoy1.Digital2 = true
endif

if (Wiimote1.One = false) and (Wiimote1.B = false) then
  PPJoy1.Digital1 = false
  PPJoy1.Digital2 = false
endif

endif

// - WIIMOTE + NUNCHUK -

if var.Expansion1 = 1 then
var.WiimoteCalibrate1 = false

// Nunchuk Movement
PPJoy1.analog0 = Wiimote1.Nunchuk.JoyX
PPJoy1.analog1 = Wiimote1.Nunchuk.JoyY
if Wiimote1.Up then
  PPJoy1.analog1 = -1
endif
if Wiimote1.Down then
  PPJoy1.analog1 = 1
endif
if Wiimote1.Left then
  PPJoy1.analog0 = -1
endif
if Wiimote1.Right then
  PPJoy1.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy1.Digital0 = Wiimote1.A
PPJoy1.Digital3 = Wiimote1.Two
PPJoy1.Digital4 = Wiimote1.Minus
PPJoy1.Digital5 = Wiimote1.Plus

// Digital Buttons in Nunchuk
PPJoy1.Digital6 = Wiimote1.Nunchuk.CButton
PPJoy1.Digital7 = Wiimote1.Nunchuk.ZButton

// B Actions
if ((Wiimote1.A = true) and (Wiimote1.B = true)) or (Wiimote1.One = true) then
  PPJoy1.Digital2 = true
  PPJoy1.Digital1 = false
endif

if (Wiimote1.A = false) and (Wiimote1.B = true) and (Wiimote1.One = false) then
  PPJoy1.Digital1 = true
  PPJoy1.Digital2 = false
endif

if (Wiimote1.A = false) and (Wiimote1.B = true) and (Wiimote1.One = true) then
  PPJoy1.Digital1 = true
  PPJoy1.Digital2 = true
endif

if (Wiimote1.B = false) and (Wiimote1.One = false) then
  PPJoy1.Digital1 = false
  PPJoy1.Digital2 = false
endif

endif

// - CLASSIC CONTROLLER -

if var.Expansion1 = 2 then
var.WiimoteCalibrate1 = false

// Movement
PPJoy1.analog0 = Wiimote1.Classic.Joy1X
PPJoy1.analog1 = Wiimote1.Classic.Joy1Y
if Wiimote1.Classic.Up then
  PPJoy1.analog1 = -1
endif
if Wiimote1.Classic.Down then
  PPJoy1.analog1 = 1
endif
if Wiimote1.Classic.Left then
  PPJoy1.analog0 = -1
endif
if Wiimote1.Classic.Right then
  PPJoy1.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy1.Digital0 = Wiimote1.Classic.a
PPJoy1.Digital1 = Wiimote1.Classic.b
PPJoy1.Digital2 = Wiimote1.Classic.R
PPJoy1.Digital3 = Wiimote1.Classic.ZL
PPJoy1.Digital4 = Wiimote1.Classic.Minus
PPJoy1.Digital5 = Wiimote1.Classic.Plus
PPJoy1.Digital6 = Wiimote1.Classic.ZR or Wiimote1.Classic.x
PPJoy1.Digital7 = Wiimote1.Classic.L

endif

// - GUITAR -
if var.Expansion1 = 3 then
PPJoy1.analog0 = 0
PPJoy1.analog1 = 0
PPJoy1.Digital5 = Wiimote1.Guitar.Plus or Wiimote1.Plus
endif

//********************P2********************

// - WIIMOTE -

if var.Expansion2 = 0 then

// Calibrate Wiimote if Home is holded for 2 seconds
if var.WiimoteCalibrate2 = 0 then
var.PitchTrim2 = 6
endif
if var.WiimoteCalibrate2 = 1 then
wait 10 ms
endif
if var.WiimoteCalibrate2 = 2 then
wait 100 ms
var.PitchTrim2 = Wiimote2.SmoothPitch
endif

// Set the pitch- and roll-values to zero by using the trim-values
var.Pitch2 = Wiimote2.SmoothPitch + var.PitchTrim2

// Assignment of the axis
if var.MotionOff2 = 0 then
PPjoy2.Analog0 = (var.Pitch2 / 78)
endif

// Movement
if Wiimote2.Right then
  PPJoy2.analog1 = -1
endif
if Wiimote2.Left then
  PPJoy2.analog1 = 1
endif
if (not(Wiimote2.Left)) and (not(Wiimote2.Right)) then
  PPJoy2.analog1 = 0
endif
if Wiimote2.Up then
  PPJoy2.analog0 = -1
endif
if Wiimote2.Down then
  PPJoy2.analog0 = 1
endif
if var.MotionOff2 = true then
if (not(Wiimote2.Up)) and (not(Wiimote2.Down)) then
  PPJoy2.analog0 = 0
endif
endif

// Digital Buttons in Wiimote
PPJoy2.Digital0 = Wiimote2.Two
PPJoy2.Digital7 = Wiimote2.A

// Shake Item
if (Wiimote2.RelAccX > 10) or (Wiimote2.RelAccY > 10) or (Wiimote2.RelAccZ > 10) then
   PPJoy2.Digital7 = true
   wait 150 ms
   PPJoy2.Digital7 = false
   wait 250 ms
   endif

// Minus Action
var.HeldTime = 180 ms
var.HeldTime2 = 300 ms
if Released(Wiimote2.Minus) then
   if !var.Held2 then
      PPJoy2.Digital4 = true
      PPJoy2.Digital6 = false
      wait 60 ms
      PPJoy2.Digital4 = false
   else
      var.Held2 = false
   endif
else
   if Pressed(HeldDown(Wiimote2.Minus, var.HeldTime)) then
      PPJoy2.Digital4 = false
      PPJoy2.Digital6 = true
      wait 60 ms
      PPJoy2.Digital6 = false
      var.Held2 = true
   endif
endif

// Home Action
if Released(Wiimote2.Home) then
   if !var.Held22 then
      var.ChangeMode2 = true
      wait 60 ms
      var.ChangeMode2 = 0
   else
      var.Held22 = false
   endif
else
   if Pressed(HeldDown(Wiimote2.Home, var.HeldTime2)) then
      var.ChangeMode2 = 0
      var.WiimoteCalibrate2 = 2
      wait 60 ms
      var.WiimoteCalibrate2 = 1
      var.Held22 = true
   endif
endif

// Plus Action
if Released(Wiimote2.Plus) then
   if !var.Held222 then
      PPJoy2.Digital3 = false
      PPJoy2.Digital5 = true
      wait 60 ms
      PPJoy2.Digital5 = false
   else
      var.Held222 = false
   endif
else
   if Pressed(HeldDown(Wiimote2.Plus, var.HeldTime2)) then
      PPJoy2.Digital5 = false
      PPJoy2.Digital3 = true
      wait 60 ms
      PPJoy2.Digital3 = false
      var.Held222 = true
   endif
endif

// Enable/disable motion by pressing Home
if var.ChangeMode2 = true and var.MotionOff2 = 0 and var.XD2 = 0 then
var.XD2 = true
var.MotionOff2 = true
wait 100 ms
var.XD2 = 0
endif
if var.ChangeMode2 = true and var.MotionOff2 = true and var.XD2 = 0 then
var.XD2 = true
var.MotionOff2 = 0
wait 100 ms
var.XD2 = 0
endif

// 1 Actions
if ((Wiimote2.Two = true) and (Wiimote2.One = true)) or (Wiimote2.B = true) then
  PPJoy2.Digital2 = true
  PPJoy2.Digital1 = false
endif

if (Wiimote2.Two = false) and (Wiimote2.One = true) and (Wiimote2.B = false) then
  PPJoy2.Digital1 = true
  PPJoy2.Digital2 = false
endif

if (Wiimote2.Two = false) and (Wiimote2.One = true) and (Wiimote2.B = true) then
  PPJoy2.Digital1 = true
  PPJoy2.Digital2 = true
endif

if (Wiimote2.One = false) and (Wiimote2.B = false) then
  PPJoy2.Digital1 = false
  PPJoy2.Digital2 = false
endif

endif

// - WIIMOTE + NUNCHUK -

if var.Expansion2 = 1 then
var.WiimoteCalibrate2 = false

// Nunchuk Movement
PPJoy2.analog0 = Wiimote2.Nunchuk.JoyX
PPJoy2.analog1 = Wiimote2.Nunchuk.JoyY
if Wiimote2.Up then
  PPJoy2.analog1 = -1
endif
if Wiimote2.Down then
  PPJoy2.analog1 = 1
endif
if Wiimote2.Left then
  PPJoy2.analog0 = -1
endif
if Wiimote2.Right then
  PPJoy2.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy2.Digital0 = Wiimote2.A
PPJoy2.Digital3 = Wiimote2.Two
PPJoy2.Digital4 = Wiimote2.Minus
PPJoy2.Digital5 = Wiimote2.Plus

// Digital Buttons in Nunchuk
PPJoy2.Digital6 = Wiimote2.Nunchuk.CButton
PPJoy2.Digital7 = Wiimote2.Nunchuk.ZButton

// B Actions
if ((Wiimote2.A = true) and (Wiimote2.B = true)) or (Wiimote2.One = true) then
  PPJoy2.Digital2 = true
  PPJoy2.Digital1 = false
endif

if (Wiimote2.A = false) and (Wiimote2.B = true) and (Wiimote2.One = false) then
  PPJoy2.Digital1 = true
  PPJoy2.Digital2 = false
endif

if (Wiimote2.A = false) and (Wiimote2.B = true) and (Wiimote2.One = true) then
  PPJoy2.Digital1 = true
  PPJoy2.Digital2 = true
endif

if (Wiimote2.B = false) and (Wiimote2.One = false) then
  PPJoy2.Digital1 = false
  PPJoy2.Digital2 = false
endif

endif

// - CLASSIC CONTROLLER -

if var.Expansion2 = 2 then
var.WiimoteCalibrate2 = false

// Movement
PPJoy2.analog0 = Wiimote2.Classic.Joy1X
PPJoy2.analog1 = Wiimote2.Classic.Joy1Y
if Wiimote2.Classic.Up then
  PPJoy2.analog1 = -1
endif
if Wiimote2.Classic.Down then
  PPJoy2.analog1 = 1
endif
if Wiimote2.Classic.Left then
  PPJoy2.analog0 = -1
endif
if Wiimote2.Classic.Right then
  PPJoy2.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy2.Digital0 = Wiimote2.Classic.a
PPJoy2.Digital1 = Wiimote2.Classic.b
PPJoy2.Digital2 = Wiimote2.Classic.R
PPJoy2.Digital3 = Wiimote2.Classic.ZL
PPJoy2.Digital4 = Wiimote2.Classic.Minus
PPJoy2.Digital5 = Wiimote2.Classic.Plus
PPJoy2.Digital6 = Wiimote2.Classic.ZR or Wiimote2.Classic.x
PPJoy2.Digital7 = Wiimote2.Classic.L

endif

// - GUITAR -
if var.Expansion2 = 3 then
PPJoy2.analog0 = 0
PPJoy2.analog1 = 0
PPJoy2.Digital5 = Wiimote2.Guitar.Plus or Wiimote2.Plus
endif

//********************P3********************

// - WIIMOTE -

if var.Expansion3 = 0 then

// Calibrate Wiimote if Home is holded for 2 seconds
if var.WiimoteCalibrate3 = 0 then
var.PitchTrim3 = 6
endif
if var.WiimoteCalibrate3 = 1 then
wait 10 ms
endif
if var.WiimoteCalibrate3 = 2 then
wait 100 ms
var.PitchTrim3 = Wiimote3.SmoothPitch
endif

// Set the pitch- and roll-values to zero by using the trim-values
var.Pitch3 = Wiimote3.SmoothPitch + var.PitchTrim3

// Assignment of the axis
if var.MotionOff3 = 0 then
PPjoy3.Analog0 = (var.Pitch3 / 78)
endif

// Movement
if Wiimote3.Right then
  PPJoy3.analog1 = -1
endif
if Wiimote3.Left then
  PPJoy3.analog1 = 1
endif
if (not(Wiimote3.Left)) and (not(Wiimote3.Right)) then
  PPJoy3.analog1 = 0
endif
if Wiimote3.Up then
  PPJoy3.analog0 = -1
endif
if Wiimote3.Down then
  PPJoy3.analog0 = 1
endif
if var.MotionOff3 = true then
if (not(Wiimote3.Up)) and (not(Wiimote3.Down)) then
  PPJoy3.analog0 = 0
endif
endif

// Digital Buttons in Wiimote
PPJoy3.Digital0 = Wiimote3.Two
PPJoy3.Digital7 = Wiimote3.A

// Shake Item
if (Wiimote3.RelAccX > 10) or (Wiimote3.RelAccY > 10) or (Wiimote3.RelAccZ > 10) then
   PPJoy3.Digital7 = true
   wait 150 ms
   PPJoy3.Digital7 = false
   wait 250 ms
   endif

// Minus Action
var.HeldTime = 180 ms
var.HeldTime2 = 300 ms
if Released(Wiimote3.Minus) then
   if !var.Held3 then
      PPJoy3.Digital4 = true
      PPJoy3.Digital6 = false
      wait 60 ms
      PPJoy3.Digital4 = false
   else
      var.Held3 = false
   endif
else
   if Pressed(HeldDown(Wiimote3.Minus, var.HeldTime)) then
      PPJoy3.Digital4 = false
      PPJoy3.Digital6 = true
      wait 60 ms
      PPJoy3.Digital6 = false
      var.Held3 = true
   endif
endif

// Home Action
if Released(Wiimote3.Home) then
   if !var.Held33 then
      var.ChangeMode3 = true
      wait 60 ms
      var.ChangeMode3 = 0
   else
      var.Held33 = false
   endif
else
   if Pressed(HeldDown(Wiimote3.Home, var.HeldTime2)) then
      var.ChangeMode3 = 0
      var.WiimoteCalibrate3 = 2
      wait 60 ms
      var.WiimoteCalibrate3 = 1
      var.Held33 = true
   endif
endif

// Plus Action
if Released(Wiimote3.Plus) then
   if !var.Held333 then
      PPJoy3.Digital3 = false
      PPJoy3.Digital5 = true
      wait 60 ms
      PPJoy3.Digital5 = false
   else
      var.Held333 = false
   endif
else
   if Pressed(HeldDown(Wiimote3.Plus, var.HeldTime2)) then
      PPJoy3.Digital5 = false
      PPJoy3.Digital3 = true
      wait 60 ms
      PPJoy3.Digital3 = false
      var.Held333 = true
   endif
endif

// Enable/disable motion by pressing Home
if var.ChangeMode3 = true and var.MotionOff3 = 0 and var.XD3 = 0 then
var.XD3 = true
var.MotionOff3 = true
wait 100 ms
var.XD3 = 0
endif
if var.ChangeMode3 = true and var.MotionOff3 = true and var.XD3 = 0 then
var.XD3 = true
var.MotionOff3 = 0
wait 100 ms
var.XD3 = 0
endif

// 1 Actions
if ((Wiimote3.Two = true) and (Wiimote3.One = true)) or (Wiimote3.B = true) then
  PPJoy3.Digital2 = true
  PPJoy3.Digital1 = false
endif

if (Wiimote3.Two = false) and (Wiimote3.One = true) and (Wiimote3.B = false) then
  PPJoy3.Digital1 = true
  PPJoy3.Digital2 = false
endif

if (Wiimote3.Two = false) and (Wiimote3.One = true) and (Wiimote3.B = true) then
  PPJoy3.Digital1 = true
  PPJoy3.Digital2 = true
endif

if (Wiimote3.One = false) and (Wiimote3.B = false) then
  PPJoy3.Digital1 = false
  PPJoy3.Digital2 = false
endif

endif

// - WIIMOTE + NUNCHUK -

if var.Expansion3 = 1 then
var.WiimoteCalibrate3 = false

// Nunchuk Movement
PPJoy3.analog0 = Wiimote3.Nunchuk.JoyX
PPJoy3.analog1 = Wiimote3.Nunchuk.JoyY
if Wiimote3.Up then
  PPJoy3.analog1 = -1
endif
if Wiimote3.Down then
  PPJoy3.analog1 = 1
endif
if Wiimote3.Left then
  PPJoy3.analog0 = -1
endif
if Wiimote3.Right then
  PPJoy3.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy3.Digital0 = Wiimote3.A
PPJoy3.Digital3 = Wiimote3.Two
PPJoy3.Digital4 = Wiimote3.Minus
PPJoy3.Digital5 = Wiimote3.Plus

// Digital Buttons in Nunchuk
PPJoy3.Digital6 = Wiimote3.Nunchuk.CButton
PPJoy3.Digital7 = Wiimote3.Nunchuk.ZButton

// B Actions
if ((Wiimote3.A = true) and (Wiimote3.B = true)) or (Wiimote3.One = true) then
  PPJoy3.Digital2 = true
  PPJoy3.Digital1 = false
endif

if (Wiimote3.A = false) and (Wiimote3.B = true) and (Wiimote3.One = false) then
  PPJoy3.Digital1 = true
  PPJoy3.Digital2 = false
endif

if (Wiimote3.A = false) and (Wiimote3.B = true) and (Wiimote3.One = true) then
  PPJoy3.Digital1 = true
  PPJoy3.Digital2 = true
endif

if (Wiimote3.B = false) and (Wiimote3.One = false) then
  PPJoy3.Digital1 = false
  PPJoy3.Digital2 = false
endif

endif

// - CLASSIC CONTROLLER -

if var.Expansion3 = 2 then
var.WiimoteCalibrate3 = false

// Movement
PPJoy3.analog0 = Wiimote3.Classic.Joy1X
PPJoy3.analog1 = Wiimote3.Classic.Joy1Y
if Wiimote3.Classic.Up then
  PPJoy3.analog1 = -1
endif
if Wiimote3.Classic.Down then
  PPJoy3.analog1 = 1
endif
if Wiimote3.Classic.Left then
  PPJoy3.analog0 = -1
endif
if Wiimote3.Classic.Right then
  PPJoy3.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy3.Digital0 = Wiimote3.Classic.a
PPJoy3.Digital1 = Wiimote3.Classic.b
PPJoy3.Digital2 = Wiimote3.Classic.R
PPJoy3.Digital3 = Wiimote3.Classic.ZL
PPJoy3.Digital4 = Wiimote3.Classic.Minus
PPJoy3.Digital5 = Wiimote3.Classic.Plus
PPJoy3.Digital6 = Wiimote3.Classic.ZR or Wiimote3.Classic.x
PPJoy3.Digital7 = Wiimote3.Classic.L

endif

// - GUITAR -
if var.Expansion3 = 3 then
PPJoy3.analog0 = 0
PPJoy3.analog1 = 0
PPJoy3.Digital5 = Wiimote3.Guitar.Plus or Wiimote3.Plus
endif

//********************P4********************

// - WIIMOTE -

if var.Expansion4 = 0 then

// Calibrate Wiimote if Home is holded for 2 seconds
if var.WiimoteCalibrate4 = 0 then
var.PitchTrim4 = 6
endif
if var.WiimoteCalibrate4 = 1 then
wait 10 ms
endif
if var.WiimoteCalibrate4 = 2 then
wait 100 ms
var.PitchTrim4 = Wiimote4.SmoothPitch
endif

// Set the pitch- and roll-values to zero by using the trim-values
var.Pitch4 = Wiimote4.SmoothPitch + var.PitchTrim4

// Assignment of the axis
if var.MotionOff4 = 0 then
PPjoy4.Analog0 = (var.Pitch4 / 78)
endif

// Movement
if Wiimote4.Right then
  PPJoy4.analog1 = -1
endif
if Wiimote4.Left then
  PPJoy4.analog1 = 1
endif
if (not(Wiimote4.Left)) and (not(Wiimote4.Right)) then
  PPJoy4.analog1 = 0
endif
if Wiimote4.Up then
  PPJoy4.analog0 = -1
endif
if Wiimote4.Down then
  PPJoy4.analog0 = 1
endif
if var.MotionOff4 = true then
if (not(Wiimote4.Up)) and (not(Wiimote4.Down)) then
  PPJoy4.analog0 = 0
endif
endif

// Digital Buttons in Wiimote
PPJoy4.Digital0 = Wiimote4.Two
PPJoy4.Digital5 = Wiimote4.Plus
PPJoy4.Digital7 = Wiimote4.A

// Shake Item
if (Wiimote4.RelAccX > 10) or (Wiimote4.RelAccY > 10) or (Wiimote4.RelAccZ > 10) then
   PPJoy4.Digital7 = true
   wait 150 ms
   PPJoy4.Digital7 = false
   wait 250 ms
   endif

// Minus Action
var.HeldTime = 180 ms
var.HeldTime2 = 300 ms
if Released(Wiimote4.Minus) then
   if !var.Held4 then
      PPJoy4.Digital4 = true
      PPJoy4.Digital6 = false
      wait 60 ms
      PPJoy4.Digital4 = false
   else
      var.Held4 = false
   endif
else
   if Pressed(HeldDown(Wiimote4.Minus, var.HeldTime)) then
      PPJoy4.Digital4 = false
      PPJoy4.Digital6 = true
      wait 60 ms
      PPJoy4.Digital6 = false
      var.Held4 = true
   endif
endif

// Home Action
if Released(Wiimote4.Home) then
   if !var.Held44 then
      var.ChangeMode4 = true
      wait 60 ms
      var.ChangeMode4 = 0
   else
      var.Held44 = false
   endif
else
   if Pressed(HeldDown(Wiimote4.Home, var.HeldTime2)) then
      var.ChangeMode4 = 0
      var.WiimoteCalibrate4 = 2
      wait 60 ms
      var.WiimoteCalibrate4 = 1
      var.Held44 = true
   endif
endif

// Plus Action
if Released(Wiimote4.Plus) then
   if !var.Held444 then
      PPJoy4.Digital3 = false
      PPJoy4.Digital5 = true
      wait 60 ms
      PPJoy4.Digital5 = false
   else
      var.Held444 = false
   endif
else
   if Pressed(HeldDown(Wiimote4.Plus, var.HeldTime2)) then
      PPJoy4.Digital5 = false
      PPJoy4.Digital3 = true
      wait 60 ms
      PPJoy4.Digital3 = false
      var.Held444 = true
   endif
endif

// Enable/disable motion by pressing Home
if var.ChangeMode4 = true and var.MotionOff4 = 0 and var.XD4 = 0 then
var.XD4 = true
var.MotionOff4 = true
wait 100 ms
var.XD4 = 0
endif
if var.ChangeMode4 = true and var.MotionOff4 = true and var.XD4 = 0 then
var.XD4 = true
var.MotionOff4 = 0
wait 100 ms
var.XD4 = 0
endif

// 1 Actions
if ((Wiimote4.Two = true) and (Wiimote4.One = true)) or (Wiimote4.B = true) then
  PPJoy4.Digital2 = true
  PPJoy4.Digital1 = false
endif

if (Wiimote4.Two = false) and (Wiimote4.One = true) and (Wiimote4.B = false) then
  PPJoy4.Digital1 = true
  PPJoy4.Digital2 = false
endif

if (Wiimote4.Two = false) and (Wiimote4.One = true) and (Wiimote4.B = true) then
  PPJoy4.Digital1 = true
  PPJoy4.Digital2 = true
endif

if (Wiimote4.One = false) and (Wiimote4.B = false) then
  PPJoy4.Digital1 = false
  PPJoy4.Digital2 = false
endif

endif

// - WIIMOTE + NUNCHUK -

if var.Expansion4 = 1 then
var.WiimoteCalibrate4 = false

// Nunchuk Movement
PPJoy4.analog0 = Wiimote4.Nunchuk.JoyX
PPJoy4.analog1 = Wiimote4.Nunchuk.JoyY
if Wiimote4.Up then
  PPJoy4.analog1 = -1
endif
if Wiimote4.Down then
  PPJoy4.analog1 = 1
endif
if Wiimote4.Left then
  PPJoy4.analog0 = -1
endif
if Wiimote4.Right then
  PPJoy4.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy4.Digital0 = Wiimote4.A
PPJoy4.Digital3 = Wiimote4.Two
PPJoy4.Digital4 = Wiimote4.Minus
PPJoy4.Digital5 = Wiimote4.Plus

// Digital Buttons in Nunchuk
PPJoy4.Digital6 = Wiimote4.Nunchuk.CButton
PPJoy4.Digital7 = Wiimote4.Nunchuk.ZButton

// B Actions
if ((Wiimote4.A = true) and (Wiimote4.B = true)) or (Wiimote4.One = true) then
  PPJoy4.Digital2 = true
  PPJoy4.Digital1 = false
endif

if (Wiimote4.A = false) and (Wiimote4.B = true) and (Wiimote4.One = false) then
  PPJoy4.Digital1 = true
  PPJoy4.Digital2 = false
endif

if (Wiimote4.A = false) and (Wiimote4.B = true) and (Wiimote4.One = true) then
  PPJoy4.Digital1 = true
  PPJoy4.Digital2 = true
endif

if (Wiimote4.B = false) and (Wiimote4.One = false) then
  PPJoy4.Digital1 = false
  PPJoy4.Digital2 = false
endif

endif

// - CLASSIC CONTROLLER -

if var.Expansion4 = 2 then
var.WiimoteCalibrate4 = false

// Movement
PPJoy4.analog0 = Wiimote4.Classic.Joy1X
PPJoy4.analog1 = Wiimote4.Classic.Joy1Y
if Wiimote4.Classic.Up then
  PPJoy4.analog1 = -1
endif
if Wiimote4.Classic.Down then
  PPJoy4.analog1 = 1
endif
if Wiimote4.Classic.Left then
  PPJoy4.analog0 = -1
endif
if Wiimote4.Classic.Right then
  PPJoy4.analog0 = 1
endif

// Digital Buttons in Wiimote
PPJoy4.Digital0 = Wiimote4.Classic.a
PPJoy4.Digital1 = Wiimote4.Classic.b
PPJoy4.Digital2 = Wiimote4.Classic.R
PPJoy4.Digital3 = Wiimote4.Classic.ZL
PPJoy4.Digital4 = Wiimote4.Classic.Minus
PPJoy4.Digital5 = Wiimote4.Classic.Plus
PPJoy4.Digital6 = Wiimote4.Classic.ZR or Wiimote4.Classic.x
PPJoy4.Digital7 = Wiimote4.Classic.L

endif

// - GUITAR -
if var.Expansion4 = 3 then
PPJoy4.analog0 = 0
PPJoy4.analog1 = 0
PPJoy4.Digital5 = Wiimote4.Guitar.Plus or Wiimote4.Plus
endif

//*******************LEDs*******************

// ---P1---

if var.MotionOff1 = 0 and var.AllLeds1 = 0 then
Wiimote1.Led1=true
Wiimote1.Led2=false
Wiimote1.Led3=false
Wiimote1.Led4=false
endif

if var.MotionOff1 = true and var.AllLeds1 = 0 then
Wiimote1.Led1=false
Wiimote1.Led2=false
Wiimote1.Led3=false
Wiimote1.Led4=false
wait 600 ms
Wiimote1.Led1=true
Wiimote1.Led2=false
Wiimote1.Led3=false
Wiimote1.Led4=false
wait 400 ms
endif

if var.WiimoteCalibrate1 = 2 then
var.AllLeds1 = true
endif
if var.AllLeds1 = true then
Wiimote2.Led1=true
Wiimote2.Led2=false
Wiimote2.Led3=false
Wiimote2.Led4=false
wait 50 ms
Wiimote2.Led1=true
Wiimote1.Led2=true
Wiimote1.Led3=false
Wiimote1.Led4=false
wait 50 ms
Wiimote1.Led1=true
Wiimote1.Led2=true
Wiimote1.Led3=true
Wiimote1.Led4=false
wait 50 ms
Wiimote1.Led1=true
Wiimote1.Led2=true
Wiimote1.Led3=true
Wiimote1.Led4=true
wait 200 ms
Wiimote1.Led1=false
Wiimote1.Led2=true
Wiimote1.Led3=true
Wiimote1.Led4=true
wait 50 ms
Wiimote1.Led1=false
Wiimote1.Led2=false
Wiimote1.Led3=true
Wiimote1.Led4=true
wait 50 ms
Wiimote1.Led1=false
Wiimote1.Led2=false
Wiimote1.Led3=false
Wiimote1.Led4=true
wait 50 ms
Wiimote1.Led1=false
Wiimote1.Led2=false
Wiimote1.Led3=false
Wiimote1.Led4=false
wait 200 ms
Wiimote1.Led1=true
Wiimote1.Led2=false
Wiimote1.Led3=false
Wiimote1.Led4=false
var.AllLeds1 = 0
endif

// ---P2---

if var.MotionOff2 = 0 and var.AllLeds2 = 0 then
Wiimote2.Led1=false
Wiimote2.Led2=true
Wiimote2.Led3=false
Wiimote2.Led4=false
endif

if var.MotionOff2 = true and var.AllLeds2 = 0 then
Wiimote2.Led1=false
Wiimote2.Led2=false
Wiimote2.Led3=false
Wiimote2.Led4=false
wait 600 ms
Wiimote2.Led1=false
Wiimote2.Led2=true
Wiimote2.Led3=false
Wiimote2.Led4=false
wait 400 ms
endif

if var.WiimoteCalibrate2 = 2 then
var.AllLeds2 = true
endif
if var.AllLeds2 = true then
Wiimote2.Led1=false
Wiimote2.Led2=true
Wiimote2.Led3=false
Wiimote2.Led4=true
wait 100 ms
Wiimote2.Led1=false
Wiimote2.Led2=false
Wiimote2.Led3=true
Wiimote2.Led4=true
wait 100 ms
Wiimote2.Led1=true
Wiimote2.Led2=false
Wiimote2.Led3=true
Wiimote2.Led4=false
wait 100 ms
Wiimote2.Led1=true
Wiimote2.Led2=true
Wiimote2.Led3=false
Wiimote2.Led4=false
wait 100 ms
Wiimote2.Led1=false
Wiimote2.Led2=true
Wiimote2.Led3=true
Wiimote2.Led4=false
wait 100 ms
Wiimote2.Led1=false
Wiimote2.Led2=false
Wiimote2.Led3=false
Wiimote2.Led4=false
wait 200 ms
Wiimote2.Led1=false
Wiimote2.Led2=true
Wiimote2.Led3=false
Wiimote2.Led4=false
var.AllLeds2 = 0
endif

// ---P3---

if var.MotionOff3 = 0 and var.AllLeds3 = 0 then
Wiimote3.Led1=false
Wiimote3.Led2=false
Wiimote3.Led3=true
Wiimote3.Led4=false
endif

if var.MotionOff3 = true and var.AllLeds3 = 0 then
Wiimote3.Led1=false
Wiimote3.Led2=false
Wiimote3.Led3=false
Wiimote3.Led4=false
wait 600 ms
Wiimote3.Led1=false
Wiimote3.Led2=false
Wiimote3.Led3=true
Wiimote3.Led4=false
wait 400 ms
endif

if var.WiimoteCalibrate3 = 2 then
var.AllLeds3 = true
endif
if var.AllLeds3 = true then
Wiimote3.Led1=false
Wiimote3.Led2=false
Wiimote3.Led3=true
Wiimote3.Led4=true
wait 100 ms
Wiimote3.Led1=false
Wiimote3.Led2=true
Wiimote3.Led3=true
Wiimote3.Led4=false
wait 100 ms
Wiimote3.Led1=true
Wiimote3.Led2=true
Wiimote3.Led3=false
Wiimote3.Led4=false
wait 100 ms
Wiimote3.Led1=false
Wiimote3.Led2=true
Wiimote3.Led3=true
Wiimote3.Led4=false
wait 100 ms
Wiimote3.Led1=false
Wiimote3.Led2=false
Wiimote3.Led3=true
Wiimote3.Led4=true
wait 100 ms
Wiimote3.Led1=false
Wiimote3.Led2=false
Wiimote3.Led3=false
Wiimote3.Led4=false
wait 200 ms
Wiimote3.Led1=false
Wiimote3.Led2=false
Wiimote3.Led3=true
Wiimote3.Led4=false
var.AllLeds3 = 0
endif

// ---P4---

if var.MotionOff4 = 0 and var.AllLeds4 = 0 then
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=false
Wiimote4.Led4=true
endif

if var.MotionOff4 = true and var.AllLeds4 = 0 then
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=false
Wiimote4.Led4=false
wait 600 ms
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=false
Wiimote4.Led4=true
wait 400 ms
endif

if var.WiimoteCalibrate4 = 2 then
var.AllLeds4 = true
endif
if var.AllLeds4 = true then
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=false
Wiimote4.Led4=true
wait 50 ms
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=true
Wiimote4.Led4=true
wait 50 ms
Wiimote4.Led1=false
Wiimote4.Led2=true
Wiimote4.Led3=true
Wiimote4.Led4=true
wait 50 ms
Wiimote4.Led1=true
Wiimote4.Led2=true
Wiimote4.Led3=true
Wiimote4.Led4=true
wait 200 ms
Wiimote4.Led1=true
Wiimote4.Led2=false
Wiimote4.Led3=true
Wiimote4.Led4=true
wait 50 ms
Wiimote4.Led1=true
Wiimote4.Led2=false
Wiimote4.Led3=true
Wiimote4.Led4=false
wait 50 ms
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=true
Wiimote4.Led4=false
wait 50 ms
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=false
Wiimote4.Led4=false
wait 200 ms
Wiimote4.Led1=false
Wiimote4.Led2=false
Wiimote4.Led3=false
Wiimote4.Led4=true
var.AllLeds4 = 0
endif
Back to top
View user's profile Send private message Send e-mail MSN Messenger
lanasidoog



Joined: 04 Jun 2008
Posts: 6

Digg It
PostPosted: Sun Jul 13, 2008 7:50 pm    Post subject: Synaesthete

Script for Synaesthete

Required:

Balance Board, Nunchuck, Wiimote

Video of my friend playing:
http://www.youtube.com/watch?v=GjI88WH3WbI

Code:
WASD = Nunchuk.Joy

wait 20ms //"Warm-up" time for the Balance Board
//Get initial BB values for offsetting
If !var.init
var.BBinit = Wiimote2.BalanceBoard.Weight
var.init = True
EndIf
var.BB = (Wiimote2.BalanceBoard.Weight - var.BBinit) //"Zeroed balance"
J = (Nunchuk.RawAccY > abs(20)) //Shake Nunchuk for left beats
K = (var.BB > abs(2.5Kg)) //Apply 1Kg or more of weight/pressure to the Balance Board for middle beats
L = (Wiimote.RawAccY > abs(20)) //Shake the Wiimote for right beats
I = (Nunchuk.ZButton and Wiimote.B) //Press Z and B to cast spells

If (Nunchuk.RawAccY > abs(20)) or (var.BB > abs(2.5Kg)) or (Wiimote.RawAccY > abs(20))
Wiimote.Rumble = True
wait 25ms
Wiimote.LEDs = 6
wait 25ms
Wiimote.LEDs = 15
Wiimote.Rumble = False
Else
Wiimote.Rumble = False
Wiimote.LEDs = 0
EndIf


If Wiimote.PointerVisible
(Mouse.X /2) = Wiimote.PointerX
(Mouse.Y /2) = Wiimote.PointerY
EndIf

Mouse.LeftButton = Wiimote.Left //Left mouse button
Mouse.RightButton = Wiimote.Right //Right mouse button
Enter = Wiimote.Plus //Menu enter
Esc = Wiimote.Minus //Menu back
Shift + P + I + E = Wiimote.Home //Stops script running

//Balance Board, Wiimote, and Nunchuk stats
Debug = "BB: " + var.BBinit + ", Wiimote: " + Wiimote.RawAccY + ", Nunchuk: " + Nunchuk.RawAccY

Wiimote2.BalanceBoard.LED = True
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie All times are GMT
Goto page Previous  1, 2, 3 ... 49, 50, 51 ... 53, 54, 55  Next
Page 50 of 55

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group