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, 4 ... 51, 52, 53  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> GlovePie
View previous topic :: View next topic  
Author Message
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Wed Dec 13, 2006 10:23 pm    Post subject:

Calibrator:
Code:
//Wiimote PC Calibrator by Freeman Speaketh/US of Anarchy
//Feel free to modify and redistribute, but leave this here

//Adjust these
var.trimx = 0
var.trimy = 0
var.trimz = 0

var.x = Wiimote.RawForceX + var.trimx
var.y = Wiimote.RawForceY + var.trimy
var.z = Wiimote.RawForceZ + var.trimz
wait 1s

debug = "Add " + var.x * -1 + " to X,  Add " + var.y * -1 + " to Y  Add, " + var.z * -1 + "  to Z"


FPS:
Code:
//Wiimote FPS Controls by Freeman Speaketh/US of Anarchy
//Feel free to modify and redistribute, but leave this here

// Show wiimote forces
debug = "X="+Wiimote.RawForceX+' Y='+Wiimote.RawForceY+' Z='+Wiimote.RawForceZ

//Movement Keys. Works for both arrow keys and WASD.
Keyboard.W and Keyboard.Up = Wiimote.Up
Keyboard.S and Keyboard.Down = Wiimote.Down
Keyboard.A and Keyboard.Left = Wiimote.Left
Keyboard.D and Keyboard.Right = Wiimote.Right

//Key assignments. Feel Free to change
Keyboard.Esc = Wiimote.Home
Keyboard.Space = Wiimote.One
Keyboard.E and Keyboard.F = Wiimote.Two
Keyboard.R = Wiimote.Plus
Keyboard.G = Wiimote.Minus

//You might want to switch these depending on your tastes
Mouse.LeftButton = Wiimote.B
Mouse.RightButton = Wiimote.A

//Controls rumble
//Note: If for some reason your game uses the apostrophe key, change this!
if Wiimote.A = 1 and Keyboard.Apostrophe = 0
Wiimote.Rumble = 1
wait 75 ms
wiimote.Rumble = 0
Keyboard.Apostophe = 1
endif

if Wiimote.B = 1 and Keyboard.Apostrophe = 0
Wiimote.Rumble = 1
wait 75 ms
wiimote.Rumble = 0
Keyboard.Apostophe = 1
endif

if Wiimote.A = 0 and Wiimote.B = 0
Keyboard.Apostrophe = 0
endif

//Controls LEDs
if Wiimote.A or Wiimote.B
Wiimote.Led1 = 1
wait 500 ms
Wiimote.Led2 = 1
wait 500 ms
Wiimote.Led3 = 1
wait 500 ms
Wiimote.Led4 = 1
wait 500 ms
endif

if Wiimote.A = 0 and Wiimote.B = 0
Wiimote.Led1 = 0
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 0
endif

// set these to the offsets when the wiimote is at rest
// will be different for each wiimote
var.x = Wiimote.RawForceX +12 //trim to 0
var.y = Wiimote.RawForceY -36 // trim to 0
var.z = Wiimote.RawForceZ +14 //trim to 0

//precision
var.sense0 = 500
var.thresh0x = 5
var.thresh0y = 2

var.sense = 300
var.threshx = 10
var.threshy = 5

var.sense2 = 100
var.thresh2x = 15
var.thresh2y = 8

var.sense3 = 50
var.thresh3x = 20
var.thresh3y = 12

//first sensitivity setting
//xaxis
if var.x > var.thresh0x
mouse.x = mouse.x - 1/var.sense0
endif
if var.x < -var.thresh0x
mouse.x = mouse.x + 1/var.sense0
endif

//yaxis
if var.z > var.thresh0y
mouse.y = mouse.y - 1/var.sense0
endif
if var.z < -var.thresh0y
mouse.y = mouse.y + 1/var.sense0
endif


//second sensitivity setting
//xaxis
if var.x > var.threshx
mouse.x = mouse.x - 1/var.sense
endif
if var.x < -var.threshx
mouse.x = mouse.x + 1/var.sense
endif

//yaxis
if var.z > var.threshy
mouse.y = mouse.y - 1/var.sense
endif
if var.z < -var.threshy
mouse.y = mouse.y + 1/var.sense
endif

//third sensitivity setting
//xaxis
if var.x > var.thresh2x
mouse.x = mouse.x - 1/var.sense2
endif
if var.x < -var.thresh2x
mouse.x = mouse.x + 1/var.sense2
endif

//yaxis
if var.z > var.thresh2y
mouse.y = mouse.y - 1/var.sense2
endif
if var.z < -var.thresh2y
mouse.y = mouse.y + 1/var.sense2
endif

//fourth sensitivity setting
//xaxis
if var.x > var.thresh3x
mouse.x = mouse.x - 1/var.sense3
endif
if var.x < -var.thresh3x
mouse.x = mouse.x + 1/var.sense3
endif

//yaxis
if var.z > var.thresh3y
mouse.y = mouse.y - 1/var.sense3
endif
if var.z < -var.thresh3y
mouse.y = mouse.y + 1/var.sense3
endif


Racing:
Code:
//Wiimote Racing Controls by Freeman Speaketh/US of Anarchy
//Feel free to modify and redistribute, but leave this here

// Show wiimote forces
debug = "X="+Wiimote.RawForceX+' Y='+Wiimote.RawForceY+' Z='+Wiimote.RawForceZ

//LEDs setup
While Wiimote.RawForceZ < -10 and > -20
Keyboard.Left = 0
Keyboard.Right = 0
endif

While Wiimote.RawForceZ < -10 and > -20
Wiimote.Led1 = 0
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 0
endif

While Wiimote.RawForceZ > -10 and < -5
Wiimote.Led1 = 1
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 0
wait 500 ms
endif

While Wiimote.RawForceZ > -5 and < 0
Wiimote.Led1 = 1
Wiimote.Led2 = 1
Wiimote.Led3 = 0
Wiimote.Led4 = 0
wait 500 ms
endif

While Wiimote.RawForceZ > 0 and < 5
Wiimote.Led1 = 1
Wiimote.Led2 = 1
Wiimote.Led3 = 1
Wiimote.Led4 = 0
wait 500 ms
endif

While Wiimote.RawForceZ > 5
Wiimote.Led1 = 1
Wiimote.Led2 = 1
Wiimote.Led3 = 1
Wiimote.Led4 = 1
wait 500 ms
endif

While Wiimote.RawForceZ < -20 and > -25
Wiimote.Led1 = 1
Wiimote.Led2 = 0
Wiimote.Led3 = 0
Wiimote.Led4 = 0
wait 500 ms
endif

While Wiimote.RawForceZ < -25 and > -30
Wiimote.Led1 = 1
Wiimote.Led2 = 1
Wiimote.Led3 = 0
Wiimote.Led4 = 0
wait 500 ms
endif

While Wiimote.RawForceZ < -30 AND > -35
Wiimote.Led1 = 1
Wiimote.Led2 = 1
Wiimote.Led3 = 1
Wiimote.Led4 = 0
wait 500 ms
endif

While Wiimote.RawForceZ < -35
Wiimote.Led1 = 1
Wiimote.Led2 = 1
Wiimote.Led3 = 1
Wiimote.Led4 = 1
wait 500 ms
endif

//Toggles between mouse mode and racing mode
if wiimote.Home
Toggle Keyboard.Apostrophe
Endif

//Racing Mode:
If Keyboard.Apostrophe

Keyboard.Up = Wiimote.Two
Keyboard.Down = Wiimote.One

If Wiimote.One or Wiimote.Two
Wiimote.Rumble = 1
Else
Wiimote.Rumble = 0
endif

if Wiimote.RawForceZ > 0
Keyboard.Right = 1
endif

if Wiimote.RawForceZ < -30
Keyboard.Left = 1
endif

if Wiimote.RawForceZ > -30 and < 0
Keyboard.Left = 0
Keyboard.Right = 0
endif
endif

//Mouse Mode:
if not Keyboard.Apostrophe

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

// set these to the offsets when the wiimote is at rest
// will be different for each wiimote
var.x = Wiimote.RawForceX +12 //trim to 0
var.y = Wiimote.RawForceY -36 // trim to 0
var.z = Wiimote.RawForceZ +14 //trim to 0

//precision
var.sense0 = 500
var.thresh0x = 5
var.thresh0y = 2

var.sense = 300
var.threshx = 10
var.threshy = 5

var.sense2 = 100
var.thresh2x = 15
var.thresh2y = 8

var.sense3 = 50
var.thresh3x = 20
var.thresh3y = 12
//first sensitivity setting
//xaxis
if var.x > var.thresh0x
mouse.x = mouse.x - 1/var.sense0
endif
if var.x < -var.thresh0x
mouse.x = mouse.x + 1/var.sense0
endif

//yaxis
if var.z > var.thresh0y
mouse.y = mouse.y - 1/var.sense0
endif
if var.z < -var.thresh0y
mouse.y = mouse.y + 1/var.sense0
endif


//second sensitivity setting
//xaxis
if var.x > var.threshx
mouse.x = mouse.x - 1/var.sense
endif
if var.x < -var.threshx
mouse.x = mouse.x + 1/var.sense
endif

//yaxis
if var.z > var.threshy
mouse.y = mouse.y - 1/var.sense
endif
if var.z < -var.threshy
mouse.y = mouse.y + 1/var.sense
endif

//third sensitivity setting
//xaxis
if var.x > var.thresh2x
mouse.x = mouse.x - 1/var.sense2
endif
if var.x < -var.thresh2x
mouse.x = mouse.x + 1/var.sense2
endif

//yaxis
if var.z > var.thresh2y
mouse.y = mouse.y - 1/var.sense2
endif
if var.z < -var.thresh2y
mouse.y = mouse.y + 1/var.sense2
endif

//fourth sensitivity setting
//xaxis
if var.x > var.thresh3x
mouse.x = mouse.x - 1/var.sense3
endif
if var.x < -var.thresh3x
mouse.x = mouse.x + 1/var.sense3
endif

//yaxis
if var.z > var.thresh3y
mouse.y = mouse.y - 1/var.sense3
endif
if var.z < -var.thresh3y
mouse.y = mouse.y + 1/var.sense3
endif
endif
Back to top
View user's profile Send private message Send e-mail
Mienaikage



Joined: 13 Dec 2006
Posts: 54
Location: London, UK

Digg It
PostPosted: Wed Dec 13, 2006 10:31 pm    Post subject:

WiinSaber v1.1

Code:
//Mienaikage's WiinSaber v1.1
//Based on the Mac WiiSaber
//Get all the files you need at http://rapidshare.com/files/7731954/WiinSaber_v1.1.rar.html

var.xOffset = 0
var.yOffset = -10
var.zOffset = -10

var.xRot = Wiimote.RawAccX + var.xOffset
var.yRot = Wiimote.RawAccY + var.yOffset
var.zRot = Wiimote.rawforceZ + var.zOffset


Wiimote.leds = 0

if var.rmbl then
   wiimote.Rumble = 1
   wait 1 ms
   wiimote.Rumble = 0
   wait var.time ms
endif

if var.rmbl = false then
debug = "Press B to turn on your WiinSaber"
endif

if var.rmbl = true then
debug = "Swing. Hold B or Down to change sound effects. Press A to stop."
endif

if (wiimote.b) + (var.on = 0) then
playsound("lightsaber sounds\on0.wav")
var.time = 25
var.rmbl = true
wait(1.35s)
var.on = 1
var.soundon = 1
endif

if var.soundon = 1
playsound("lightsaber sounds\idle0.wav")
var.time = 100
wait(452ms)
endif

if wiimote.a + (var.on = 1) then
playsound("lightsaber sounds\off0.wav")
var.on = 0
var.soundon = 0
var.time = 200
wait(0.5s)
var.rmbl= false
endif

if (var.yrot < -30) + (var.on = 1) + (wiimote.b = 0) + (wiimote.down = 0) then
var.swingy = 1
playsound("lightsaber sounds\swing0.wav")
wait(0.5s)
var.swingy = 0
endif

if (var.xrot > 15) + (var.on = 1) + (wiimote.b = 0) + (wiimote.down = 0) then
var.swingx = 1
playsound("lightsaber sounds\swing1.wav")
wait(0.64s)
var.swingx = 0
endif

if (var.zrot > 20) + (var.on = 1) + (wiimote.b = 0) + (wiimote.down = 0) then
var.swingz = 1
playsound("lightsaber sounds\swing7.wav")
wait(0.53s)
var.swingz = 0
endif

if (var.yrot > 32) + (var.on = 1) + (wiimote.b = 0) + (wiimote.down = 0) then
var.swingminusy = 1
playsound("lightsaber sounds\swing2.wav")
wait(0.85s)
var.swingminusy = 0
endif

if (var.xrot < -15) + (var.on = 1) + (wiimote.b = 0) + (wiimote.down = 0) then
var.swingminusx = 1
playsound("lightsaber sounds\swing5.wav")
wait(0.64s)
var.swingminusx = 0
endif



if (var.yrot > 32) + (var.on = 1) + (wiimote.b = 1) then
playsound("lightsaber sounds\strike0.wav")
var.strikey = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.38s)
var.strikey = 0
endif

if (var.xrot > 15) + (var.on = 1) + (wiimote.b = 1) then
playsound("lightsaber sounds\strike1.wav")
var.strikex = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.23s)
var.strikex = 0
endif

if (var.zrot > 20) + (var.on = 1) + (wiimote.b = 1) then
playsound("lightsaber sounds\strike2.wav")
var.strikez = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.27s)
var.strikez = 0
endif

if (var.yrot < -30) + (var.on = 1) + (wiimote.b = 1) then
playsound("lightsaber sounds\strike0.wav")
var.strikeminusy = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.38s)
var.strikeminusy = 0
endif

if (var.xrot < -15) + (var.on = 1) + (wiimote.b = 1) then
playsound("lightsaber sounds\strike1.wav")
var.strikeminusx = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.23s)
var.strikeminusx = 0
endif



if (var.yrot < -30) + (var.on = 1) + (wiimote.down = 1) then
playsound("lightsaber sounds\hit0.wav")
var.hity = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(1.25s)
var.hity = 0
endif

if (var.xrot > 15) + (var.on = 1) + (wiimote.down = 1) then
playsound("lightsaber sounds\hit3.wav")
var.hitx = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.45s)
var.hitx = 0
endif

if (var.zrot > 20) + (var.on = 1) + (wiimote.down = 1) then
playsound("lightsaber sounds\hit1.wav")
var.hitz = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.8s)
var.hitz = 0
endif

if (var.yrot > 32) + (var.on = 1) + (wiimote.down = 1) then
playsound("lightsaber sounds\hit2.wav")
var.hitminusy = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(1.25s)
var.hitminusy = 0
endif

if (var.xrot < -15) + (var.on = 1) + (wiimote.down = 1) then
playsound("lightsaber sounds\hit4.wav")
var.hitminusx = 1
var.time = 0
Wiimote.Leds = 15
wait(0.3s)
var.time = 50
wait(0.45s)
var.hitminusx = 0
endif



if (var.swingy or var.swingx or var.swingz or var.strikey or var.strikex or var.strikez or var.hity or var.hitx or var.hitz or var.swingminusy or var.swingminusx or var.strikeminusy or var.strikeminusx or var.hitminusy or var.hitminusx) = 1 then
var.soundon = 0
else if var.on = 1
var.soundon = 1
endif


Last edited by Mienaikage on Sat Dec 16, 2006 3:07 pm; edited 16 times in total
Back to top
View user's profile Send private message Visit poster's website
J5892



Joined: 13 Dec 2006
Posts: 33

Digg It
PostPosted: Wed Dec 13, 2006 10:36 pm    Post subject:

I already posted this as a new thread, but I'll post it here now too.

I wrote a Wiimote guitar script. It's fairly simple, and pretty intuitive. The instructions are in the code.

It requires 2 wiimotes.

Code:

/* This is my guitar script.       By  Jordan Sanborn (J5892)
   It requires 2 wiimotes. One to the frets,
   and the other to control picking.

   To control the frets, start by holding wiimote 1 flat for the first fret,
   then for each consecutive fret, tilt it slightly more towards vertical.
   There are 5 possible frets.
   The 4th is vertical, and the fifth is tilted slightly forward from vertical.
   For no fret, hold the "B" button.

   To pick, hold down a button on wiimote 2, and flick your wrist.
   The string keys is as follows:
   B - low E string.
   A - A string.
   Down - D string.
   Left - G string.
   Right - B string.
   Up - high E string.

   To change the buttons to your liking, just use GlovePIE's replace feature,
   search for the current button, and replace it with the one you want.

   To determine which wiimote is which, simply press A on one of them,
   and the debug window will show either "Wiimote 1" or "Wiimote 2".


   More features, such as common chords will come soon.


   (yes, I realize that the sounds are piano sounds, but I don't really know
   anything about midi yet.
   If someone would like to help me out, PM me on the wiili.org forums,
   or IM me. My AIM is J5892.
*/

if wiimote1.A == true
   var.wiinumber = "Wiimote 1"
else if wiimote2.A == true
   var.wiinumber = "Wiimote 2"
endif
debug = var.wiinumber
if wiimote1.gy <= 1.00 && wiimote1.gy >= 0.90
   if var.fret != 0
   wiimote.Led1 = true
   wiimote.Led2 = false
   wiimote.Led3 = false
   wiimote.Led4 = false
   endif
   var.fret = 1

endif
if wiimote1.gy <= 0.89 && wiimote1.gy >= 0.75
   if var.fret != 0
   wiimote.Led1 = false
   wiimote.Led2 = true
   wiimote.Led3 = false
   wiimote.Led4 = false
   endif
   var.fret = 2
endif
if wiimote1.gy <= 0.74 && wiimote1.gy >= 0.54
   if var.fret != 0
   wiimote.Led1 = false
   wiimote.Led2 = false
   wiimote.Led3 = true
   wiimote.Led4 = false
   endif
   var.fret = 3

endif
if wiimote1.gy <= 0.30 && wiimote1.gy >= 0.00
   if var.fret != 0
   wiimote.Led1 = false
   wiimote.Led2 = false
   wiimote.Led3 = false
   wiimote.Led4 = true
   endif
   var.fret = 4
endif
if wiimote1.gy <= -0.10
   if var.fret != 0
   wiimote.Led1 = true
   wiimote.Led2 = false
   wiimote.Led3 = false
   wiimote.Led4 = true
   endif
   var.fret = 5
endif
if wiimote1.B == true
   var.fret = 0
   wiimote.Led1 = false
   wiimote.Led2 = false
   wiimote.Led3 = false
   wiimote.Led4 = false
endif

if MapRange(Wiimote2.RelAccY, -20 m per s per s,20 m per s per s, 0,64) >= 50
if var.fret == 0
   if Wiimote2.B == true
      midi.e3 = true

   endif
   if Wiimote2.A == true
      midi.a3 = true
       
   endif
   if Wiimote2.Down == true
      midi.d4 = true
       
   endif
   if Wiimote2.Left == true
      midi.g4 = true
       
   endif
   if Wiimote2.Right == true
      midi.b4 = true
       
   endif
   if Wiimote2.Up == true
      midi.e5 = true
       
   endif
   wait 150 ms
endif

if var.fret == 1
   if Wiimote2.B == true
      midi.f3 = true

   endif
   if Wiimote2.A == true
      midi.asharp3 = true
       
   endif
   if Wiimote2.Down == true
      midi.dsharp4 = true
       
   endif
   if Wiimote2.Left == true
      midi.gsharp4 = true
       
   endif
   if Wiimote2.Right == true
      midi.c5 = true
       
   endif
   if Wiimote2.Up == true
      midi.f5 = true
       
   endif
   wait 150 ms
endif

if var.fret == 2
   if Wiimote2.B == true
      midi.fsharp3 = true

   endif
   if Wiimote2.A == true
      midi.b3 = true
       
   endif
   if Wiimote2.Down == true
      midi.e4 = true
       
   endif
   if Wiimote2.Left == true
      midi.a4 = true
       
   endif
   if Wiimote2.Right == true
      midi.csharp5 = true
       
   endif
   if Wiimote2.Up == true
      midi.fsharp5 = true
       
   endif
   wait 150 ms
endif

if var.fret == 3
   if Wiimote2.B == true
      midi.g3 = true

   endif
   if Wiimote2.A == true
      midi.c4 = true
       
   endif
   if Wiimote2.Down == true
      midi.f4 = true
       
   endif
   if Wiimote2.Left == true
      midi.asharp4 = true
       
   endif
   if Wiimote2.Right == true
      midi.d5 = true
       
   endif
   if Wiimote2.Up == true
      midi.g5 = true
       
   endif
   wait 150 ms
endif

if var.fret == 4
   if Wiimote2.B == true
      midi.gsharp3 = true

   endif
   if Wiimote2.A == true
      midi.csharp4 = true
       
   endif
   if Wiimote2.Down == true
      midi.fsharp4 = true
       
   endif
   if Wiimote2.Left == true
      midi.b4 = true
       
   endif
   if Wiimote2.Right == true
      midi.dsharp5 = true
       
   endif
   if Wiimote2.Up == true
      midi.gsharp5 = true
       
   endif
   wait 150 ms
endif

if var.fret == 5
   if Wiimote2.B == true
      midi.a3 = true

   endif
   if Wiimote2.A == true
      midi.d4 = true
       
   endif
   if Wiimote2.Down == true
      midi.g4 = true
       
   endif
   if Wiimote2.Left == true
      midi.c5 = true
       
   endif
   if Wiimote2.Right == true
      midi.e5 = true
       
   endif
   if Wiimote2.Up == true
      midi.a5 = true
       
   endif
   wait 150 ms
endif


endif
Back to top
View user's profile Send private message AIM Address
Skeeter8887



Joined: 13 Dec 2006
Posts: 1

Digg It
PostPosted: Wed Dec 13, 2006 11:28 pm    Post subject: Script for DTX Mania

Yeah so I'm sure there are people who are lazy and don't want to figure out a DTX Mania code so here you guys go. I have it set up to use the default keyboard keys.

It's not perfect but it works.

Also I'll have a video soon of me playing a song.

Feel free to comment or suggest better alternatives.

Code:

/* Code created by Charles J. "Skeeter8887"  Skeeter87@comcast.net
   Possible configuration for DTX Mania

   Hats of to Bob of Bobsomers.com for setting up the core of this code.

   So basically here's how it works.

   First off you need two wiimotes. Can't have a drum game without two sticks
   right? Anyway once you have that you're set.

   The controls are a bit weird but I was too lazy to figure out a perfect scheme,
   but for the most part it works. Also you have to strike down in order to play
   the note you want.

   ************************************************
   Wiimote 1 (indicated with LED's)

   No buttons = snare
   A = green tom tom
   Down = red tom tom
   Up = High Hat

   Wiimote 2 (indicated with LED's)

   No buttons = High Hat
   A = red tom tom
   Down = green tom tom
   Up = snare
   ************************************************

   I have yet to figure out how to utilize the bass drum, so for now I just leave
   it on Auto.


   Feel free to change it up to your liking just tell me if you find a better control
   scheme so I can start using it.

   Enjoi ya'll.

*/





var.xOffset = 8
var.yOffset = -37
var.zOffset = 12

var.xRot = Wiimote1.RawForceX + var.xOffset
var.yRot = Wiimote1.RawForceY + var.yOffset
var.zRot = Wiimote1.RawForceZ + var.zOffset

var.xRot2 = Wiimote2.RawForceX + var.xOffset
var.yRot2 = Wiimote2.RawForceY + var.yOffset
var.zRot2 = Wiimote2.RawForceZ + var.zOffset

// Debug
debug = "(X=" + var.xRot + "   Y=" + var.yRot + "   Z=" + var.zRot + ")  (X2=" + var.xRot2 + "   Y=" + var.yRot2 + "   Z=" + var.zRot2 + ")"

// Downward drum beat triggered for Stick 1
if var.yRot > 30 then
   var.Snare = not(Wiimote1.A or Wiimote1.down or Wiimote1.up)
   var.Green = Wiimote1.A and not (Wiimote1.down or Wiimote1.up)
   var.Red = Wiimote1.down and not (Wiimote1.A or Wiimote1.up)
   var.HH = Wiimote1.Up and not (Wiimote1.A or Wiimote1.down)
else
    var.Snare = false
    var.Green = false
    var.Red = false
    var.HH = false
endif

// Downward drum beat triggered for Stick 2
if var.yRot2 > 30 then
   var.Green2 = Wiimote2.Down and not (Wiimote2.A or Wiimote2.B or Wiimote2.Up)
   var.Red2 = Wiimote2.A and not (Wiimote2.down or Wiimote2.B or Wiimote2.Up)
   var.HH2 = not(Wiimote2.A or Wiimote2.down or Wiimote2.B or Wiimote2.Up)
   var.Cym = Wiimote2.B and not (Wiimote2.A or Wiimote2.down or Wiimote2.Up)
   var.Snare2 = Wiimote2.Up and not (Wiimote2.A or Wiimote2.down or Wiimote2.B)
else
    var.Green2 = false
    var.Red2 = false
    var.HH2 = false
    var.Cym = false
    var.Snare2 = false
endif


wiimote1.Leds = 1
wiimote2.Leds = 2

X = var.Snare
X = var.Snare2
V = var.Green
V = var.Green2
B = var.Red
B = var.Red2
Z = var.HH
Z = var.HH2
M = var.Cym
Back to top
View user's profile Send private message
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Thu Dec 14, 2006 2:53 am    Post subject: Wiimote Saber Script

I see that some one beat me to it, but I have a wiimote saber script as well. Try mine out I think you'll like it

Code:
//LiightSaber V 1.0 by Freeman Speaketh/US of Anarchy
//Feel free to modify and redistribute, but leave this here

//Credits to the creators of Mac Saber for the sound effects


// set these to the offsets when the wiimote is at rest
// will be different for each wiimote
var.xOffset = 12
var.yOffset = -36
var.zOffset = 14

//Settings
var.Swing = 20 //Adjusts how far you have to swing
var.Rumble = true //Enables or Disables rumble
var.swingTime = 50 //Adjusts time between swings (in ms)


//Home button exits LiightSaber. Double press exits GlovePIE
if Wiimote.Home
if doubleclicked(Wiimote.Home)
ExitPie
else
wait 200 ms
ExitProgram
endif
endif

//Change these to whatever sounds you like
PlaySound("Sounds/swing0.wav") = var.A
PlaySound("Sounds/swing1.wav") = var.B
PlaySound("Sounds/swing2.wav") = var.C
PlaySound("Sounds/swing3.wav") = var.D
PlaySound("Sounds/swing4.wav") = var.E
PlaySound("Sounds/swing5.wav") = var.F
PlaySound("Sounds/idle0.wav") = var.G

PlaySound("Sounds/on0.wav") = var.H
PlaySound("Sounds/off0.wav") = var.I

//B Toggles Saber on/off
if Wiimote.B = 1 and (var.wait = false or null)
var.wait = true
if var.onOff = false
var.H = true
wait 500 ms
var.H = false
var.onOff = true
else
var.I = true
wait 500 ms
var.I = false
var.onOff = false
endif
var.wait = false
endif

if var.onOff = false
debug = "Press B to turn your LiightSaber on!"
Wiimote.Leds = 0
Wiimote.Rumble = 0

else
    wait 25 ms
    Wiimote.Leds = 0

 //Determines amount of swing after 100 ms
var.swingTime = var.swingTime / 2
var.xRot = Wiimote.RawForceX + var.xOffset
wait var.swingTime ms
Wiimote.Rumble = 0
wait var.swingTime ms
var.xRot1 = wiimote.RawForceX + var.xOffset - var.xRot

var.yRot = Wiimote.RawForceY + var.yOffset
wait var.swingTime ms
Wiimote.Rumble = 0
wait var.swingTime ms
var.yRot1 = wiimote.RawForceY + var.yOffset - var.yRot

var.zRot = Wiimote.RawForceZ + var.zOffset
wait var.swingTime ms
Wiimote.Rumble = 0
wait var.swingTime ms
var.zRot1 = wiimote.RawForceZ + var.zOffset - var.zRot

debug = ""

//Determines sounds played


if var.xRot1 > var.Swing
   var.A = true
   var.G = false
   Wiimote.Rumble = var.Rumble
   Wiimote.Leds = 15
   debug = "Hit! "
else if var.xRot1 < - var.Swing
   var.B = true
   var.G = false
   Wiimote.Rumble = var.Rumble
   Wiimote.Leds = 15
   debug = "Hit! "
else if var.yRot1 > var.Swing
   var.C = true   
   var.G = false
   Wiimote.Rumble = var.Rumble
   Wiimote.Leds = 15
   debug = "Hit! "
else if var.yRot1 < - var.Swing
   var.D = true 
   var.G = false
   Wiimote.Rumble = var.Rumble
   Wiimote.Leds = 15
   debug = "Hit! "
else if var.zRot1 > var.Swing
   var.E = true   
   var.G = false
   Wiimote.Rumble = var.Rumble
   Wiimote.Leds = 15
   debug = "Hit! "
else if var.zRot1 < - var.Swing
   var.F = true   
   var.G = false
   Wiimote.Rumble = var.Rumble
   Wiimote.Leds = 15
   debug = "Hit! "
else
    var.A = false
    var.B = false
    var.C = false
    var.D = false
    var.E = false
    var.F = false
    var.G = true
endif
endif


Download the PIE file with all of the sounds (borrowed from MacSaber) here:
http://www.geocities.com/freemanspeaketh/wiimote_liightsaber.zip

Features:
-Easy to change settings at the top for swing speed, swing distance, and rumble.
-Swings when you move it a user-defined amount in a user-defined amount of time, and in any direction!
-Default settings for in my opinion the best setup.
-No button presses needed to change sounds!
-6 Different sound effects!
-LED flashes and rumble!
-Turn on and off your LiightSaber!

Try it out!
Back to top
View user's profile Send private message Send e-mail
CarlKenner
Site Admin


Joined: 29 Nov 2006
Posts: 614

Digg It
PostPosted: Thu Dec 14, 2006 5:19 am    Post subject:

By the way, there is a SingleClicked function. So it is better to do this:

if DoubleClicked(Wiimote.home) then

end if
if SingleClicked(Wiimote.home) then

end if

I can't guarantee that doubleclicked will always trigger when the button is down, in older versions I had doubleclicked triggering after they released for the second time. So using DoubleClicked and SingleClicked is prefered. SingleClicked waits after a click until a doubleclick is no longer possible and then returns true.

And false, null, and 0 all evaluate to exactly the same thing. And (var.x = 1 or 2) means (var.x = 1) or (2<>0). Uninitialized variables currently start out as 0 (I think).

The correct way of doing multiple comparisons is like this:

if var.wait = false or = null then

But note that if something evaluates to false it will also evaluate to null and vice-versa, so in this case it is unneccessary.
Back to top
View user's profile Send private message Send e-mail
Or3L



Joined: 03 Dec 2006
Posts: 10

Digg It
PostPosted: Thu Dec 14, 2006 3:34 pm    Post subject:

For Mario Tennis 64 :

Code:
Up = Wiimote.Up
Down = Wiimote.Down
Left = Wiimote.Left
Right = Wiimote.Right
A = Wiimote.A
B = Wiimote.B
One = Wiimote.One
Two = Wiimote.Two
Home = Wiimote.Home
Minus = Wiimote.Minus
Equals = Wiimote.Plus

if Wiimote.A then
Wiimote.Rumble = true
else
Wiimote.Rumble = false
end if

if Wiimote.RawForceY > 50 then
var.RotationY = Wiimote.RawForceY
B = true
Wiimote.Rumble = true
Wiimote.Led1 = true
else
B = false
Wiimote.Led1 = false
Wiimote.Rumble = false
end if
Back to top
View user's profile Send private message
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, 4 ... 51, 52, 53  Next
Page 3 of 53

 
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