Advertisement
N3rdsWithGame

sidehop.lua

May 3rd, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. local linSpeedAddr = 0x1DB258
  2.  
  3. local noButtonPressed = {}
  4. noButtonPressed['A']=false
  5. noButtonPressed['Z']=false
  6. noButtonPressed['X Axis'] = 0
  7. noButtonPressed['Y Axis'] = 0
  8.  
  9.  
  10. local ztarget = {}
  11. ztarget['Z']=true
  12.  
  13. local sidehop = {}
  14. sidehop['A']=true
  15. sidehop['Z']=true
  16. sidehop["X Axis"] = 127
  17. sidehop["Y Axis"] = 0
  18.  
  19. local test = {}
  20. test['X Axis'] = 0
  21. test['Y Axis'] = 127
  22.  
  23. local sidehopping = false
  24. local changeDirectionsOnNextHop = false
  25. local keys = input.get()
  26.  
  27. function readyForNextAction()
  28.   return  mainmemory.readfloat(linSpeedAddr,true)==7.5
  29. end
  30.  
  31. function nextAction()
  32.   if changeDirectionsOnNextHop then
  33.     local isPaused = client.ispaused()
  34.  
  35.  
  36.  
  37.     print("starting")
  38.     changeDirectionsOnNextHop = false
  39.     client.unpause()
  40.     joypad.set(noButtonPressed,1)
  41.     joypad.setanalog(noButtonPressed,1)
  42.     client.pause()
  43.     emu.frameadvance()
  44.     local controller = joypad.get()
  45.     local controlX = controller['X Axis']
  46.     emu.frameadvance()
  47.     joypad.set(sidehop,1)
  48.  
  49.  
  50.  
  51.     if ispuased then
  52.       client.pause()
  53.     else
  54.       client.unpause()
  55.     end
  56.   end
  57.   joypad.set(sidehop,1)
  58.   joypad.setanalog(sidehop,1)
  59. end
  60.  
  61. while true do
  62.   keys = input.get()
  63.   if sidehopping then
  64.       if readyForNextAction() then-- time to do next action
  65.         nextAction()
  66.       else
  67.         joypad.set(ztarget,1)
  68.       end
  69.   end
  70.  
  71.   if keys['V'] then-- change sidehop angles
  72.     changeDirectionsOnNextHop = true
  73.     print("changing direction next hop")
  74.   end
  75.   if keys['B'] then-- sidehop left
  76.     sidehopping=true
  77.     sidehop["X Axis"] = -127
  78.     sidehop["Y Axis"] = 127
  79.     print("sidehop  left")
  80.   end
  81.   if keys['N'] then --stop sidehop
  82.     sidehopping=false
  83.     print("no sidehop for you")
  84.   end
  85.   if keys['M'] then --sidehop right
  86.     sidehopping=true
  87.     sidehop["X Axis"] = 127
  88.     print("sidehop  right")
  89.   end
  90.  
  91.   emu.yield()
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement