How to check if a player has collected enough star coins when entering a warp

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

zekene20
Shy Guy
Shy Guy
Posts: 5
Joined: Fri Nov 03, 2023 3:03 pm
Pronouns: he/him/his

How to check if a player has collected enough star coins when entering a warp

Postby zekene20 » Tue Dec 24, 2024 10:06 pm

I am wondering if there's a way to check if I can block a player from entering a warp if he does not have the required star coins. I know you can do it with Power Stars, but I wanted to use star coins instead.

proCoder
Shy Guy
Shy Guy
Posts: 5
Joined: Sat Mar 15, 2025 7:28 pm
Flair: The best coder (maybe)
Pronouns: he/him

Re: How to check if a player has collected enough star coins when entering a warp

Postby proCoder » Sun Mar 16, 2025 2:05 pm

I suppose you could do this:

Code: Select all

local starCoinsTotal = 3 -- Replace with how many star coins you placed in the editor
local starCoinsCollected = starCoinsTotal - #NPC.get(310)
But I don't actually know how to block the player from using a warp.
You could spawn some blocks to block the warp and then remove them when the player
gets enough, But if you want to do it without that I've got nothing.
Last edited by proCoder on Sun Mar 16, 2025 2:07 pm, edited 1 time in total.

Gaming-Dojo
Tweeter
Tweeter
Posts: 143
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

Re: How to check if a player has collected enough star coins when entering a warp

Postby Gaming-Dojo » Fri Aug 08, 2025 6:14 am

Generally, there should be 3 ways to block warps for the player:

1. set entranceHeight and entranceWidth to 0
2. set locked property of warp to yes
3. set starsRequired to a very high number

I think the first option is best spontaneously as I think there are downsides to the other two options which doesn't apply to the first method, you just might want to draw an indicator next to the warp entrance so the player knows how much star coins are needed. However, I will do some tests when I'm at home and reply again when I have new results.

deice
Rocky Wrench
Rocky Wrench
Posts: 637
Joined: Fri Jul 23, 2021 7:35 am

Re: How to check if a player has collected enough star coins when entering a warp

Postby deice » Fri Aug 08, 2025 8:05 am

Gaming-Dojo wrote:
Fri Aug 08, 2025 6:14 am
1. set entranceHeight and entranceWidth to 0
2. set locked property of warp to yes
3. set starsRequired to a very high number
besides this being a massive necrobump for a problem that the op is not that likely to still be interested in, none of these are good ways to disable warps. the cleanest method is to put the warp in its own layer and then hide/show that layer as necessary.
1. setting a warp's entrance size to 0 has the potential to cause certain bugs and is generally not elegant
2. a locked warp signals to the player that they need a key, rather than a different collectible (in this case star coins), not to mention it doesn't work for areas where the player might have access to a key
3. a warp blocked behind a star requirement also signals to the player that they need something completely different, making 2 and 3 both unnecessarily confusing

Gaming-Dojo
Tweeter
Tweeter
Posts: 143
Joined: Mon Jan 25, 2016 9:20 am
Pronouns: he/him
Contact:

Re: How to check if a player has collected enough star coins when entering a warp

Postby Gaming-Dojo » Fri Aug 08, 2025 8:32 am

Thanks for the insights and the idea with layers. I didn't know that setting width and height of warp entrance is buggy. I thought about method 2 messing with keys but didn't think it were that severe, esp if keys aren't used otherwise in the episode. I also thought 3 to be confusing but thought there might be a way to disable the star message and sign. However I added them anyways for completions sake.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 29 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari