anotherpowerup.lua - and another one

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

Moderator: Userbase Moderators

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

anotherpowerup.lua - and another one

Postby Emral » Wed Apr 01, 2020 3:51 pm

I woke up today with motivation to do this so here you go:
https://drive.google.com/file/d/1FeFLta ... sp=sharing
Gif: show
Image
How does it work?
This essentially replaces the fire and ice flower with whatever you want. It comes preinstalled with fire and ice flower replacements, and I included a little demo level with a Gold Flower to show how a custom powerup might be implemented.

Features:
- Technically infinite powerups. The biggest bottleneck is your motivation to make player hitboxes and spritesheets and code.
- As mentioned above, every powerup state can have its own hitboxes and spritesheets. Hitboxes must be named like "mario-powerupname.ini", so in the example for the gold flower that'd be "mario-ap_goldflower.ini".
- Every powerup gets onTick, onDraw, onTickEnd which run only when the powerup is active, as well as onEnable and onDisable for when the player switches to and fro.
- As a little additional feature, you can define powerup tiers, or just whether you would like to have the powerup turn into a mushroom when the player is small.
- Powerups save across levels.

Limitations:
- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks).
- Only works with Mario, Luigi, Peach, Toad. Link's projectile timers make extracting fire and ice flower for this impossible. The rest all have custom code that is impossible to fight against.

Stuff:
-- registerPowerup registers a new powerup to the system
--- libraryName: string - The name of the library containing powerup information. One library per powerup. Think of it as a require(libraryName) call

-- Returns the library table for the powerup
ap.registerPowerup(libraryName)

-- Returns the player's current powerup, accounting for anotherpowerup powerups. Use this instead of player.powerup.
function ap.getPowerup()

-- Use this instead of setting powerup. Silent avoids the powerup animation and sound.
function ap.setPlayerPowerup(appower, silent)

-- registerItemTier registers a new tier chain for items.
-- spawnedItem: number - The item that spawns from a block.
-- chain: table - The list of states ordered by significance. Numbers correspond to vanilla states, strings correspond to the names of anotherpowerup powerups. See demo for more info.
-- if you provide chain as "true", it will accept everything except for small mario
function ap.registerItemTier(spawnedItem, chain)

Score is doubled up for vanilla powerup npcs but literally who cares.
If you make powerups for this make sure that they're clearly marked as anotherpowerup mods so people can find them.

Enjoy.

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

Re: anotherpowerup.lua - and another one

Postby Taycamgame » Wed Apr 01, 2020 5:28 pm

I thought it was currently impossible to add new powerups due to the Id system?

ElectriKong
Bowser
Bowser
Posts: 4651
Joined: Mon Jun 06, 2016 4:32 pm
Flair: I have NO idea what to put here
Pronouns: he/him
Contact:

Re: anotherpowerup.lua - and another one

Postby ElectriKong » Wed Apr 01, 2020 5:43 pm

Taycamgame wrote:
Wed Apr 01, 2020 5:28 pm
I thought it was currently impossible to add new powerups due to the Id system?
Still is. This system just replaces fire and ice flowers.

FanofSMBX
Ludwig von Koopa
Ludwig von Koopa
Posts: 3878
Joined: Sun Dec 22, 2013 12:01 pm

Re: anotherpowerup.lua - and another one

Postby FanofSMBX » Sat May 02, 2020 12:36 am

"- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks)."

Can't one theoretically
1. Combine fire and ice mario into slot 3
2. Make slot 7 have a small hitbox
3. Code custom blocks (brick and turn block replicas) that do NOT smash if one is in form 7?

It's complex, sure, but if one is already making Mini Mario's floaty physics and water stuff then this should be possible.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: anotherpowerup.lua - and another one

Postby Emral » Sat May 02, 2020 1:30 am

FanofSMBX wrote:
Sat May 02, 2020 12:36 am
"- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks)."

Can't one theoretically
1. Combine fire and ice mario into slot 3
2. Make slot 7 have a small hitbox
3. Code custom blocks (brick and turn block replicas) that do NOT smash if one is in form 7?

It's complex, sure, but if one is already making Mini Mario's floaty physics and water stuff then this should be possible.
Points 1 and 2 dont even contribute to changing those properties, especially since anotherpowerup gives each powerup a string-index, and each powerup already can have its own hitbox (by means of loading/unloading them for player.powerup in onEnable and onDisable). If you REALLY wanna reprogram the powerup hierarchy and all brick blocks and enemy bounce physics... and prevent the player from riding a mount then ... maybe... you can get close to something that resembles mini mushroom, though the amount of effort to make it non-janky is not trivial.

Bulby_VR
Fighter Fly
Fighter Fly
Posts: 33
Joined: Wed Aug 07, 2019 11:18 am

Re: anotherpowerup.lua - and another one

Postby Bulby_VR » Fri May 08, 2020 11:29 am

um i think that it's bad that it causes an error when you try to pick up a power up with a incompatible character? Is it the power up itself or the inner script?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: anotherpowerup.lua - and another one

Postby Emral » Fri May 08, 2020 12:35 pm

Bulby_VR wrote:
Fri May 08, 2020 11:29 am
um i think that it's bad that it causes an error when you try to pick up a power up with a incompatible character? Is it the power up itself or the inner script?
Well, they're incompatible. I didn't optimize for those, because I figured an episode using this would hardly employ characters that don't work with it.

Bulby_VR
Fighter Fly
Fighter Fly
Posts: 33
Joined: Wed Aug 07, 2019 11:18 am

Re: anotherpowerup.lua - and another one

Postby Bulby_VR » Sat May 09, 2020 12:51 pm

ah, ok

ArtAddictedArchitect
Shy Guy
Shy Guy
Posts: 8
Joined: Fri Aug 09, 2019 11:05 am

Re: anotherpowerup.lua - and another one

Postby ArtAddictedArchitect » Mon Jun 29, 2020 7:01 am

So, apart from no mini Mario— what needs to get this useable? By making hit boxes do you mean importing the custom tiles for the new powerup you make or something else?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: anotherpowerup.lua - and another one

Postby Emral » Mon Jun 29, 2020 7:49 am

ArtAddictedArchitect wrote:
Mon Jun 29, 2020 7:01 am
So, apart from no mini Mario— what needs to get this useable? By making hit boxes do you mean importing the custom tiles for the new powerup you make or something else?
You need to use the player calibration tool in the data/pge folder to calibrate the hitboxes. Getting a powerup set up is inferrable from the included gold mario example.

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: anotherpowerup.lua - and another one

Postby MrDoubleA » Mon Jun 29, 2020 11:24 am

I've been wondering... why exactly is the mini mushroom not possible? Couldn't the issues be avoided with onNPCHarm and onBlockHit, and onPlayerHarm?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: anotherpowerup.lua - and another one

Postby Emral » Mon Jun 29, 2020 11:38 am

MrDoubleA wrote:
Mon Jun 29, 2020 11:24 am
I've been wondering... why exactly is the mini mushroom not possible? Couldn't the issues be avoided with onNPCHarm and onBlockHit, and onPlayerHarm?
Potentially.

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: anotherpowerup.lua - and another one

Postby MrDoubleA » Mon Jul 13, 2020 1:21 pm

I've been using this library for a bit, and I have a couple bugs/annoyances to share.

- If you pick up a custom powerup but you already have that powerup, it'll still play the animation.
- When picking up a custom powerup, often times the wrong powerup will appear in the item box. This could maybe be fixed by setting 0x46 to the NPC ID of the powerup (though it'd need to happen after the animation happens, and therefore outside of the setPlayerPowerup function).
- Not a bug, but it'd be really nice to let the sound effect played when grabbing it be customisable.
- Only works with Mario, Luigi, Peach, Toad. Link's projectile timers make extracting fire and ice flower for this impossible. The rest all have custom code that is impossible to fight against.
- Link's projectiles have a dedicated timer, so you can just do this every tick:

Code: Select all

player:mem(0x162,FIELD_WORD,29)
As for the x2 characters... I don't really think anybody cares about those lol


Good job on this, though! It's really nice to have a functional custom powerup library.


Edit: There's also some bugs with the fire/ice flower recreations:
- Both don't spawn fireballs when spin jumping.
- Fire flowers (but not ice flowers) give this error:
Error: show
Image

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: anotherpowerup.lua - and another one

Postby Emral » Mon Jul 13, 2020 1:51 pm

Thanks for pointing these out! I'll get to fixing them when I have time. I'll reply here when that's happened.

The spinjump thing is actually intentional. Mostly because platforming with a fire flower or ice flower is pretty miserable otherwise. Part of it is also though that I'm not sure how to best do it... Maybe I could make it toggleable if I find that out.

Added in 3 hours 16 minutes 14 seconds:
... alright... Updated the file with a few fixes and experiments.
- Link support? I guess? I'm not sure? The existing powerups don't work with them the way they're written, but the script at least won't outright reject link now. I don't really feel like dealing with link code in the example powerups tbh, but maybe he'll work for further custom ones.
- Fixed the fireflower crash
- You can now have .apSounds table in your powerup file for the upgrade and reserve storage sound effect. Check gold flower for an example. If you wanna change it per character, adjust it upon character change on your end.
- Redesigned the powerup distribution mechanism. Instead of spawning an item on the player it now manually sets the relevant offsets.
- Hopefully fixed reserve powerup distribution as well?

Known issues:
- No change to the way fireball spinjumping works. You can still manually shoot fireballs throughout a spinjump, however.
- Because fire and ice flower in the basic example only use the basegame powerup, there are some duplicate effects, and sometimes the wrong sound effect for the animation plays. The solution here is to introduce new powerup items for those states.
- Still no multiplayer. I toyed around with the idea a little bit, but it's getting late and I don't consider it a priority.

MrDoubleA
Ripper II
Ripper II
Posts: 394
Joined: Mon Aug 20, 2018 7:02 am
Flair: How much munchers?

Re: anotherpowerup.lua - and another one

Postby MrDoubleA » Wed Jul 15, 2020 6:10 pm

Thanks for the update! There's just 3 new bugs I've found recently. (Sorry for all the hassle...)

- The reserve powerup is much more functional now, though it still doesn't seem to work 100% properly.
you're a mouse? - If you collect a custom powerup with nothing in 0x46, you'll get the custom powerup in the item box for whatever reason
you're a mouse? - If you collect a normal powerup while having a custom powerup, a fire/ice flower will appear in the item box
(you should just be able to set 0x46 and reservePowerup appropriately when getting a custom powerup, since 0x46 isn't cleared on level load, though I don't know what's going on with that latter bug)

- The player's frame doesn't get reset to 1 like it normally does when picking up a custom powerup, resulting in the animation almost always looking odd when transforming from small mario)
- Costumes do not work with the fire/ice flower recreations

Edit: it also seems that hitting a block containing a non-custom powerup gives this error:
Error: show
Image

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

Re: anotherpowerup.lua - and another one

Postby Marioman2007 » Tue Sep 29, 2020 5:03 am

Wow, I was just looking for a Gold Flower, Thanks. But I replaced the golden mario and Gold ball sprites with the one that lx xzit made. I want to ask you one question is it possible to add an sparkling effect and golden trail like the fire flower (effect-77) ?

timocomsmbx2345
Foo
Foo
Posts: 852
Joined: Sat Feb 06, 2016 1:44 pm
Contact:

Re: anotherpowerup.lua - and another one

Postby timocomsmbx2345 » Tue Mar 23, 2021 12:32 pm

For some reason I still get an error when I hit a block with a fire flower in it, even within the demo.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: anotherpowerup.lua - and another one

Postby Emral » Fri Jun 18, 2021 4:21 pm

Thanks to MrDoubleA, the reserve item bug is now fixed! Big thanks to them.

Zaturno Dominicano
Cheep-Cheep
Cheep-Cheep
Posts: 12
Joined: Fri Aug 27, 2021 1:55 pm
Flair: ...............
Pronouns: Nothing
Contact:

Re: anotherpowerup.lua - and another one

Postby Zaturno Dominicano » Sat Sep 04, 2021 8:18 am

Enjl wrote:
Wed Apr 01, 2020 3:51 pm
I woke up today with motivation to do this so here you go:
https://drive.google.com/file/d/1FeFLta ... sp=sharing
Gif: show
Image
How does it work?
This essentially replaces the fire and ice flower with whatever you want. It comes preinstalled with fire and ice flower replacements, and I included a little demo level with a Gold Flower to show how a custom powerup might be implemented.

Features:
- Technically infinite powerups. The biggest bottleneck is your motivation to make player hitboxes and spritesheets and code.
- As mentioned above, every powerup state can have its own hitboxes and spritesheets. Hitboxes must be named like "mario-powerupname.ini", so in the example for the gold flower that'd be "mario-ap_goldflower.ini".
- Every powerup gets onTick, onDraw, onTickEnd which run only when the powerup is active, as well as onEnable and onDisable for when the player switches to and fro.
- As a little additional feature, you can define powerup tiers, or just whether you would like to have the powerup turn into a mushroom when the player is small.
- Powerups save across levels.

Limitations:
- You cannot make mini mario since every powerup has the properties of a full grown adult (can smash bricks and turn blocks).
- Only works with Mario, Luigi, Peach, Toad. Link's projectile timers make extracting fire and ice flower for this impossible. The rest all have custom code that is impossible to fight against.

Stuff:
-- registerPowerup registers a new powerup to the system
--- libraryName: string - The name of the library containing powerup information. One library per powerup. Think of it as a require(libraryName) call

-- Returns the library table for the powerup
ap.registerPowerup(libraryName)

-- Returns the player's current powerup, accounting for anotherpowerup powerups. Use this instead of player.powerup.
function ap.getPowerup()

-- Use this instead of setting powerup. Silent avoids the powerup animation and sound.
function ap.setPlayerPowerup(appower, silent)

-- registerItemTier registers a new tier chain for items.
-- spawnedItem: number - The item that spawns from a block.
-- chain: table - The list of states ordered by significance. Numbers correspond to vanilla states, strings correspond to the names of anotherpowerup powerups. See demo for more info.
-- if you provide chain as "true", it will accept everything except for small mario
function ap.registerItemTier(spawnedItem, chain)

Score is doubled up for vanilla powerup npcs but literally who cares.
If you make powerups for this make sure that they're clearly marked as anotherpowerup mods so people can find them.

Enjoy.
Hey could you upload the files of the golden flower? it looks very cool

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

Re: anotherpowerup.lua - and another one

Postby Marioman2007 » Sat Sep 04, 2021 10:05 am

Zaturno Dominicano wrote:
Sat Sep 04, 2021 8:18 am
Hey could you upload the files of the golden flower? it looks very cool
It is contained with the download


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 5 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari