inertia.lua - Keep your speed on moving npcs!

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

Master of Disaster
Bit
Bit
Posts: 62
Joined: Sun Nov 28, 2021 9:29 am
Flair: Average Koopa Fan
Pronouns: he/him

inertia.lua - Keep your speed on moving npcs!

Postby Master of Disaster » Sat Mar 09, 2024 9:50 am

You may know the moment when you are trying to platform on a moving platform (looking at you, red YI platform) and it's hard to stay on the platform and feels wrong as well.
The lack of inertia in SMBX bothered me at least, so here's a little library that fixes that!

inertia.lua v1.1

With this library you keep your momentum on moving npcs, making it a lot easier to stay on a moving platform.
Additionally, your jump height is effected by the vertical speed of the platform! You can get quite a lot of distance with that.

v1.1 fixes two issues:
- Fixed an oversight where jumping to the left capped your speed at your runspeed
- NPC's layer movement now also affects you

You can customize how it works with these:

Code: Select all

local inertia = require("inertia") -- loads the library

inertia.keepSpeed = 1 -- how much speed you keep when leaving the platform
inertia.maxJumpSpeed = -16 -- the highest vertical speed you can get when jumping off a moving platform
inertia.minJumpSpeed = -3   -- the lowest vertical speed you get when jumping off a moving platform.
inertia.maxSpeedX = 6          -- highest horizontal speed. If > 6, you can get faster than your normal running speed, it reverts back to normal when landing
here's a little bit of footage:
Spoiler: show
inertia off:
Image

inertia on:
Image

credit if used yadda yadda you know the drill

Here's the download:
https://www.dropbox.com/scl/fo/4in7q8fj ... zn5pp&dl=0
Last edited by Master of Disaster on Wed Mar 19, 2025 7:43 am, edited 1 time in total.

AirShip
Panser
Panser
Posts: 1084
Joined: Wed Jan 01, 2014 1:30 am
Flair: The Flying Ghost
Contact:

Re: inertia.lua - Keep your speed on moving npcs!

Postby AirShip » Sat Mar 09, 2024 12:41 pm

Inertia, my beloved--
Great work, useful as always!

King Mario
Tweeter
Tweeter
Posts: 167
Joined: Sun Nov 19, 2017 2:13 pm
Flair: Jesus Christ is Lord!
Pronouns: he/him
Contact:

Re: inertia.lua - Keep your speed on moving npcs!

Postby King Mario » Sat Mar 09, 2024 8:22 pm

When I try it, an error appears saying that "jumpspeed" does not exist. Know how to fix this?

Master of Disaster
Bit
Bit
Posts: 62
Joined: Sun Nov 28, 2021 9:29 am
Flair: Average Koopa Fan
Pronouns: he/him

Re: inertia.lua - Keep your speed on moving npcs!

Postby Master of Disaster » Mon Mar 11, 2024 8:55 am

King Mario wrote:
Sat Mar 09, 2024 8:22 pm
When I try it, an error appears saying that "jumpspeed" does not exist. Know how to fix this?
jumpspeed doesn't exist? That's an error message you get when using beta 4, since Defines.jumpspeed was recently added in beta 5.
If you are still using beta 4, I'd advice you to update smbx, as there is no reason to not do

King Mario
Tweeter
Tweeter
Posts: 167
Joined: Sun Nov 19, 2017 2:13 pm
Flair: Jesus Christ is Lord!
Pronouns: he/him
Contact:

Re: inertia.lua - Keep your speed on moving npcs!

Postby King Mario » Tue Mar 12, 2024 3:50 pm

I switched to Beta 5 and it works! Thank you for the suggestion.

Blake Izayoi
Volcano Lotus
Volcano Lotus
Posts: 598
Joined: Sun Feb 23, 2014 1:55 pm
Flair: Sakuya's Husband
Pronouns: He / Him
Contact:

Re: inertia.lua - Keep your speed on moving npcs!

Postby Blake Izayoi » Sun Mar 17, 2024 8:49 pm

This will absolutely come in handy in a lot of scenarios. Marvelous work!

cold soup
Bit
Bit
Posts: 72
Joined: Wed May 13, 2020 8:29 pm
Flair: yeah
Pronouns: they/she
Contact:

Re: inertia.lua - Keep your speed on moving npcs!

Postby cold soup » Tue Mar 18, 2025 12:43 am

Spoiler: show
Image
found an oversight when your maximum X-speed is set to a value above your regular max run speed. while jumping to the right makes your momentum carry just fine, jumping to the left still caps your speed

Master of Disaster
Bit
Bit
Posts: 62
Joined: Sun Nov 28, 2021 9:29 am
Flair: Average Koopa Fan
Pronouns: he/him

Re: inertia.lua - Keep your speed on moving npcs!

Postby Master of Disaster » Wed Mar 19, 2025 7:31 am

Oh that's odd, definitely gonna look into the code to see what's the issue

Added in 2 minutes 52 seconds:
Alright, updated the library to fix the speed cap oversight, and additionally properly handle layer movement on npcs.


Return to “LunaLua”

Who is online

Users browsing this forum: Barkrowler [Bot] and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari