Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
LunarCatUSA
Hoopster
Hoopster
Posts: 105
Joined: Sat Mar 06, 2021 9:56 am
Flair: Soda-Butler

Re: Need help with lua? - LunaLua General Help

Postby LunarCatUSA » Sun Nov 14, 2021 2:53 pm

So I have another question.

How would I go about making a custom animation for an enemy grabbing the player after charging into them? I guess the idea would be to (1) set the player state to invisible and making a custom graphic for the npc to transform into depicting them grabbing the player and then end the scene and set the player back to normal? Or maybe (2) make a custom graphic sheet depicting the player getting grabbed and find a way to make it look like the enemy is strangling them or something.

If you could provide any advice about how I would do this, I'd appreciate it!

LunarCatUSA
Hoopster
Hoopster
Posts: 105
Joined: Sat Mar 06, 2021 9:56 am
Flair: Soda-Butler

Re: Need help with lua? - LunaLua General Help

Postby LunarCatUSA » Tue Nov 16, 2021 4:02 pm

Anyone know how I'd add custom world music?

I'm doing the thing with music.ini and the visible file name (not in another folder) but when I play the song in the music box section in the world map editor, it's still the same vanilla song.

[world-music-1]
name="MY WORLD Overwold"
file="MySong.mp3"

What am I doing wrong?

Dragon0307
Snifit
Snifit
Posts: 211
Joined: Sun Dec 08, 2019 8:21 am
Flair: I predicted Minecraft Legends!
Pronouns: He/Him

Re: Need help with lua? - LunaLua General Help

Postby Dragon0307 » Wed Nov 17, 2021 3:28 pm

LunarCatUSA wrote:
Tue Nov 16, 2021 4:02 pm
Anyone know how I'd add custom world music?

I'm doing the thing with music.ini and the visible file name (not in another folder) but when I play the song in the music box section in the world map editor, it's still the same vanilla song.

[world-music-1]
name="MY WORLD Overwold"
file="MySong.mp3"

What am I doing wrong?
Have you tried it in the actual SMBX engine? It should work there.

LunarCatUSA
Hoopster
Hoopster
Posts: 105
Joined: Sat Mar 06, 2021 9:56 am
Flair: Soda-Butler

Re: Need help with lua? - LunaLua General Help

Postby LunarCatUSA » Wed Nov 17, 2021 4:04 pm

Dragon0307 wrote:
Wed Nov 17, 2021 3:28 pm
LunarCatUSA wrote:
Tue Nov 16, 2021 4:02 pm
Anyone know how I'd add custom world music?

I'm doing the thing with music.ini and the visible file name (not in another folder) but when I play the song in the music box section in the world map editor, it's still the same vanilla song.

[world-music-1]
name="MY WORLD Overwold"
file="MySong.mp3"

What am I doing wrong?
Have you tried it in the actual SMBX engine? It should work there.
You mean, switching the music out in the main music file that will change it for the other episodes? Or is there some other engine thing?

Added in 31 seconds:
Oh wait, you mean outside of the editor. I'll try that.

Added in 24 minutes 7 seconds:
Another thing,

Do instant warp exits not work with warping to a map location? Because when I reach an instant warp that would warp to a given location on the world map, nothing happens.

Dragon0307
Snifit
Snifit
Posts: 211
Joined: Sun Dec 08, 2019 8:21 am
Flair: I predicted Minecraft Legends!
Pronouns: He/Him

Re: Need help with lua? - LunaLua General Help

Postby Dragon0307 » Thu Nov 18, 2021 7:02 am

LunarCatUSA wrote:
Wed Nov 17, 2021 4:29 pm
Do instant warp exits not work with warping to a map location? Because when I reach an instant warp that would warp to a given location on the world map, nothing happens.

Looks like they don't. Try it with a portal warp. Alternatively, just stick in a door or a pipe or something.

FirestarPlays
Spike
Spike
Posts: 281
Joined: Tue Feb 28, 2017 1:26 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby FirestarPlays » Wed Nov 24, 2021 8:14 am

How do I get npc-310 working? This is probably a dumb question but I dont know this. And yes before you ask, I've looked in the handbook and there is nothing :P

deice
Buster Beetle
Buster Beetle
Posts: 441
Joined: Fri Jul 23, 2021 7:35 am

Re: Need help with lua? - LunaLua General Help

Postby deice » Wed Nov 24, 2021 9:04 am

FirestarPlays wrote:
Wed Nov 24, 2021 8:14 am
How do I get npc-310 working? This is probably a dumb question but I dont know this. And yes before you ask, I've looked in the handbook and there is nothing :P
this isn't really a lua question, star coins are vanilla in SMBX2. just set it's index in the "item properties" tab on the right (starting from 1 and incrementing by 1 with each additional coin). while there's nothing in the handbook, this is very clearly explained by the tooltip that pops up when you hover over it in the editor.

FirestarPlays
Spike
Spike
Posts: 281
Joined: Tue Feb 28, 2017 1:26 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby FirestarPlays » Wed Nov 24, 2021 9:15 am

I have tried that but it doesn't seem to work for me. Whenever I reload the level, load up another level or test the game the index gets set to 0...I'm not sure what I'm supposed to do. Am I supposed to choose the index while PLACING the coin because mine are all stuck at 0?

deice
Buster Beetle
Buster Beetle
Posts: 441
Joined: Fri Jul 23, 2021 7:35 am

Re: Need help with lua? - LunaLua General Help

Postby deice » Wed Nov 24, 2021 9:24 am

FirestarPlays wrote:
Wed Nov 24, 2021 9:15 am
I have tried that but it doesn't seem to work for me. Whenever I reload the level, load up another level or test the game the index gets set to 0...I'm not sure what I'm supposed to do. Am I supposed to choose the index while PLACING the coin because mine are all stuck at 0?
ideally you would, but right clicking it and setting the index from there works for me too.

FirestarPlays
Spike
Spike
Posts: 281
Joined: Tue Feb 28, 2017 1:26 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby FirestarPlays » Wed Nov 24, 2021 9:26 am

Surprising. That's what I've been trying and it doesn't work for me unfortunately...I think I've found a bug.

MarioLover64
Spike
Spike
Posts: 257
Joined: Fri Apr 26, 2019 6:09 pm

Re: Need help with lua? - LunaLua General Help

Postby MarioLover64 » Thu Nov 25, 2021 12:24 pm

Is the level using the .lvl or the .lvlx format

Twisted4932
Monty Mole
Monty Mole
Posts: 143
Joined: Fri Jun 18, 2021 4:36 pm
Flair: Inactive for now.
Pronouns: He/him

Re: Need help with lua? - LunaLua General Help

Postby Twisted4932 » Tue Nov 30, 2021 6:18 pm

How I can change the health of an npc and make them resist more hits?

Dragon0307
Snifit
Snifit
Posts: 211
Joined: Sun Dec 08, 2019 8:21 am
Flair: I predicted Minecraft Legends!
Pronouns: He/Him

Re: Need help with lua? - LunaLua General Help

Postby Dragon0307 » Wed Dec 01, 2021 2:31 pm

Weirdgoomba4932 wrote:
Tue Nov 30, 2021 6:18 pm
How I can change the health of an npc and make them resist more hits?
There's two ways:

1. Alter their health using an NPC text file, which you can create using PGE. This only works for NPCs that already take multiple hits.

2. Use LightHitPoint.lua. It requires that you register the NPCs that you want to take extra hits in your luna.lua, and any NPCs who already take multiple hits will only take those hits once the health bar is empty.

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9491
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Wed Dec 01, 2021 2:45 pm

There's a third way - write your own.

Code: Select all

function onNPCHarm(eventObj, harmedNPC, harmReason)
	if harmReason == HARM_TYPE_JUMP and harmedNPC.id == 1 then
		if harmedNPC.data.hp == nil then
			harmedNPC.data.hp = 3
		end
		harmedNPC.data.hp = harmedNPC.data.hp - 1
		if harmedNPC.data.hp > 0 then
			eventObj.cancelled = true
		end
	end
end
This, for instance, cancels any jump damage dealt to a goomba for 2 hits, granting it 3 hp.
It's basically what LightHitPoint already does, but I figured I'd write up this sample in case you wanted a bit more insight.

Twisted4932
Monty Mole
Monty Mole
Posts: 143
Joined: Fri Jun 18, 2021 4:36 pm
Flair: Inactive for now.
Pronouns: He/him

Re: Need help with lua? - LunaLua General Help

Postby Twisted4932 » Thu Dec 02, 2021 11:30 am

Nice codes for customize npcs health :)

Goldenemerl64
Rex
Rex
Posts: 37
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Wed Dec 29, 2021 5:38 pm

how do I shrink the clown car's size when I enter it?
(or specifically how to change the clown car's hitbox)

viewtopic.php?f=101&t=27680 (the topic of the same thing.)
Last edited by Goldenemerl64 on Mon Jan 10, 2022 10:18 pm, edited 1 time in total.

SuperAlex
Blooper
Blooper
Posts: 190
Joined: Mon Nov 02, 2020 3:02 pm
Contact:

Re: Need help with lua? - LunaLua General Help

Postby SuperAlex » Fri Jan 07, 2022 8:47 pm

Hello! Uuuuuufff Is posible to obtain in a Lua code an instance method when the player is inside on the Clearpipe?

Goldenemerl64
Rex
Rex
Posts: 37
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Thu Jan 13, 2022 5:02 pm

Hello, How do you activate an event in Lua?

As in:

Code: Select all

if number == 1 then
--???
What code runs an event in the classic events.

I'm sorry if I'm not making any sense...

SuperAlex
Blooper
Blooper
Posts: 190
Joined: Mon Nov 02, 2020 3:02 pm
Contact:

Re: Need help with lua? - LunaLua General Help

Postby SuperAlex » Thu Jan 13, 2022 5:17 pm

Goldenemerl64 wrote:
Thu Jan 13, 2022 5:02 pm
Hello, How do you activate an event in Lua?

As in:

Code: Select all

if number == 1 then
--???

What code runs an event in the classic events.

I'm sorry if I'm not making any sense...
Whaaaaaaæ
You need to put

Code: Select all

función onEvent(number)
In your Lua dile ok

Added in 45 seconds:
SuperAlex wrote:
Thu Jan 13, 2022 5:17 pm
Goldenemerl64 wrote:
Thu Jan 13, 2022 5:02 pm
Hello, How do you activate an event in Lua?

As in:

Code: Select all

if number == 1 then
--???

What code runs an event in the classic events.

I'm sorry if I'm not making any sense...
Whaaaaaaæ
You need to put

Code: Select all

function onEvent(number)
If number == 1 then
Do things here
In your Lua dile ok

Goldenemerl64
Rex
Rex
Posts: 37
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Fri Jan 14, 2022 6:53 am

SuperAlex wrote:
Thu Jan 13, 2022 5:17 pm
Goldenemerl64 wrote:
Thu Jan 13, 2022 5:02 pm
Hello, How do you activate an event in Lua?

As in:

Code: Select all

if number == 1 then
--???

What code runs an event in the classic events.

I'm sorry if I'm not making any sense...
Whaaaaaaæ
You need to put

Code: Select all

función onEvent(number)
In your Lua dile ok

Added in 45 seconds:
SuperAlex wrote:
Thu Jan 13, 2022 5:17 pm
Goldenemerl64 wrote:
Thu Jan 13, 2022 5:02 pm
Hello, How do you activate an event in Lua?

As in:

Code: Select all

if number == 1 then
--???

What code runs an event in the classic events.

I'm sorry if I'm not making any sense...
Whaaaaaaæ
You need to put

Code: Select all

function onEvent(number)
If number == 1 then
Do things here
In your Lua dile ok
Got it, Thank you so much! :)


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests