Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- |||| O ||||
- |||| / |||| walljumps.lua v1.1.2
- ||||/ ||||
- ||||\ |||| Original Author: PixelPest
- ||||/ |||| Further Work: Antiginger
- ]]--
- local eventu = API.load("eventu");
- local walljumps = {};
- walljumps.slideSpeed = 2; --speed when sliding down walls
- walljumps.jumpIntensityX = 8; --absolute speed of how fast the player travels along the horizontal axis after walljumping
- walljumps.jumpIntensityY = -10.5; --speed of how fast the player travels along the vertical axis after walljumping
- walljumps.delayTime = 0.5; --time (in seconds) that the player has to wait to walljump after making contact with the wall
- walljumps.maxNumFramesStuck = 24;
- local isWallSlidingRight = false;
- local isWallSlidingLeft = false;
- local ReadyToJump = false;
- local timerIsSet = false;
- local StuckToWall = false;
- local FrameCounterStuck = 0;
- function walljumps.onInitAPI()
- registerEvent(walljumps, "onInputUpdate", "onInputUpdate", false);
- end
- local function jump()
- playSFX(2);
- player.speedY = walljumps.jumpIntensityY;
- ReadyToJump = false;
- StuckToWall = false;
- if isWallSlidingRight then
- player.speedX = (-1)*walljumps.jumpIntensityX;
- Animation.spawn(75, player.x + 0.5*(player.width), player.y + player.height - 16);
- elseif isWallSlidingLeft then
- player.speedX = walljumps.jumpIntensityX;
- Animation.spawn(75, player.x - 0.5*(player.width), player.y + player.height - 16);
- end
- end
- local function reset()
- timerIsSet = false;
- canJump = true;
- end
- function walljumps.onInputUpdate()
- if ((isWallSlidingRight) or
- (isWallSlidingLeft)) and
- (player.jumpKeyPressing == true) and
- (ReadyToJump == true) and
- (not player.downKeyPressing) and
- (player:mem(0x34, FIELD_WORD) ~= 2) and
- (player:mem(0x108, FIELD_WORD) == 0) and
- (player.holdingNPC == nil) then
- jump();
- end
- if (player:mem(0x146, FIELD_WORD) == 0) and
- (player:mem(0x14A, FIELD_WORD) == 0) and
- (((player:mem(0x148, FIELD_WORD) == 2) or
- (player:mem(0x14C, FIELD_WORD) == 2)) or
- ((player:mem(0x148, FIELD_WORD) == 2) and
- (player:mem(0x14C, FIELD_WORD) == 2))) and
- (((player.rightKeyPressing) and
- (player:mem(0x14C, FIELD_WORD) == 2)) or
- ((player.leftKeyPressing)) and
- (player:mem(0x148, FIELD_WORD) == 2)) or
- (StuckToWall == true) and
- (not player.downKeyPressing) and
- (player:mem(0x34, FIELD_WORD) ~= 2) and --is not underwater/quicksand
- (player:mem(0x50, FIELD_BOOL) ~= true) then --is not spingjumping
- if (not isWallSlidingLeft) and (not isWallSlidingRight) and (not timerIsSet) then
- eventu.setTimer(walljumps.delayTime, reset, false);
- timerIsSet = true;
- ReadyToJump = false;
- end
- if player:mem(0x148, FIELD_WORD) == 2 then
- isWallSlidingLeft = true;
- isWallSlidingRight = false;
- if player.jumpKeyPressing == false then
- ReadyToJump = true;
- end
- if player.speedY > 0 then
- Animation.spawn(74, player.x - 8, player.y + 0.5*(player.height + 8));
- end
- elseif player:mem(0x14C, FIELD_WORD) == 2 then
- isWallSlidingRight = true;
- isWallSlidingLeft = false;
- if player.jumpKeyPressing == false then
- ReadyToJump = true;
- end
- if player.speedY > 0 then
- Animation.spawn(74, player.x + player.width, player.y + 0.5*(player.height + 8));
- end
- end
- if (player.speedY > 0) and (not player.downKeyPressing) then
- player.speedY = walljumps.slideSpeed;
- if (StuckToWall == false) then
- StuckToWall = true;
- FrameCounterStuck = walljumps.maxNumFramesStuck;
- end
- end
- if (StuckToWall) then
- FrameCounterStuck = FrameCounterStuck - 1;
- if (FrameCounterStuck == 0) then
- StuckToWall = false;
- player.speedY = 0;
- player.speedX = 0;
- end
- if (isWallSlidingRight) then
- player.speedX = 3;
- if player:mem(0x14C, FIELD_WORD) ~= 2 then
- StuckToWall = false;
- player.speedY = 0;
- FrameCounterStuck = 0;
- end
- end
- if (isWallSlidingLeft) then
- player.speedX = -3;
- if player:mem(0x148, FIELD_WORD) ~= 2 then
- StuckToWall = false;
- player.speedY = 0;
- FrameCounterStuck = 0;
- end
- end
- end
- else
- isWallSlidingRight = false;
- isWallSlidingLeft = false;
- ReadyToJump = false;
- end
- if player:mem(0x146, FIELD_WORD) == 2 then
- ReadyToJump = false;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement