LBoksha

Shadowrun SNES mouse script

Oct 3rd, 2021 (edited)
1,217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. -- Shadowrun SNES mouse script for BizHawk
  2. -- Inspired by Gamachara's script for snes9x-rr which can be found
  3. --  here: https://github.com/Gamachara/SNES-Shadowrun-Mouse-Script/)
  4. -- Left click attacks, right click interacts, middle click casts spells.
  5. -- Reload the script to toggle mouse control on or off.
  6.  
  7. function shadowrun_mouse()
  8.     mouse = input.getmouse()
  9.     if (mouse.X >= 0 and mouse.X < 256 and mouse.Y >= 0 and mouse.Y < 224) then
  10.         if (memory.readbyte(0x0001F5) == 255) then
  11.             offset = {X=0, Y=0}
  12.             if (memory.readbyte(0x0001F4) == 0xFE) then
  13.                 -- Player has crosshair (attack) cursor selected
  14.                 offset = {X=-7, Y=-6}
  15.             end
  16.  
  17.             x = math.max(3, math.min(mouse.X + offset.X, 239))
  18.             y = math.max(3, math.min(mouse.Y + offset.Y, 206))
  19.             memory.writebyte(0x0001F1, x)
  20.             memory.writebyte(0x0001F3, y)
  21.         end
  22.  
  23.         if (mouse.Left) then
  24.             joypad.set({["P1 A"]=true})  -- Attack
  25.         elseif (mouse.Right) then
  26.             joypad.set({["P1 B"]=true})  -- Interact
  27.         elseif (mouse.Middle) then
  28.             joypad.set({["P1 X"]=true})  -- Cast
  29.         end
  30.      end
  31. end
  32.  
  33. if (not event.unregisterbyname("Shadowrun mouse handler")) then
  34.     event.onframestart(shadowrun_mouse, "Shadowrun mouse handler")
  35.     console.log("* Mouse control on")
  36. else
  37.     console.log("* Mouse control off")
  38. end
Add Comment
Please, Sign In to add comment