A lot of stuff that I want to know is possible in LunaLua

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
MarioChallengerX2
Bit
Bit
Posts: 77
Joined: Sat Dec 31, 2022 4:34 pm
Pronouns: he/him

A lot of stuff that I want to know is possible in LunaLua

Postby MarioChallengerX2 » Wed Feb 01, 2023 9:05 pm

1. Is it possible to make an enemy: Once they're killed, they stay killed. And upon killing them the first time, they make blocks appear. (I know, you would have to have many layers and events linked to be possible.) And if they never respawn, the blocks are still there. (Sort of tricky as well because, in order to do that, they would have to be their own separate layer, and fulfill if layer is empty requirement.) But my point is, with Lua, is it possible to make an enemy never respawn once you've killed it before in a previous attempt in a level? (This is within an episode) (Also, side note: I want to use rooms.lua in my episode and I'm not sure how the new rooms.lua code will affect this, once that releases)

2. Is it possible to swap levels in the world map with other files using LunaLua? Like, I mean: The second level is called (Mario's Cavern Expedition) but if I do a certain achievement like "Activate the hidden drill", the level is now called "Broken Expedition" which is like that because the drill broke the caves. I mainly want to swap levels using achievements if possible.

3. Is it possible to apply or change new graphics to a map like, if you did the drill thing in the example I mentioned before, the cave would be cracked instead of an actual cave. Again, something linked to achievements.

4. Is it possible to slow down music through lua? (Just to skip creating a different music file for the episode folder and so people won't be sus about it for whatever reason)

That's all I really want to know for myself so I can apply this tech in my episode somehow.

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

Re: A lot of stuff that I want to know is possible in LunaLua

Postby Emral » Wed Feb 01, 2023 9:56 pm

1. Yes, but only if the NPCs are there when the level starts and aren't generated or otherwise spawned.
The way to do it is to iterate over your NPCs in onStart and create a SaveData variable in a list, the index matching that of the index in the for loop you're in. Save the same number to the NPC's data table, so that in onPostNPCKill you can use it to set the SaveData flag. In onPostNPCKill you would then also spawn the blocks.
If the SaveData flag is set, you kill the NPC in onStart, spawning the blocks once again.

2. Yes, using if statements and fields like world.levelTitle and world.levelObj.filename
https://docs.codehaus.moe/#/reference/world

3. Change the .id field of a level object on the map, or use SpriteOverride to hotswap the graphics for all tiles of the current ID
https://docs.codehaus.moe/#/reference/g ... teoverride

4. Not at the moment

deice
Volcano Lotus
Volcano Lotus
Posts: 538
Joined: Fri Jul 23, 2021 7:35 am

Re: A lot of stuff that I want to know is possible in LunaLua

Postby deice » Thu Feb 02, 2023 4:35 am

Enjl wrote:
Wed Feb 01, 2023 9:56 pm
2. Yes, using if statements and fields like world.levelTitle and world.levelObj.filename
https://docs.codehaus.moe/#/reference/world
just a pre-emptive note for op about world.levelObj specifically: i believe it doesn't work properly for levels that share their title with other levels on the world map. there should be a basegame script called "mapmanager" or something that offers a better alternative but my memory's a bit fuzzy on that.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari