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

Share and discuss custom LunaLua code and content packs for SMBX2.
Marioman2007
Lakitu
Lakitu
Posts: 466
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

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

Postby Marioman2007 » Mon Feb 05, 2024 11:44 am

Wanted to create SMBW powerups but anotherpowerup had some issues with reserveBox which I was unable to fix, so I ended up doing my own powerup system with a bit of code from anotherPowerup.lua.

GIFs:
Spoiler: show
Image
Image
Image
Cape feather by MDA: viewtopic.php?t=26620
Super ball flower by lucstar and MegaDood: viewtopic.php?t=28422

How is it any different from anotherpowerup?
- Multiplayer compatible
- Replaces a single powerup
- Replaced powerup doesn't need to be recreated
- Uses custom forced state IDs
- No custom powerup tiers

Can anotherPowerup powerups still be used?
- Yes, this library has compatibility functions. The only things that won't work are custom powerup tiers.
- You can find "local ap = require("anotherPowerup")" and change it to "local ap = require("customPowerups")" and things should work by default.
- Unfortunately, Captain Monochrome's powerups use a modified version of ap so they can't be properly used with this.

Credits:
Marioman2007 - customPowerups.lua and both the powerups, drill player sprites

Give credits if used, enjoy!
Emral - code from anotherpowerup.lua

- Credits for GFX
Shikaternia - Bubble and its pop effect sprites
RedBallBomb - Bubble flower sprite
Deltomx3 - Base sprites for the drill powerup, Jewel block sprites
Bubble Flower's palettes were taken from the frightlight npc

Included Powerups:
- Drill Mushroom
- Bubble Flower

Changelog:
v1.0 - First release
v1.1 - Some bugfixes, now works on the map.

Note:
If you use "player.character = #" instead of "player:transform(#)", the script will malfunction. Always use the transform function to transform stuff.

Download:
https://drive.google.com/file/d/1Shl1RP ... sp=sharing
Last edited by Marioman2007 on Tue Feb 06, 2024 8:42 am, edited 2 times in total.

mariobrigade2018
Spike
Spike
Posts: 275
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

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

Postby mariobrigade2018 » Mon Feb 05, 2024 3:15 pm

Does this work with the X2 characters? What happens if you enter the world map? Does Link have a proper fix? Does the reserve box work? How would you add this to furyinventory? Heartsforall? LovelyReserve?
Spoiler: show
I. Must. KNOW.

AppleTheTomato
Bit
Bit
Posts: 78
Joined: Wed Jun 02, 2021 8:44 pm
Flair: I am a Tomato named Apple.
Pronouns: He/Him

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

Postby AppleTheTomato » Mon Feb 05, 2024 4:56 pm

I can probably answer the heartsForAll and lovelyReserve question:
With heartsForAll, you'd need to do 3 things (I'll assume you've loaded in heartsForAll with local pc = require("heartsForAll")):
- Possibly adjust pc.kneeScraper to have proper hurt settings for the custom powerups (tho looking at customPowerups files briefly, I don't think you'd have to).
- Add whatever custom forced state is used to pc.bannedStates (like pc.bannedStates[CUSTOM_FORCEDSTATE] = true)
- Add the custom powerup NPCs to pc.powerups (like pc.powerups[751] = {amount = 1})

With lovelyReserves (assuming you load it in with local lr = require("lovelyReserves")), I THINK you'd just need to add the custom powerup NPCs to lr.mainReserveItems (like lr.mainReserveItems[751] = true).

I'm just glancing over the code of customPowerups here, so you may need to do more, but this should be enough. I'd glance over all the scripts' documentation to make sure.

Marioman2007
Lakitu
Lakitu
Posts: 466
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

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

Postby Marioman2007 » Mon Feb 05, 2024 9:35 pm

mariobrigade2018 wrote:
Mon Feb 05, 2024 3:15 pm
Does this work with the X2 characters? What happens if you enter the world map? Does Link have a proper fix? Does the reserve box work? How would you add this to furyinventory? Heartsforall? LovelyReserve?
Spoiler: show
I. Must. KNOW.

By default, the library does not blacklist X2 characters and link. Though there's a function to blacklist them and to (optionally) provide a replacement powerup.
If you want to use this with X2 characters or link, it's up to you to handle the custom powerups or to fight against the code of X2 characters.
Reserve box is working fine for me.
I don't know what is the "proper fix" for link you're referring to.
As for the other libraries, I haven't used them but AppleTheTomato already replied about the last two.

Just_Thomas
Snifit
Snifit
Posts: 234
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

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

Postby Just_Thomas » Tue Feb 06, 2024 3:19 am

Marioman2007 wrote:
Mon Feb 05, 2024 11:44 am
I would like to know for possible future projects: Were you also able to fix the "custom powerup returns as ice flower in reserve box in next level" bug?
I do not know, if the question
Does the reserve box work?
did cover this as well.

And did I get that right, it is kind of a superior version of Emrals one?

However: Great stuff as usual. Still feel like most people around here enjoy coding and creating npcs more than level design. That is almost a luxury problem.

Marioman2007
Lakitu
Lakitu
Posts: 466
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

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

Postby Marioman2007 » Tue Feb 06, 2024 3:29 am

Just_Thomas wrote:
Tue Feb 06, 2024 3:19 am
Marioman2007 wrote:
Mon Feb 05, 2024 11:44 am
I would like to know for possible future projects: Were you also able to fix the "custom powerup returns as ice flower in reserve box in next level" bug?
I do not know, if the question
Does the reserve box work?
did cover this as well.
I haven't tried the former but it shouldn't happen.
For the latter, yes, reservePowerup bugs should be fixed.

DrMekar
Eerie
Eerie
Posts: 778
Joined: Sat Apr 08, 2017 7:16 am
Flair: CUSTOM CHARACTER CREATOR
Contact:

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

Postby DrMekar » Tue Feb 06, 2024 3:58 am

This is looking really good. I was in general still playing with the thought of including New Powerups, so wasn't sure of it to do having to do a lot of maintenance on the earlier levels, though considering the fact that I have to revisit all of them anyway now to replace things like the old Piranha Plants, I might as well give this a shot.

Marioman2007
Lakitu
Lakitu
Posts: 466
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 » Tue Feb 06, 2024 8:42 am

Version 1.1 released!
Changelog in the main post.

DrMekar
Eerie
Eerie
Posts: 778
Joined: Sat Apr 08, 2017 7:16 am
Flair: CUSTOM CHARACTER CREATOR
Contact:

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

Postby DrMekar » Tue Feb 06, 2024 11:20 am

[/quote]
By default, the library does not blacklist X2 characters and link. Though there's a function to blacklist them and to (optionally) provide a replacement powerup.
[/quote]

I had a question about this bit though. Does the replacement option work for classic characters too and also in all circumstances? In my MH1.5 (the Episode I'm currently working on, I so far have 3 playable characters with one of them (Toad) not meant to use the Leaf and Tanooki Suit. Unfortunately just replacing the Items still can the character give the items and it also makes it a bit less varied.

So could I potentially make one Powerup be one transformation for one character and another one
for two other characters?

Marioman2007
Lakitu
Lakitu
Posts: 466
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

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

Postby Marioman2007 » Tue Feb 06, 2024 11:55 am

DrMekar wrote:
Tue Feb 06, 2024 11:20 am
By default, the library does not blacklist X2 characters and link. Though there's a function to blacklist them and to (optionally) provide a replacement powerup.
I had a question about this bit though. Does the replacement option work for classic characters too and also in all circumstances? In my MH1.5 (the Episode I'm currently working on, I so far have 3 playable characters with one of them (Toad) not meant to use the Leaf and Tanooki Suit. Unfortunately just replacing the Items still can the character give the items and it also makes it a bit less varied.

So could I potentially make one Powerup be one transformation for one character and another one
for two other characters?

No, it only works with powerups registered to a customPowerups.
I suggest you to check out whatsThatPowerup.lua by AppleTheTomato.
viewtopic.php?t=29298

mariobrigade2018
Spike
Spike
Posts: 275
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

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

Postby mariobrigade2018 » Tue Feb 06, 2024 12:12 pm

Marioman2007 wrote:
Tue Feb 06, 2024 8:42 am
Version 1.1 released!
Changelog in the main post.
Is there a download for just updating the customPowerups.lua file?

Edit:
Bug are really bugging me:

Image

Image
But hey, at least we can transfer our custom powerups on the world map now.

DrMekar
Eerie
Eerie
Posts: 778
Joined: Sat Apr 08, 2017 7:16 am
Flair: CUSTOM CHARACTER CREATOR
Contact:

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

Postby DrMekar » Tue Feb 06, 2024 1:54 pm

Marioman2007 wrote:
Tue Feb 06, 2024 11:55 am
DrMekar wrote:
Tue Feb 06, 2024 11:20 am
By default, the library does not blacklist X2 characters and link. Though there's a function to blacklist them and to (optionally) provide a replacement powerup.
I had a question about this bit though. Does the replacement option work for classic characters too and also in all circumstances? In my MH1.5 (the Episode I'm currently working on, I so far have 3 playable characters with one of them (Toad) not meant to use the Leaf and Tanooki Suit. Unfortunately just replacing the Items still can the character give the items and it also makes it a bit less varied.

So could I potentially make one Powerup be one transformation for one character and another one
for two other characters?

No, it only works with powerups registered to a customPowerups.
I suggest you to check out whatsThatPowerup.lua by AppleTheTomato.
viewtopic.php?t=29298
Wow, thanks alot. This is exactly what I needed to ensure that some states cannot be triggered.

Just_Thomas
Snifit
Snifit
Posts: 234
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

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

Postby Just_Thomas » Wed Feb 07, 2024 6:42 am

Marioman2007 wrote:
Mon Feb 05, 2024 11:44 am
So, I managed to link the cape feather with your framework
Image
But as you can see, for some reason I started to bug with the fireflower (fireflower variante does not matter, happens with all of them).
Bug does NOT happen with the iceflower, as well NOT with leaf, tanooki suit, hammer bro. suit.

To me, it looks like there is some kind of offset both X and Y .. something about -32 or so. So the fire form does place the player a little to high and to the left from the actual correct position. But I am no expert, I can only describe what I see.

Just to make sure, yes the cape feather powerup (npc-851) uses:

Code: Select all

local ap = require("customPowerups")
luna.lua has the code

Code: Select all

local cp = require("customPowerups")
local capefeather = cp.addPowerup("Cape Feather", "ap_cape", 851)

function onStart()
	Player.setCostume(CHARACTER_MARIO, "SMW-Mario")
	Player.setCostume(CHARACTER_LUIGI, "SMW-Luigi")
end

(files of the cape feather are in the level folder as I could not do it as like in your example with a seperate folder, because of the required cape feather AI file)

and I copied your map.lua with

Code: Select all

local cp = require("customPowerups")
(only copied, nothing changed)

So, something I missed?
I do not get any crash, error or warning message.

An other test: Collect Ice Flower -> collect Fire flower, bug does not happen. But as soon the cape feather comes into play (by getting collected at least once), the fire flower is on drugs. Well, seems obvious it has something to do with the cape itself, otherwise it would ALWAYS happen. These kind of bugs are somehow the worst IMHO.

Marioman2007
Lakitu
Lakitu
Posts: 466
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 » Wed Feb 07, 2024 7:47 am

Just_Thomas wrote:
Wed Feb 07, 2024 6:42 am

I'm unable to reproduce the bug. Earlier today someone else was also experiencing this bug and removing the cap feather worked for them.
Can you zip the level and upload it here or by a PM?

Just_Thomas
Snifit
Snifit
Posts: 234
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

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

Postby Just_Thomas » Wed Feb 07, 2024 8:01 am

Marioman2007 wrote:
Wed Feb 07, 2024 7:47 am
Just_Thomas wrote:
Wed Feb 07, 2024 6:42 am

I'm unable to reproduce the bug. Earlier today someone else was also experiencing this bug and removing the cap feather worked for them.
Can you zip the level and upload it here or by a PM?
I deleted most of the stuff in the level not needed
https://www.file-upload.net/download-15 ... e.zip.html
or
https://file.io/ywiMjf5kIRId
or
https://fastupload.io/FuWdnHmVroBgGrP/file

Marioman2007
Lakitu
Lakitu
Posts: 466
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 » Wed Feb 07, 2024 8:09 am

Just_Thomas wrote:
Wed Feb 07, 2024 8:01 am
Marioman2007 wrote:
Wed Feb 07, 2024 7:47 am
Just_Thomas wrote:
Wed Feb 07, 2024 6:42 am

I'm unable to reproduce the bug. Earlier today someone else was also experiencing this bug and removing the cap feather worked for them.
Can you zip the level and upload it here or by a PM?
I deleted most of the stuff in the level not needed
https://www.file-upload.net/download-15 ... e.zip.html
or
https://file.io/ywiMjf5kIRId
or
https://fastupload.io/FuWdnHmVroBgGrP/file

Thanks.
I think its because of the costumes, after disabling them, things work fine for me.
I'll upload a patch for that soon.
Also one thing I noticed is that you are registering the cape feather twice, the cape feather npc already registers the powerup so you don't need to register it in luna.lua.

Just_Thomas
Snifit
Snifit
Posts: 234
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

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

Postby Just_Thomas » Wed Feb 07, 2024 8:24 am

Thanks for looking/in advance.
I simply checked your example and thought I have to do the same.

About registering: Make assurance double sure I guess :D
Is not really a bad thing here, or isn`t it?

mariobrigade2018
Spike
Spike
Posts: 275
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

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

Postby mariobrigade2018 » Wed Feb 07, 2024 9:32 pm

I'm having trouble registering the Superball Flower and Carrot from Megadood's SML pack:

Image

As shown from the GIF, the Bubble Flower, Drill Mushroom, and Cape Feather work. But the other two just act like a fire flower. Did I do something wrong?

Here's what I regestered in the LunaLua file:

Code: Select all

local cp = require("customPowerups")

local bubbleFlower = cp.addPowerup("Bubble Flower", "powerups/bubbleFlower", 751)

local superballFlower = cp.addPowerup("Superball Flower", "powerups/ap_superball", 957)

local carrot = cp.addPowerup("Carrot", "powerups/ap_carrot", 848)

local drill = cp.addPowerup("Drill", "powerups/drill", 753)
drill.applyDefaultSettings()

Marioman2007
Lakitu
Lakitu
Posts: 466
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 » Wed Feb 07, 2024 10:09 pm

mariobrigade2018 wrote:
Wed Feb 07, 2024 9:32 pm
Here's what I regestered in the LunaLua file:

Code: Select all

local cp = require("customPowerups")

local bubbleFlower = cp.addPowerup("Bubble Flower", "powerups/bubbleFlower", 751)

local superballFlower = cp.addPowerup("Superball Flower", "powerups/ap_superball", 957)

local carrot = cp.addPowerup("Carrot", "powerups/ap_carrot", 848)

local drill = cp.addPowerup("Drill", "powerups/drill", 753)
drill.applyDefaultSettings()

- Did you update the path of every file when moving the libraries "ap_superball" and "ap_carrot"?
- If you did everything correctly and it still doesn't work, try doing "cp.addPowerup("Carrot", "powerups/ap_carrot", 848, true)"
- If it still doesn't work, try doing "cp.registerPowerup("powerups/ap_carrot")"

By default the files "ap_superball" and "ap_carrot" are not inside the "powerups" folder so if you didn't change their location, you would need to replace "powerups/ap_carrot" with just "ap_carrot"

mariobrigade2018
Spike
Spike
Posts: 275
Joined: Wed May 24, 2023 7:00 pm
Flair: Normie in coding who dreams of making a Mario game
Pronouns: he/him

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

Postby mariobrigade2018 » Wed Feb 07, 2024 10:21 pm

Marioman2007 wrote:
Wed Feb 07, 2024 10:09 pm

- Did you update the path of every file when moving the libraries "ap_superball" and "ap_carrot"?
- If you did everything correctly and it still doesn't work, try doing "cp.addPowerup("Carrot", "powerups/ap_carrot", 848, true)"
-I did.
-adding the " ,true" statement at the end fixed it.

Image

Thanks!

Also, how do you make the Drill Mushroom move?
Last edited by mariobrigade2018 on Wed Feb 07, 2024 10:29 pm, edited 1 time in total.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari