Need help with lua? - LunaLua General Help

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

Moderator: Userbase Moderators

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

Re: Need help with lua? - LunaLua General Help

Postby deice » Thu Jan 09, 2025 6:52 pm

Jokyaku wrote:
Thu Jan 09, 2025 4:58 pm
Hello! I'm currently just finishing a custom NPC and I was wondering if there was any way of using Extra Settings to alter an NPC Config such as nofireball or jumphurt.
extra settings are typically used for setting parameters on individual npc instances, whereas npc config (aside from some outliers like noblockcollision) have no way of being applied selectively. there are ways to emulate certain npc config flags (e.g. cancelling a harm event for a specific npc with a certain setting applied to make it immune to fireballs) but this depends heavily on the use case

could you elaborate on exactly what you're trying to do?

jokyaku
Goomba
Goomba
Posts: 4
Joined: Thu Jan 20, 2022 7:44 am
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby jokyaku » Fri Jan 10, 2025 6:07 am

deice wrote:
Thu Jan 09, 2025 6:52 pm
Jokyaku wrote:
Thu Jan 09, 2025 4:58 pm
Hello! I'm currently just finishing a custom NPC and I was wondering if there was any way of using Extra Settings to alter an NPC Config such as nofireball or jumphurt.
extra settings are typically used for setting parameters on individual npc instances, whereas npc config (aside from some outliers like noblockcollision) have no way of being applied selectively. there are ways to emulate certain npc config flags (e.g. cancelling a harm event for a specific npc with a certain setting applied to make it immune to fireballs) but this depends heavily on the use case

could you elaborate on exactly what you're trying to do?
I'm making a "Bro" NPC with way too many variants so I'm using Extra Settings to alter which variant I want instead of using a different NPC slot for each one, sorta like how the Paratroopa works but with more variants and also changing the sprite on each one.

I wanted to know if changing the config in a case by case basis was possible since it would be a lot easier to manage, but if it's not possible I'll just emulate the behavior like you mentioned, thanks for the help.

Image

Muffler
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Wed Jan 20, 2021 12:42 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby Muffler » Mon Jan 13, 2025 3:08 pm

Is there a way to check if the player is riding a Yoshi?

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 641
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby mariobrigade2018 » Mon Jan 13, 2025 7:23 pm

Muffler wrote:
Mon Jan 13, 2025 3:08 pm
Is there a way to check if the player is riding a Yoshi?

Code: Select all

if player.mount == MOUNT_YOSHI then
	--do code
end
https://docs.codehaus.moe/#/constants/mounts

Muffler
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Wed Jan 20, 2021 12:42 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby Muffler » Tue Jan 14, 2025 11:00 am

mariobrigade2018 wrote:
Mon Jan 13, 2025 7:23 pm
Muffler wrote:
Mon Jan 13, 2025 3:08 pm
Is there a way to check if the player is riding a Yoshi?

Code: Select all

if player.mount == MOUNT_YOSHI then
	--do code
end
https://docs.codehaus.moe/#/constants/mounts
Thank you sm!

Muffler
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Wed Jan 20, 2021 12:42 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby Muffler » Thu Feb 06, 2025 9:55 am

Hello, I have two questions:
1. Does anyone have a script that changes how the camera behaves to make it more like the NSMB games? I really don't like how your character is always at the center and I would like to change that. I know about SMWCamera but it is very old and it's not compatible with warpTransitions.
2. Can you disable the flight ability of the Super Leaf and Tanooki Suit and how do you do that? I'd like it to be like in 3D Land where you can only attack and glide.
Thank you in advance!

mariobrigade2018
Rocky Wrench
Rocky Wrench
Posts: 641
Joined: Wed May 24, 2023 7:00 pm
Flair: OK in coding who dreams of making a Mario game
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby mariobrigade2018 » Tue Feb 18, 2025 11:16 pm

Muffler wrote:
Thu Feb 06, 2025 9:55 am
Hello, I have two questions:
1. Does anyone have a script that changes how the camera behaves to make it more like the NSMB games? I really don't like how your character is always at the center and I would like to change that. I know about SMWCamera but it is very old and it's not compatible with warpTransitions.
2. Can you disable the flight ability of the Super Leaf and Tanooki Suit and how do you do that? I'd like it to be like in 3D Land where you can only attack and glide.
Thank you in advance!
1. Camera manipulation is kinda a pain to deal with, and I’d imagine that it would be a massive headache to make that in SMBX.

2. viewtopic.php?t=29298

arthur4272
Cheep-Cheep
Cheep-Cheep
Posts: 12
Joined: Sat Feb 19, 2022 2:51 am
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby arthur4272 » Sun Mar 02, 2025 2:47 pm

Image
I'm having this problem with Dracula, what I can do about it?

Muffler
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Wed Jan 20, 2021 12:42 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby Muffler » Wed Mar 12, 2025 5:28 pm

Hello, is there a way to remove the hearts system for Toad and Peach, so that their health is based on powerup state instead like Mario and Luigi?

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

Re: Need help with lua? - LunaLua General Help

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

I've been trying to use capture buffers to capture the background of the level (for use in the lives screen)
but it just says "Invalid type for capture buffer."

I looked in the code and turns out my capture buffer apparently isn't a capture buffer, somehow.
How does this work?

Code: Select all

local buffer = Graphics.CaptureBuffer() -- Realized that width and height defaults to main frame buffer size
buffer.captureAt(-100) -- Here is the error, Also -100 is the priority of the level background

Graphics.drawBox{
    x = 0,
    y = 0,
    priority = priority - 2,
    w = cam.width,
    h = cam.height,
    texture = buffer
}

DigitalDetective47
Bot
Bot
Posts: 51
Joined: Fri Mar 27, 2020 10:12 pm
Pronouns: they/them
Contact:

weird behavior of globals

Postby DigitalDetective47 » Thu May 01, 2025 2:56 am

i am trying to make a library with the following structure:

library.lua

Code: Select all

function onStart()
    --Do stuff
end
luna.lua

Code: Select all

require("library")
for some reason, the onStart function in the library isn't called. i've tested playing a sound effect in the global scope of library.lua and luna.lua, as well as within a new onStart function within luna.lua, and these all trigger. but if it's specifically within the onStart specified within a require, it doesn't work. why is this happening?

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

Re: Need help with lua? - LunaLua General Help

Postby Emral » Thu May 01, 2025 3:38 am

DigitalDetective47 wrote: i am trying to make a library with the following structure:

library.lua

Code: Select all

function onStart()
    --Do stuff
end
luna.lua

Code: Select all

require("library")
for some reason, the onStart function in the library isn't called. i've tested playing a sound effect in the global scope of library.lua and luna.lua, as well as within a new onStart function within luna.lua, and these all trigger. but if it's specifically within the onStart specified within a require, it doesn't work. why is this happening?
functions in libraries should be registered to the library table.

Code: Select all

local myLib = {}
function myLib.onStart()

end

registerEvent(myLib, "onStart")
return myLib
If you simply have one onStart here, and another onStart in the script calling the library, then the script calling the library overwrites the onStart from the library.

DigitalDetective47
Bot
Bot
Posts: 51
Joined: Fri Mar 27, 2020 10:12 pm
Pronouns: they/them
Contact:

Re: weird behavior of globals

Postby DigitalDetective47 » Thu May 01, 2025 4:04 am

Emral wrote:
Thu May 01, 2025 3:38 am
DigitalDetective47 wrote: i am trying to make a library with the following structure:

library.lua

Code: Select all

function onStart()
    --Do stuff
end
luna.lua

Code: Select all

require("library")
for some reason, the onStart function in the library isn't called. i've tested playing a sound effect in the global scope of library.lua and luna.lua, as well as within a new onStart function within luna.lua, and these all trigger. but if it's specifically within the onStart specified within a require, it doesn't work. why is this happening?
functions in libraries should be registered to the library table.

Code: Select all

local myLib = {}
function myLib.onStart()

end

registerEvent(myLib, "onStart")
return myLib
If you simply have one onStart here, and another onStart in the script calling the library, then the script calling the library overwrites the onStart from the library.
that works! for the record, the calling script does not have an onStart


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari