customPowerups.lua - One more powerup framework! [v1.2]

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

Moderator: Userbase Moderators

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 650
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby mariobrigade2018 » Tue May 07, 2024 11:56 am

KJPopcorn wrote:
Tue May 07, 2024 10:23 am
I mean, yeah, but you’ll have to code it yourself.
How?
The download have 2 examples of how to make them, and any Powerup that uses anotherpowerup (aside from Captain Monochrome’s acorn and penguin suit) can work with this as well.

KJPopcorn
Swooper
Swooper
Posts: 70
Joined: Wed Mar 20, 2024 8:14 pm
Pronouns: He/Him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby KJPopcorn » Tue May 07, 2024 3:55 pm

mariobrigade2018 wrote:
Tue May 07, 2024 11:56 am
KJPopcorn wrote:
Tue May 07, 2024 10:23 am
I mean, yeah, but you’ll have to code it yourself.
How?
The download have 2 examples of how to make them, and any Powerup that uses anotherpowerup (aside from Captain Monochrome’s acorn and penguin suit) can work with this as well.
Ok

Shodax
Bot
Bot
Posts: 53
Joined: Sat Feb 05, 2022 2:24 pm
Pronouns: he

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Shodax » Thu May 30, 2024 6:02 pm

Hello.
First of all, great job your library works excellent, I can add all the powerups I want, but I have a question.
I don't know if I did anything wrong but apparently with the script of "Cape Feather"(ap_cape.lua) the powerup of "Drill" behaves like the "Drill" because when trying to do the "GroundPound" the character of Mario does not execute the action, as it is automatically canceled looks:
Image

Strangely with Luigi if the action and animation are executed

Image

I say it's the "Cape Feather" because when I remove that script it doesn't give that problem anymore.
This is my setup, I probably didn't get something right

Code: Select all

	
local cp = require("customPowerups")
local drill = cp.addPowerup("Drill", "powerups/drill", 753)
drill.applyDefaultSettings()
cp.addPowerup("Superball", "powerups/ap_superball", 957, true)
cp.addPowerup("Carrot", "powerups/ap_carrot", 848, true)
local bubbleFlower = cp.addPowerup("Bubble Flower", "powerups/bubbleFlower", 751)
cp.registerItemTier(968, true)
cp.registerItemTier(969, true)
cp.registerPowerup("ap_thunderflower")

twirl = require("Twirl")

local aw = require("anotherwalljump")
aw.registerAllPlayersDefault()

local GP = require("GroundPound")
GP.applyDefaultSettings()
GP.inputStyle = GP.INPUT_DOUBLE_DOWN


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

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Marioman2007 » Thu May 30, 2024 11:42 pm

How are you registering the cape feather?

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 650
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby mariobrigade2018 » Fri May 31, 2024 2:31 am

Marioman2007 wrote:
Thu May 30, 2024 11:42 pm
Ping
Oh yeah I remember, how’s progress on fixing the costume bug?

Shodax
Bot
Bot
Posts: 53
Joined: Sat Feb 05, 2022 2:24 pm
Pronouns: he

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Shodax » Fri May 31, 2024 10:05 pm

Marioman2007 wrote:
Thu May 30, 2024 11:42 pm
How are you registering the cape feather?
I don't add it, I just copy the files and modify the npc-851.lua by changing the code

Code: Select all

local ap = require("anotherpowerup")
by

Code: Select all

local ap = require("customPowerups")
And it works.

However, I have tried to register it this way

Code: Select all

cp.addPowerup("Cape Feather", "ap_cape", 851)
I've also added the "true"

Code: Select all

cp.addPowerup("Cape Feather", "ap_cape", 851, true)

And it's still the same, what do you recommend?

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

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Marioman2007 » Sat Jun 01, 2024 7:48 am

Shodax wrote:
Fri May 31, 2024 10:05 pm

Code: Select all

local ap = require("customPowerups")

Doing this works fine for me.
Can you share your test level so that I can check?

Shodax
Bot
Bot
Posts: 53
Joined: Sat Feb 05, 2022 2:24 pm
Pronouns: he

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Shodax » Sat Jun 01, 2024 7:08 pm

Marioman2007 wrote:
Sat Jun 01, 2024 7:48 am
Shodax wrote:
Fri May 31, 2024 10:05 pm

Code: Select all

local ap = require("customPowerups")

Doing this works fine for me.
Can you share your test level so that I can check?
I'll leave it here. The level file is called "pruebas"
Thank you

https://www.mediafire.com/file/hd6rqkec ... t.zip/file

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 650
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby mariobrigade2018 » Sat Jun 01, 2024 7:16 pm

If I remember correctly, you don’t need to register the cape feather in the luna.lua file, because the lua file for the Cape already does this.

Also this.
mariobrigade2018 wrote:
Fri May 31, 2024 2:31 am
Marioman2007 wrote:
Thu May 30, 2024 11:42 pm
Ping
Oh yeah I remember, how’s progress on fixing the costume bug?

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

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Marioman2007 » Sun Jun 02, 2024 2:53 am

Shodax wrote:
Sat Jun 01, 2024 7:08 pm
I'll leave it here. The level file is called "pruebas"
Thank you

https://www.mediafire.com/file/hd6rqkec ... t.zip/file

Oh, it's due to drill.lua.
Find this code

Code: Select all

local function isOnGround(p)
	return (
		p.speedY == 0 -- "on a block"
		or p:mem(0x176,FIELD_WORD) ~= 0 -- on an NPC
		or p:mem(0x48,FIELD_WORD) ~= 0 -- on a slope
	)
end
And replace that with this.

Code: Select all

local function isOnGround(p)
    return p:isOnGround()
end



mariobrigade2018 wrote:
Fri May 31, 2024 2:31 am
Oh yeah I remember, how’s progress on fixing the costume bug?
I think it's done, but I have not tested it properly.

Shodax
Bot
Bot
Posts: 53
Joined: Sat Feb 05, 2022 2:24 pm
Pronouns: he

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Shodax » Sun Jun 02, 2024 1:49 pm

Marioman2007 wrote:
Sun Jun 02, 2024 2:53 am
Shodax wrote:
Sat Jun 01, 2024 7:08 pm
I'll leave it here. The level file is called "pruebas"
Thank you

https://www.mediafire.com/file/hd6rqkec ... t.zip/file

Oh, it's due to drill.lua.
Find this code

Code: Select all

local function isOnGround(p)
	return (
		p.speedY == 0 -- "on a block"
		or p:mem(0x176,FIELD_WORD) ~= 0 -- on an NPC
		or p:mem(0x48,FIELD_WORD) ~= 0 -- on a slope
	)
end
And replace that with this.

Code: Select all

local function isOnGround(p)
    return p:isOnGround()
end



mariobrigade2018 wrote:
Fri May 31, 2024 2:31 am
Oh yeah I remember, how’s progress on fixing the costume bug?
I think it's done, but I have not tested it properly.
It works perfectly!

Thank you

ducksarecool2001
Shy Guy
Shy Guy
Posts: 6
Joined: Sat Nov 11, 2023 5:35 pm
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby ducksarecool2001 » Thu Jun 06, 2024 8:24 pm

What is anotherpowerup.lua and customPowerups.lua? How do you use them?

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 650
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby mariobrigade2018 » Thu Jun 13, 2024 11:41 am

ducksarecool2001 wrote:
Thu Jun 06, 2024 8:24 pm
What is anotherpowerup.lua and customPowerups.lua? How do you use them?
Those two are frameworks that add more powerups, with ap being buggier than cp. Normally, for any library, you would use this code:

Code: Select all

require(“name of library”)
...to load it in, but some of them may have settings that you might want to change. In that case, this code is required to change them:

Code: Select all

local anyvariablename = require(“name of library”)
anyvariablename.settingname = changedvalue
... which is what you need to do in order to register powerups.

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

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby King Mario » Mon Jun 24, 2024 6:18 am

KJPopcorn wrote:
Mon May 06, 2024 5:52 pm
I meant: can you make these with this?
Spoiler: show
Image
Image
Image
Image
Image

As well as Luigi's, Toad's, Link's and Peach's sprites
I think you have amazing ideas! It would be quite cool to see the Frog Suit, Shell Suit, Propeller Suit, and Mini Mario in SMBX2! Looking forward to seeing them once they're finished.

Cat king
Buster Beetle
Buster Beetle
Posts: 86
Joined: Thu Feb 29, 2024 1:04 pm
Flair: Mario kart wii is #1
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Cat king » Mon Jun 24, 2024 1:07 pm

According to the original post, any custom powerups replace existing ones. But in this post, I can see there are more powerups than the normal amount (Which I believe is 5). So I'm not entirely certain about the limits of the powerups for this library. How many can I have, more than the initial 5 or is it still limited by that? Also would the code work for episodes (e.x. penguin suit all throughout the episode).
Spoiler: show
Shodax wrote:
Thu May 30, 2024 6:02 pm
Hello.
First of all, great job your library works excellent, I can add all the powerups I want, but I have a question.
I don't know if I did anything wrong but apparently with the script of "Cape Feather"(ap_cape.lua) the powerup of "Drill" behaves like the "Drill" because when trying to do the "GroundPound" the character of Mario does not execute the action, as it is automatically canceled looks:
Image

Strangely with Luigi if the action and animation are executed

Image

I say it's the "Cape Feather" because when I remove that script it doesn't give that problem anymore.
This is my setup, I probably didn't get something right

Code: Select all

	
local cp = require("customPowerups")
local drill = cp.addPowerup("Drill", "powerups/drill", 753)
drill.applyDefaultSettings()
cp.addPowerup("Superball", "powerups/ap_superball", 957, true)
cp.addPowerup("Carrot", "powerups/ap_carrot", 848, true)
local bubbleFlower = cp.addPowerup("Bubble Flower", "powerups/bubbleFlower", 751)
cp.registerItemTier(968, true)
cp.registerItemTier(969, true)
cp.registerPowerup("ap_thunderflower")

twirl = require("Twirl")

local aw = require("anotherwalljump")
aw.registerAllPlayersDefault()

local GP = require("GroundPound")
GP.applyDefaultSettings()
GP.inputStyle = GP.INPUT_DOUBLE_DOWN


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

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby King Mario » Mon Jun 24, 2024 3:24 pm

Oh that's right! You reminded me of something. I got 6 existing custom powerups to work in SMBX2 B5, at the same time! Yeah, it was a little hard to get it done, but I tampered around with the .lua and .ini files, and learned some valuable things. I don't claim to be a professional at LunaLua by any standards, but eventually, I was able to figure out what it was I was missing, and once I did, all 6 powerups started working perfectly! (With Mario and Luigi anyway.) I also personally made my own file called Custom Powerups.tileset.ini, the point of which would be to record and call every instance of custom powerups that I wanted to use. And for an added bonus, I've also added Tempest's Boomerang Flower, which replaces Mario's Hammer Suit and also works perfectly! Credit goes to Tempest for the original powerup.

Here's a video to prove that all 6 powerups work:


And here's the file if you want to use it (including the test level): https://www.dropbox.com/scl/fo/6dywftpc ... o3opq&dl=0

DISCLAIMER: I do NOT own or claim for myself any of the scripts, powerups, or files made by other people. The credit for all those belong to the original owners of said content, wherever credit is due. The only things I made are the tileset.ini file and my personal modifications to the .lua and .ini files.

Added in 25 minutes 30 seconds:
Some things I should make clear:
1. Tempest's Boomerang Flower is the only powerup that replaces an existing powerup. Every other custom powerup is its own independent thing and works just fine, without replacing anything!
2. Only Mario and Toad can throw boomerangs. Upon any other character interacting with the Boomerang Flower, it will function just like an ordinary Hammer Suit, granting the other 3 main characters their traditional abilities (Hammer Suit for Luigi, Bomb Suit for Peach, and Master Sword for Link).
3. Only Mario and Luigi can use the Drill Mushroom. Doing otherwise can cause weird bugs, glitches, or even a crash.
4. The only custom abilities Link can properly use are Cape Feather and Gold Flower. Using any of the other 4 custom powerups with Link will definitely cause a crash.

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 650
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby mariobrigade2018 » Tue Jun 25, 2024 1:48 pm

King Mario wrote:
Mon Jun 24, 2024 3:49 pm
All workable AP powerups as CP ones

Added in 25 minutes 30 seconds:
Some things I should make clear:
1. Tempest's Boomerang Flower is the only powerup that replaces an existing powerup. Every other custom powerup is its own independent thing and works just fine, without replacing anything!
2. Only Mario and Toad can throw boomerangs. Upon any other character interacting with the Boomerang Flower, it will function just like an ordinary Hammer Suit, granting the other 3 main characters their traditional abilities (Hammer Suit for Luigi, Bomb Suit for Peach, and Master Sword for Link).
3. Only Mario and Luigi can use the Drill Mushroom. Doing otherwise can cause weird bugs, glitches, or even a crash.
4. The only custom abilities Link can properly use are Cape Feather and Gold Flower. Using any of the other 4 custom powerups with Link will definitely cause a crash.
I actually made the Boomerang Flower work on other characters. I can send it in if you want.

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

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby King Mario » Tue Jun 25, 2024 5:21 pm

mariobrigade2018 wrote:
Tue Jun 25, 2024 1:48 pm
King Mario wrote:
Mon Jun 24, 2024 3:49 pm
All workable AP powerups as CP ones

Added in 25 minutes 30 seconds:
Some things I should make clear:
1. Tempest's Boomerang Flower is the only powerup that replaces an existing powerup. Every other custom powerup is its own independent thing and works just fine, without replacing anything!
2. Only Mario and Toad can throw boomerangs. Upon any other character interacting with the Boomerang Flower, it will function just like an ordinary Hammer Suit, granting the other 3 main characters their traditional abilities (Hammer Suit for Luigi, Bomb Suit for Peach, and Master Sword for Link).
3. Only Mario and Luigi can use the Drill Mushroom. Doing otherwise can cause weird bugs, glitches, or even a crash.
4. The only custom abilities Link can properly use are Cape Feather and Gold Flower. Using any of the other 4 custom powerups with Link will definitely cause a crash.
I actually made the Boomerang Flower work on other characters. I can send it in if you want.
Oh you did? That's pretty cool! Sure, you may send it in.

Cat king
Buster Beetle
Buster Beetle
Posts: 86
Joined: Thu Feb 29, 2024 1:04 pm
Flair: Mario kart wii is #1
Pronouns: he/him

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby Cat king » Wed Jun 26, 2024 11:06 am

King Mario wrote:
Mon Jun 24, 2024 3:49 pm
Oh that's right! You reminded me of something. I got 6 existing custom powerups to work in SMBX2 B5, at the same time! Yeah, it was a little hard to get it done, but I tampered around with the .lua and .ini files, and learned some valuable things. I don't claim to be a professional at LunaLua by any standards, but eventually, I was able to figure out what it was I was missing, and once I did, all 6 powerups started working perfectly! (With Mario and Luigi anyway.) I also personally made my own file called Custom Powerups.tileset.ini, the point of which would be to record and call every instance of custom powerups that I wanted to use. And for an added bonus, I've also added Tempest's Boomerang Flower, which replaces Mario's Hammer Suit and also works perfectly! Credit goes to Tempest for the original powerup.

Here's a video to prove that all 6 powerups work:


And here's the file if you want to use it (including the test level): https://www.dropbox.com/scl/fo/6dywftpc ... o3opq&dl=0

DISCLAIMER: I do NOT own or claim for myself any of the scripts, powerups, or files made by other people. The credit for all those belong to the original owners of said content, wherever credit is due. The only things I made are the tileset.ini file and my personal modifications to the .lua and .ini files.

Added in 25 minutes 30 seconds:
Some things I should make clear:
1. Tempest's Boomerang Flower is the only powerup that replaces an existing powerup. Every other custom powerup is its own independent thing and works just fine, without replacing anything!
2. Only Mario and Toad can throw boomerangs. Upon any other character interacting with the Boomerang Flower, it will function just like an ordinary Hammer Suit, granting the other 3 main characters their traditional abilities (Hammer Suit for Luigi, Bomb Suit for Peach, and Master Sword for Link).
3. Only Mario and Luigi can use the Drill Mushroom. Doing otherwise can cause weird bugs, glitches, or even a crash.
4. The only custom abilities Link can properly use are Cape Feather and Gold Flower. Using any of the other 4 custom powerups with Link will definitely cause a crash.
Interesting. I wasn't aware that one could have independent power ups due to some limitation in the code of the original SMBX.

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

Re: customPowerups.lua - One more powerup framework! [v1.1]

Postby King Mario » Mon Jul 08, 2024 11:27 am

I was testing some more and I realized two things:

1. Bubble Flower cannot be used while invincible with Starman. This is a really minor issue though, maybe it's meant to be that way.

2. The More Important Thing: Whenever Bosses (the default ones) get captured by bubbles, they get killed instantly. I was thinking that maybe I could take all of the current Boss NPCs and put them in a blacklist so that the Bubble doesn't instantly kill bosses in one hit. How would I blacklist a set of NPCs though? A little help would be nice.


Return to “LunaLua”

Who is online

Users browsing this forum: Paka_Mzuri and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari