KBM-Quine's Lua Assets v1.1.1 - powerstarEXT, custom range power stars

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

Moderator: Userbase Moderators

KBM-Quine
2025 Egg Hunter
2025 Egg Hunter
Posts: 137
Joined: Wed Jan 15, 2014 11:10 am
Flair: Crazy with a K

KBM-Quine's Lua Assets v1.1.1 - powerstarEXT, custom range power stars

Postby KBM-Quine » Wed Mar 16, 2022 1:47 pm

this here's where i'll put non-library lua stuff (NPCs, BGOs, Blocks, ect)
v1.0: show
extendedRinkas: show
extendedRinkas.lua v1.0 - a love letter to moarrinkas.lua
for the handful of moarrinkas.lua fans out there.
all the rinkas from moarrinkas.lua + some others, ported to custom range npcs.
i take no credit for the moarrinkas' ones, this is merely a way of showing respect to then vs. now

new ones i made:
- growing rinka (grows to a configurable max after it begins moving. has maxscale and scalerate as config variables)
- spookinka (it's a boo, but in rinka fashion)
- hyper rinka (is always relentlessly chasing the player)
- rando rinka (randomizes to any other rinka from this library when it starts moving)
with a guest appearance of MDA's making, sniper rinka (goes to where the player will be, really quickly, instead of where they are currently)

along with those additions, rinka blocks got an overhaul too. they can now have the following set in the editor:
- instantly active (if checked, will shoot as soon as it makes a projectile)
- projectile NPC (which NPC to use a a projectile. can be anything, every npc is supported (but not tested, mileage may vary) )
- spawn delay (ticks between spawning projectiles)
- hold delay (the number of ticks projectiles are stationary)
- shoot speed (the amount of speed npcs are shot at)
as an added bonus, they can now be used like rinky guns if you unbury them (ala The Suck from The Invasion 2)

there are two example/template custom range npcs for a rinka and a rinka block. they can be used as a base for making your own. if you don't want two versions of the basegame ones, don't use them. (the rinka can possibly be used by rando rinka, which artificially increases the chance it turns into a normal rinka fyi)

credits:
MrDoubleA - made sniper rinka's code
Enjl - some advice and rewriting moarrinkas for beta 4
aristocrat - for the original moarrinkas and it's graphics
snoruntpyro - for some logic taken from chucks.lua
Valentine - some code for spookinka lifted from reverse boo
Chilly Bean BAM! - testing
gifs: show
Image
Image
usage and documentation: show
simply extract the zip to your destination of choice and it should be working out of the box. for more info on making your own rinkas/using this library, read on.

Code: Select all

extendedRinkas.extendedBlockDrawing = bool (true by default) - toggles the moarrinkas extended rinka block graphics. meant to be used outside of npc-n.lua

extendedRinkas.standardDeathFunction(npcobject) -- a basic call to spawn rinka explosions and play the sm explosion sound. can use deatheffect and deathsound in a rinkas config to override that.

extendedRinkas.rinkaSourceHoming(npcobject, speed) -- a near 1:1 remake of the 1.3 homing rinkas perform

extendedRinkas.rinkaAdvancedHoming(npcobject, speed, angleOffset) -- a vector based version that can be offset by an angle. angle is in degrees

extendedRinkas.defaultBlockSpawning(npcobject) -- the function ran by rinka blocks to spawn their projectiles. npcobject here is the parent of the projectile

extendedRinkas.drawNPC(npcobject, args) -- an offshoot of npcutils.drawNPC. solely made to make things render above rinka blocks. only new arg is priorityOverride, a bool for if forced states should change priority

extendedRinkas.animateNPC(npcobject) -- handles the odd animation rinkas and rinka blocks have. not 1:1 but it's serviceable.

extendedRinkas.registerRinka(npc ID,  {tickFunction = function, deathFunction = function, initFunction = function, isVanilla = bool, noDeathFunction = bool})
- npc id - the id of the npc to register. used in npc-n.lua, see example rinka for an idea of that
-- only use the ones you need!
- tickFunction - a function to run every tick when the rinka should be running code (when not held, the level isn't frozen, or in a state of some sort). see any of the rinkas for a better picture of that.
- deathFunction  - a function to run on the rinkas death, only works if noDeathFunction isn't true
- initFunction  - a function to run when the rinka is initializing data. good for if you need to add your own data variables.
- isVanilla  - a slight misnomer. prevents most of extendedRinkas functions from touching it. good for more complex rinkas (see spookinka for a better idea)
- noDeathFunction - prevents extendedRinkas from running it's default death code. good for rinkas that might need more flexible death effects 

extendedRinkas.registerRinkaBlock() -- uses the same stuff as above
if you wish to change a config, i recommend you use npc-n.txts
grey shy guy: show
a funky little guy based on an unused SMB2 variant. was my first custom npc so i felt it'd be good to release em into the wild. he's pretty simple so i don't think he'd cause much fuss but who knows?
Image
V1.1: show
powerstarEXT.lua: show
a solution to your power star problems. this library/npc AI file handles adding custom range power stars that fully function in every way:
- adds to the counter
- counts on star locks
- removes star lock icons upon collection in levels
- saves to your save file
- gets around the "one per section, 21 per level" limit via an id system
also comes with some example npcs, as shown in the below showcase gif. (power moon graphic made by me, will potentially be more fleshed out later).
originally i was going to scrap this and create a system separate from the 1.3 star system but i never got around to that and don't want my work going to waste in a dusty folder. please read the documentation. credits to: Rednaxela, Enjl, and snoruntpyro for various bits and bobs.
showcase: show
Image
documentation: show
for things to operate properly, you'll need to load this library in your level/episode luna.lua like so:

Code: Select all

local powerstarEXT = require("powerstarEXT")
from there, you have a few things you can call if you want more functionality from it:

Code: Select all

powerstarEXT.idRangeStart -- the number custom range stars start adding to index wise. default is 1000 as not to erase basegame stars if expanded section counts ever becomes a thing. not much of a reason to touch this, but made it a non-hardcoded var anyways.

powerstarEXT.getStarsCollected(filename) -- returns a table of collected stars from the level specified, otherwise returns a table of all collected stars, basegame and custom range alike. formatted like so "table[index number] = {filename, section/star index} (section number if it's a basegame star, star index if it's a powerstarEXT star, which starts at powerstarEXT.idRangeStart + star index)

powerstarEXT.getStarsCollectedCount(filename) -- returns the number of collected stars from the level specified, otherwise returns the number from the star counter.

powerstarEXT.getStarsTotal(filename) -- returns the number of stars total from a level, basegame and custom range alike. this will open the level file, so may not be performant to use all the time.

powerstarEXT.registerStar(npcID, argument functions) -- registers an npc ID as a powerstarEXT star. meant for use in npc lua files. can also supply startFunction, tickEndFunction, and collectFunction to the argument function table to do things in thier respective areas (i.e. powerstarEXT.registerStar(751, {startFunction=start, tickEndFunction=tick, collectFunction=collect}). check the examples for a better understanding.
here's some documentation on those as well:
- startFunction(npc) -- only argument is the current npc running this code
- tickEndFunction(npc) -- only argument is the current npc running this code
- collectFunction(eventToken, killedNPC, harmType, killingPlayer) -- same arguments as onNPCKill + the player that collected the star

powerstarEXT.isStarCollected(npc/section number, filename) -- returns true or false if the passed npc's star index has been collected in the level with the passed filename. can substitute npc with section number for 1.3 stars
Image
Last edited by KBM-Quine on Tue Oct 25, 2022 4:34 am, edited 5 times in total.

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

Re: KBM-Quine's Lua Assets v1.0 - extendedRinkas & grey shy guy

Postby timocomsmbx2345 » Wed Mar 16, 2022 2:47 pm

Thank you, now I can get back to my rinka madness level!!

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: KBM-Quine's Lua Assets v1.0 - extendedRinkas & grey shy guy

Postby Chilly14 » Wed Mar 23, 2022 1:05 pm

The mere fact that I'm credited makes me smile. Good job.

KBM-Quine
2025 Egg Hunter
2025 Egg Hunter
Posts: 137
Joined: Wed Jan 15, 2014 11:10 am
Flair: Crazy with a K

Re: KBM-Quine's Lua Assets v1.1 - powerstarEXT, custom range power stars

Postby KBM-Quine » Sat Aug 06, 2022 3:32 am

update: added powerstarEXT, a library for custom range powerstars. might update it down the line with other fancy stuff, we'll see.
see the first post for more information

AlanLive2020
Buster Beetle
Buster Beetle
Posts: 98
Joined: Fri Nov 27, 2020 8:15 am
Flair: The guy with no social skills or self-esteem :')

Re: KBM-Quine's Lua Assets v1.1 - powerstarEXT, custom range power stars

Postby AlanLive2020 » Fri Sep 09, 2022 6:40 pm

When I grab a power star while playtesting in the editor, it doesn't save like it should. Idk what I'm doing wrong.

Everything else DOES save. I deleted the comment initially because I thought it was because I didn't load it in lua, but no.

KBM-Quine
2025 Egg Hunter
2025 Egg Hunter
Posts: 137
Joined: Wed Jan 15, 2014 11:10 am
Flair: Crazy with a K

Re: KBM-Quine's Lua Assets v1.1 - powerstarEXT, custom range power stars

Postby KBM-Quine » Mon Sep 12, 2022 5:06 am

AlanLive2020 wrote:
Fri Sep 09, 2022 6:40 pm
When I grab a power star while playtesting in the editor, it doesn't save like it should. Idk what I'm doing wrong.

Everything else DOES save. I deleted the comment initially because I thought it was because I didn't load it in lua, but no.
If your using the index settings right, it should. Other then that, the tester flushes stars when new levels are loaded. Due to how the tester works, you can't stop that from happening. Not sure which applies here but everything should be in working order if the power star npc is being loaded and it's settings are done proper. Hope that helps

AlanLive2020
Buster Beetle
Buster Beetle
Posts: 98
Joined: Fri Nov 27, 2020 8:15 am
Flair: The guy with no social skills or self-esteem :')

Re: KBM-Quine's Lua Assets v1.1 - powerstarEXT, custom range power stars

Postby AlanLive2020 » Mon Sep 12, 2022 12:17 pm

KBM-Quine wrote:
Mon Sep 12, 2022 5:06 am
AlanLive2020 wrote:
Fri Sep 09, 2022 6:40 pm
When I grab a power star while playtesting in the editor, it doesn't save like it should. Idk what I'm doing wrong.

Everything else DOES save. I deleted the comment initially because I thought it was because I didn't load it in lua, but no.
If your using the index settings right, it should. Other then that, the tester flushes stars when new levels are loaded. Due to how the tester works, you can't stop that from happening. Not sure which applies here but everything should be in working order if the power star npc is being loaded and it's settings are done proper. Hope that helps
So, that means I have to exit the level after getting the star right? I'm guessing that I can't test it in the editor.

AToMIC
Monty Mole
Monty Mole
Posts: 110
Joined: Fri Jan 24, 2014 2:57 pm
Flair: I'm here
Pronouns: He/Him

Re: KBM-Quine's Lua Assets v1.1 - powerstarEXT, custom range power stars

Postby AToMIC » Fri Oct 21, 2022 9:19 pm

Very sorry to bump this topic, but how do I get the collected Power Stars to show up on a warp? The star count doesn't show up at all for me...

KBM-Quine
2025 Egg Hunter
2025 Egg Hunter
Posts: 137
Joined: Wed Jan 15, 2014 11:10 am
Flair: Crazy with a K

Re: KBM-Quine's Lua Assets v1.1 - powerstarEXT, custom range power stars

Postby KBM-Quine » Fri Oct 21, 2022 10:15 pm

for anyone having trouble with powerstarEXT and warp star counts, i forgot a caveat to it. (it needs to always be loaded) my bad! check it's documentation for a better understanding of how that goes.

KBM-Quine
2025 Egg Hunter
2025 Egg Hunter
Posts: 137
Joined: Wed Jan 15, 2014 11:10 am
Flair: Crazy with a K

Re: KBM-Quine's Lua Assets v1.1.1 - powerstarEXT, custom range power stars

Postby KBM-Quine » Tue Oct 25, 2022 4:36 am

okay, small update to powerstarEXT!

- star counts work properly with gaps in warps with levels now (break was a bad choice admittly)
- star lock icon bgos now get disposed of properly when you collect a custom range star
- level parsing now using FileFormats, only time will tell if that improves anything.
- new & tweaked functions for external use such as: isStarCollected, getStarsCollected, getStarsCollectedCount, and getStarsTotal. see documentation for more information
- can now use per-NPCID startFunction, tickEndFunction, and collectFunction for some forms of control in these areas. see documentation for more information
- with the above, the included power moon shows a basic use of collectFunction and the included SMW power star uses startFunction to mimic the 1.3 SMW power star's death on start functionality
-- power moon is subject to further change, current implementation is for example.


Return to “LunaLua”

Who is online

Users browsing this forum: DRACalgar Law and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari