Twirl.lua Rewritten 2.3 (NSMB Midair Spin)

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

Moderator: Userbase Moderators

MegoZ_
Spiny
Spiny
Posts: 25
Joined: Mon Jun 04, 2018 10:25 am
Pronouns: he/him
Contact:

Twirl.lua Rewritten 2.3 (NSMB Midair Spin)

Postby MegoZ_ » Mon Jun 04, 2018 11:22 am

This script allows the player to twirl like in New Super Mario Bros. Wii/U.
Works for 2 players
v2.2: Now compatible with "dive.lua!"
v2.3: Changed audio file to .ogg and tweaked default settings.
* Press the Alt-Jump/Spin key in mid-air
* Only Mario, Luigi and Toad can do this

The twirl gives you a bit of momentum in mid-air. So it's useful for jumps that aren't high enough to reach certain places in a level, and it can save you from some otherwise hopeless situations.

How to install:
Spoiler: show
1. Extract both "twirl.lua" and the "twirl.flac" together into your episode/level folder.
2. Paste the following line into your level/episode's luna.lua file.

Code: Select all

twirl = require("twirl")

Gif Comparation:
Spoiler: show
The SMB1 coin makes Mario jump, as SMB2 coin triggers the spin key, both Marios are synchronized: Image
Video Preview:
Spoiler: show
Old Version:


Old Version (1.5.0):
Variables:
Spoiler: show
twirl.descent = Int | Sets this to the Y speed WHEN DESCENDING in order to achieve a slower fall.
twirl.impulsePercent = Int | Multiplies this with Y speed WHEN ASCENDING in order to reach a higher jump.
twirl.extraImpulse = Int | Substracts this to Y speed WHEN ASCENDING in order to reach an even higher jump.
twirl.cooldown = Int | Amount of ticks between twirls.

Animation Related:
twirl.frames = Table | Player's sprite sequence
twirl.animSpeed = Int | Animation Speed


Default Values:
Copy and paste these to your luna.lua file if you want to edit them:
twirl.descent = 1.5
twirl.impulsePercent = 1.5
twirl.extraImpulse = 1.3
twirl.cooldown = 10

twirl.frames = {15, -2,-2, 13, 2,2}
twirl.animSpeed = 2
[/code]

Writing this was a good way to spend my time. It has been interesting seeing myself grow up and learn lua every day since I was 16. Each time I went back to this I saw ways to shrink the code and improve my bad habits and It's been 4 years. It's always such a good feeling when something works!

This community has inspired me in a way you can't imagine. And although I barely like to socialize, I really wanted to thank you all so much for inspiring me! :D

Download (Zip file, v2.3):
MEGA: https://mega.nz/file/I9N3ACbR#ZMZASyljR ... wOAknk_aU4
MEDIAFIRE: https://www.mediafire.com/file/58gg94bg ... o.zip/file
Quick Pastebin (Only for Updates): https://pastebin.com/QJ5bFaL6

Last edited by MegoZ_ on Sun Aug 07, 2022 6:48 am, edited 30 times in total.

Taycamgame
Gold Yoshi Egg
Gold Yoshi Egg
Posts: 1483
Joined: Mon Jun 19, 2017 11:35 am
Flair: Stargard
Contact:

Re: Twirl.lua (NSMB Midair Spin)

Postby Taycamgame » Mon Jun 04, 2018 11:38 am

This looks useful, does it give the player an extra bit of momentum like it did in the NSMB games to allow the player to go a little bit further, or is it just an effect?

MegoZ_
Spiny
Spiny
Posts: 25
Joined: Mon Jun 04, 2018 10:25 am
Pronouns: he/him
Contact:

Re: Twirl.lua (NSMB Midair Spin)

Postby MegoZ_ » Mon Jun 04, 2018 12:12 pm

Taycamgame wrote:
Mon Jun 04, 2018 11:38 am
This looks useful, does it give the player an extra bit of momentum like it did in the NSMB games to allow the player to go a little bit further, or is it just an effect?
Oh yeah. I did it intentionally so that when the player press to twirl, give him a bit of momentum.

Edit: I think i haven't said it clearly. Sorry, don't speak english frequently :oops: There's two types of momentum. Before he gets to the top of the jump and when he starts to fall.

When he's about to get to the maximum height after jumping and he presses to twirl in the middle of the action, it cancells the jump in midair and gives him a lower push upward.
When he falls, it restores the Y speed into 1 and removes the speed he gained through the fall.

(Also when i putted 0 instead he could spinjump in air which is a fun fact)

The0x539
Eerie
Eerie
Posts: 751
Joined: Fri Jan 22, 2016 8:02 pm

Re: Twirl.lua (NSMB Midair Spin)

Postby The0x539 » Mon Jun 04, 2018 3:30 pm

Why does your "mem recognition function" use global variables? With the unusual but not-completely-insane structure of your code, it'd work to declare them as local to the whole file.

Conditions don't need to be a comparison.

Code: Select all

if foo == true then
is redundant in the same way that

Code: Select all

if (foo == true) == true then
is. If your value is just a boolean, you can just use `foo` and `not foo`.

MegoZ_
Spiny
Spiny
Posts: 25
Joined: Mon Jun 04, 2018 10:25 am
Pronouns: he/him
Contact:

Re: Twirl.lua (NSMB Midair Spin)

Postby MegoZ_ » Wed Jun 06, 2018 1:55 pm

The0x539 wrote:
Mon Jun 04, 2018 3:30 pm
Why does your "mem recognition function" use global variables? With the unusual but not-completely-insane structure of your code, it'd work to declare them as local to the whole file.

Conditions don't need to be a comparison.

Code: Select all

if foo == true then
is redundant in the same way that

Code: Select all

if (foo == true) == true then
is. If your value is just a boolean, you can just use `foo` and `not foo`.
So... You're telling me to use "local function" instead of just a regular one for most of them, and...

Code: Select all

that "if var == false" is the same thing as "if not var"

Code: Select all

and "if var == true" is the same thing as "if var"
If so, i see your point. And it doesn't make much sense that i haven't did it before because i knew it. However, i was scared to make a dumb mistake somewhere, lost the mistake (That doesn't necessarily needs to be a crash), and rewrite for the 4th time.

aero
Palom
Palom
Posts: 4787
Joined: Fri Mar 28, 2014 2:51 pm

Re: [1.1] twirl.lua (NSMB Midair Spin)

Postby aero » Thu Jul 19, 2018 12:50 am

I noticed you did this with your If statements:

If var == true then
var2 == true
else
var2 == false
end

This can be done on one line like this:
var2 = var

It's a lot easier to keep track of what your code is doing with the second way, and it's generally good practice to do that if your only going to be changing a boolean type within a conditional. For the parts of your code that did this, I rewrote what it would look like with the second format and it should produce the same results as your code but done more concisely.

https://pastebin.com/jyUcPGGN

MegoZ_
Spiny
Spiny
Posts: 25
Joined: Mon Jun 04, 2018 10:25 am
Pronouns: he/him
Contact:

Re: [1.1] twirl.lua (NSMB Midair Spin)

Postby MegoZ_ » Sat Jul 28, 2018 11:48 am

GhostHawk wrote:
Thu Jul 19, 2018 12:50 am
I noticed you did this with your If statements:

If var == true then
var2 == true
else
var2 == false
end

This can be done on one line like this:
var2 = var

It's a lot easier to keep track of what your code is doing with the second way, and it's generally good practice to do that if your only going to be changing a boolean type within a conditional. For the parts of your code that did this, I rewrote what it would look like with the second format and it should produce the same results as your code but done more concisely.

https://pastebin.com/jyUcPGGN
I'll use this info on my future projects. This is very useful and can shorten my code. Thanks a lot!

MegaDood
Charged Spiny
Charged Spiny
Posts: 1825
Joined: Wed Nov 01, 2017 2:43 am

Re: [1.2] twirl.lua (NSMB Midair Spin)

Postby MegaDood » Sat Apr 13, 2019 1:48 am

This is so cool. Subtle differences like this might change up the game a bit more.

Eri7
Banned
Posts: 1770
Joined: Sat Jan 28, 2017 4:48 pm
Flair: Good Foundation allows for strong Execution
Contact:

Re: [1.2] twirl.lua (NSMB Midair Spin)

Postby Eri7 » Sat Apr 13, 2019 7:09 am

MegaDood wrote:
Sat Apr 13, 2019 1:48 am
This is so cool. Subtle differences like this might change up the game a bit more.
Well i used this script for my cancelled 2.0 project but the people who played it never used the twirl for some weird reason so idk if it will change anything that much.

MegaDood
Charged Spiny
Charged Spiny
Posts: 1825
Joined: Wed Nov 01, 2017 2:43 am

Re: [1.2] twirl.lua (NSMB Midair Spin)

Postby MegaDood » Sun Apr 14, 2019 12:06 am

Eri7 wrote:
Sat Apr 13, 2019 7:09 am
MegaDood wrote:
Sat Apr 13, 2019 1:48 am
This is so cool. Subtle differences like this might change up the game a bit more.
Well i used this script for my cancelled 2.0 project but the people who played it never used the twirl for some weird reason so idk if it will change anything that much.
Huh, that's interesting. I would have thought people would make the most use out of a feature.

MegoZ_
Spiny
Spiny
Posts: 25
Joined: Mon Jun 04, 2018 10:25 am
Pronouns: he/him
Contact:

midAirTwirl.lua 1.3.1 update!

Postby MegoZ_ » Wed Feb 19, 2020 12:25 pm

Hey! I just updated this script to be compatible with peach and other characters. Other cool stuff on the changelog which is in the .lua file itself! Just redownload it from the same links provided in the post above!

DrLugawi
Shy Guy
Shy Guy
Posts: 5
Joined: Tue Aug 13, 2019 11:27 am

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby DrLugawi » Sun Feb 23, 2020 10:27 pm

Hi, I see you're making an experimental ground pound API, if you want, can you post some progress images, or like logs?

MegoZ_
Spiny
Spiny
Posts: 25
Joined: Mon Jun 04, 2018 10:25 am
Pronouns: he/him
Contact:

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby MegoZ_ » Mon Feb 24, 2020 5:27 am

DrLugawi wrote:
Sun Feb 23, 2020 10:27 pm
Hi, I see you're making an experimental ground pound API, if you want, can you post some progress images, or like logs?
Sadly that groundpound API got lost... I will search for it and if I find it, i will rewrite it since it has a lot of problems

DrLugawi
Shy Guy
Shy Guy
Posts: 5
Joined: Tue Aug 13, 2019 11:27 am

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby DrLugawi » Mon Feb 24, 2020 7:07 am

MegoZ_ wrote:
Mon Feb 24, 2020 5:27 am
DrLugawi wrote:
Sun Feb 23, 2020 10:27 pm
Hi, I see you're making an experimental ground pound API, if you want, can you post some progress images, or like logs?
Sadly that groundpound API got lost... I will search for it and if I find it, i will rewrite it since it has a lot of problems
That's unfortunate, but if you ever find it'll be awsome to use

Neon358
Fighter Fly
Fighter Fly
Posts: 35
Joined: Tue Apr 07, 2020 5:24 pm

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby Neon358 » Thu May 21, 2020 1:55 pm

Is there a version for SMBX 38A 1.4.5? Just curious.

Bomb Kicker DX
Fighter Fly
Fighter Fly
Posts: 30
Joined: Sat Mar 30, 2019 11:46 am
Contact:

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby Bomb Kicker DX » Thu May 21, 2020 9:08 pm

As far as i know no

Cedur
Link
Link
Posts: 7073
Joined: Tue Jun 28, 2016 10:14 am
Flair: I'm gone, for chess and minesweeper
Pronouns: he/him

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby Cedur » Fri May 22, 2020 9:57 am

Will it be also possible to change constantly between normal jump and spinjump, as in the SMW hack Invictus?

MrCool422
Fighter Fly
Fighter Fly
Posts: 35
Joined: Sun Jan 24, 2021 12:26 am
Flair: Autistic
Pronouns: He/Him
Contact:

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby MrCool422 » Fri May 07, 2021 7:46 pm

MegoZ_... I been using the midAirTwirl.lua And pressing the alt jump button 500 times and still no mid air twirl!

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 543
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby Marioman2007 » Sat May 08, 2021 2:30 am

MrCool422 wrote:
Fri May 07, 2021 7:46 pm
MegoZ_... I been using the midAirTwirl.lua And pressing the alt jump button 500 times and still no mid air twirl!
Are you even loading the library.

MrCool422
Fighter Fly
Fighter Fly
Posts: 35
Joined: Sun Jan 24, 2021 12:26 am
Flair: Autistic
Pronouns: He/Him
Contact:

Re: midAirTwirl.lua (NSMB Midair Spin) 2 PLAYER SUPPORT

Postby MrCool422 » Sun Jun 13, 2021 12:50 am

Image
Ok so i've reloaded the libary after this happended!


Return to “LunaLua”

Who is online

Users browsing this forum: RadMetalMarioSMIX and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari