(Request) Star And Exit Indicator For World Map

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
King Mario
Hoopster
Hoopster
Posts: 122
Joined: Sun Nov 19, 2017 2:13 pm
Flair: Jesus Christ is Lord!
Pronouns: he/him
Contact:

(Request) Star And Exit Indicator For World Map

Postby King Mario » Wed Dec 06, 2023 10:55 am

I've been playing through "SMBX: A New Problem" and I couldn't find all the stars. I saw a pipe in the Warp Zone that seemed to lead to a secret world, but the paths there don't work. I had to use the Editor to bypass the 50-star lock because of this, but I do wish I could've found the rest of the stars.

Which leads to my main point. The only easy solution I can think of for this problem, is if I could implement a star counter for individual levels on the world map to figure out which stars I'm missing (if there are even any left), just like I could in hub-based Episodes.

Like so: Image

If anyone knows of something like this (that's compatible with B4), then please let me know. The only other solution I can think of is checking the Editor extensively for uncollected stars, and then playing through levels in the Episode again to collect them. Seems obnoxious to me and I'd rather not do that.

Added in 3 minutes 50 seconds:
Oh and BTW, I know I said "Star And Exit Indicator For World Map", but for now the Exit indicator is entirely optional. The Star indicator, on the other hand, would prove to be more than useful right now.

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: (Request) Star And Exit Indicator For World Map

Postby mariobrigade2018 » Wed Dec 06, 2023 11:43 am


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

Re: (Request) Star And Exit Indicator For World Map

Postby King Mario » Wed Dec 06, 2023 11:56 am

You mean starCoinCounter.lua? Are you trying to say that the counter for Star Coins in individual map levels could work for collectible Stars too? I guess I could try it.

Is there anything you'd recommend i change in the script?

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

Re: (Request) Star And Exit Indicator For World Map

Postby Emral » Wed Dec 06, 2023 6:20 pm

the way we did it for level contest japan (the episode pictured) is to manually write down the star count and exit count for each level, put it in a table indexed by level name and Text.print it to the world map
local starsAndExits = {
["myLevel.lvlx"] = {stars = 2, exits = 1},
["myLevel2.lvlx"] = {stars = 1, exits = 1},
}
If you wanna do something like that for an episode you're unfamiliar with:
stars can be found via the level header. exits would need a manual scan of the level data for non-friendly exit npcs in different sections. FileFormats.openLevelHeader and FileFormats.getLevelData can get you the header and full file respectively.

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

Re: (Request) Star And Exit Indicator For World Map

Postby King Mario » Wed Dec 06, 2023 8:12 pm

Emral wrote: If you wanna do something like that for an episode you're unfamiliar with:
stars can be found via the level header. exits would need a manual scan of the level data for non-friendly exit npcs in different sections. FileFormats.openLevelHeader and FileFormats.getLevelData can get you the header and full file respectively.
Very interesting information. Could you please explain it in more of layman's terms though? I'm not exactly a professional at this. If I knew how to properly implement these two into play (meaning FileFormats.openLevelHeader and FileFormats.getLevelData) I might make more sense of it.

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

Re: (Request) Star And Exit Indicator For World Map

Postby Emral » Thu Dec 07, 2023 6:51 am

It's gonna be difficult without some experience, so I don't know how much I can help.
You could Misc.dialog the return variables of those functions and then go from there:
local headerData = FileFormats.openLevelHeader("myLevel.lvlx")
Misc.dialog(headerData)
local levelData = FileFormats.getLevelData("myLevel.lvlx")
Misc.dialog(levelData)

The documentation on these functions is sadly sparse but by debugging like this you should be able to find out what exactly is stored where. Looking at basegame use, I was able to ascertain that headerData.data.showInMarioChallenge is a thing, and that headerData.meta exists.

Remember that "exit count" is not information easily discoverable from this. It comes down to a combination of
- manually finding Exit type NPCs that are not friendly and of different exit types
- finding warps that lead out of the level but don't lead to another level
- finding keyhole and key npcs. This is not a given, though, as the keys might be used for something else. It can always give misleading info.
- offscreen exit sections

"Okay that's cool and all but what if I wanna do it for the level you stand on on the map?
For that you can use the World class.
https://docs.codehaus.moe/#/reference/world
if world.levelObj and world.levelObj.filename ~= "" then
-- use world.levelObj.filename instead of "myLevel.lvlx"
end

Hopefully that's enough to get you started.

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

Re: (Request) Star And Exit Indicator For World Map

Postby King Mario » Thu Dec 07, 2023 12:34 pm

I think I tried what you said. I put in the code you suggested, plus added a little bit:

Code: Select all

local function starCounter()
    if world.levelObj and world.levelObj.filename ~= "level0.lvlx" then
        local headerData = FileFormats.openLevelHeader(world.levelObj.filename)
        Misc.dialog(headerData)
    end
end
I changed "level0.lvl" in the episode to "level0.lvlx" and then tried it. It's not giving me debug messages or errors anymore after that, but nothing seems to be happening either. Is there something valuable that I'm missing? And also, how would I apply the LCJ-style World Map star symbol to the hud afterwards?

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

Re: (Request) Star And Exit Indicator For World Map

Postby Emral » Fri Dec 08, 2023 4:56 am

King Mario wrote:
Thu Dec 07, 2023 12:34 pm
Are you calling the starCounter function anywhere? Like from onDraw, for example?

To draw an icon, you just use the Graphics.loadImage and Graphics.drawImage functions. I wrote a guide specifically for this: https://docs.codehaus.moe/#/guides/how- ... -functions


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 5 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari