Advertisement
Enjl

coyotetime

May 24th, 2020 (edited)
953
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. -- Enjl wrote about coyote time one fine sunday morning
  2. local ct = {}
  3.  
  4. -- Customization Options:
  5. ct.frames = 5
  6. ct.onJump = function(p, isSpinJumping) end -- Override this in your own code if you have any special jump handling. Passes player and boolean.
  7.  
  8. -- Functionality
  9.  
  10. local timeSinceWasGrounded = {}
  11.  
  12. function ct.onInitAPI()
  13.     registerEvent(ct, "onTick")
  14. end
  15.  
  16. function ct.onTick()
  17.     for k,p in ipairs(Player.get()) do
  18.         if timeSinceWasGrounded[k] == nil then
  19.             timeSinceWasGrounded[k] = 0
  20.         end
  21.         if not p:isGroundTouching() then
  22.             if p.speedY > 0 then
  23.                 if timeSinceWasGrounded[k] < ct.frames then
  24.                     if p.keys.jump == KEYS_PRESSED then
  25.                         p.speedY = 0
  26.                         p:mem(0x11E, FIELD_BOOL, true)
  27.                         ct.onJump(p, false)
  28.                     elseif p.keys.altJump == KEYS_PRESSED then
  29.                         p.speedY = 0
  30.                         p:mem(0x120, FIELD_BOOL, true)
  31.                         ct.onJump(p, true)
  32.                     end
  33.                 end
  34.             end
  35.             timeSinceWasGrounded[k] = timeSinceWasGrounded[k] + 1
  36.         else
  37.             timeSinceWasGrounded[k] = 0
  38.         end
  39.     end
  40. end
  41.  
  42. return ct
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement