GlovePIE:The Legend of Zelda: A Link to the Past (Script)
From WiiLi
acdombasrol This script uses Dead Zone and Pulsing. Last updated 15:27, 1 March 2007 (EST).
[edit] Script
/******************************************************
Zelda: A Link to The Past, Pulse Script 1.3b
GlovePIE Script by almostconnected (almost.technodookie@com)
Suggested Key Mapping
SNES -> PC (Zsnes) -> Wiimote
D-Pad -> Arrow Keys -> Analog Stick
A (interact) -> X -> Z or tap A
B (sword) -> Z -> Swing Wiimote
X (map) -> S -> D-Pad Up
Y (item) -> A -> B
L -> D -> D-Pad Left
R -> C -> D-Pad Right
Select -> Right Shift -> -
Start -> Enter -> +
To perform a spin attack, hold A Button down when
swinging the Wiimote and keep holding it down until you
are ready to attack.
*******************************************************/
// init
if not var.Inited
var.LowBattery = 10 // low battery value
var.RemindWait = 30 seconds // amount of time between low battery reminders
var.SwingThresh = 400.0 // swing threshold (acceleration squared)
var.SwingWait = 125 ms // amount of time to hold the swing button down
var.SwingHold = false // keep holding swing!
var.DeadZone = 0.20 // dead zone for movement
var.LiveZone = 1.0 - var.DeadZone // live zone for movement
var.Inited = true
end
// LEDs (Battery Power)
var.Leds = (Wiimote.Battery + 24) / 48
Wiimote.Led1 = var.Leds >= 1
Wiimote.Led2 = var.Leds >= 2
Wiimote.Led3 = var.Leds >= 3
Wiimote.Led4 = var.Leds >= 4
// check for low battery
if Wiimote.Battery <= var.LowBattery
say "wiimote batteries are low."
wait var.RemindWait
end
// Buttons
Key.A = Wiimote.B
Key.Enter = Wiimote.Plus
Key.RightShift = Wiimote.Minus
Key.X = Wiimote.Nunchuk.ZButton or (Released (Wiimote.A) and not var.SwingHold)
Key.S = Wiimote.Up
Key.D = Wiimote.Left
Key.C = Wiimote.Right
// Swing Detection
var.Swing = Wiimote.RelAccX*Wiimote.RelAccX + Wiimote.RelAccY*Wiimote.RelAccY
if var.SwingHold // getting ready for a spin attack!
var.SwingHold = Wiimote.A
Key.Z = var.SwingHold
else if var.Swing >= var.SwingThresh // swing!
Key.Z = true
var.SwingHold = Wiimote.A
wait var.SwingWait
else // nothing!
Key.Z = false
end
// analog pulse code
var.JoyX = Wiimote.Nunchuk.JoyX
var.JoyY = Wiimote.Nunchuk.JoyY
// apply deadzone to X axis
if var.JoyX < -var.DeadZone
var.JoyX = (var.JoyX + var.DeadZone) / var.LiveZone
else if var.JoyX > var.DeadZone
var.JoyX = (var.JoyX - var.DeadZone) / var.LiveZone
else
var.JoyX = 0
end
// apply deadzone to Y axis
if var.JoyY < -var.DeadZone
var.JoyY = (var.JoyY + var.DeadZone) / var.LiveZone
else if var.JoyY > var.DeadZone
var.JoyY = (var.JoyY - var.DeadZone) / var.LiveZone
else
var.JoyY = 0
end
// only pulse in the non dominant axis
// (scale so that the dominant axis is -1, 1, or 0)
var.Norm = Max( Abs(var.JoyX), Abs(var.JoyY) )
if var.Norm > 0
var.JoyX = var.JoyX / var.Norm
var.JoyY = var.JoyY / var.Norm
end
// pulse X axis
var.PulseX = var.PulseX + Abs(var.JoyX)
if var.PulseX >= 1.0 // pulse!
Key.Left = var.JoyX < 0
Key.Right = var.JoyX > 0
var.PulseX = var.PulseX - 1.0
else
Key.Left = false
Key.Right = false
end
// pulse Y axis
var.PulseY = var.PulseY + Abs(var.JoyY)
if var.PulseY >= 1.0 // pulse!
Key.Up = var.JoyY < 0
Key.Down = var.JoyY > 0
var.PulseY = var.PulseY - 1.0
else
Key.Up = false
Key.Down = false
end
// print battery status
debug = "Battery Power at " + (Wiimote.Battery / 1.92) + "%"

