Page 21 of 27

Re: Need help with lua? - LunaLua General Help

Posted: Sun Nov 14, 2021 2:53 pm
by LunarCatUSA
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!

Re: Need help with lua? - LunaLua General Help

Posted: Tue Nov 16, 2021 4:02 pm
by LunarCatUSA
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?

Re: Need help with lua? - LunaLua General Help

Posted: Wed Nov 17, 2021 3:28 pm
by Dragon0307
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Nov 17, 2021 4:04 pm
by LunarCatUSA
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Nov 18, 2021 7:02 am
by Dragon0307
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Nov 24, 2021 8:14 am
by FirestarPlays
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

Re: Need help with lua? - LunaLua General Help

Posted: Wed Nov 24, 2021 9:04 am
by deice
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Nov 24, 2021 9:15 am
by FirestarPlays
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?

Re: Need help with lua? - LunaLua General Help

Posted: Wed Nov 24, 2021 9:24 am
by deice
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Nov 24, 2021 9:26 am
by FirestarPlays
Surprising. That's what I've been trying and it doesn't work for me unfortunately...I think I've found a bug.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Nov 25, 2021 12:24 pm
by MarioLover64
Is the level using the .lvl or the .lvlx format

Re: Need help with lua? - LunaLua General Help

Posted: Tue Nov 30, 2021 6:18 pm
by Twisted4932
How I can change the health of an npc and make them resist more hits?

Re: Need help with lua? - LunaLua General Help

Posted: Wed Dec 01, 2021 2:31 pm
by Dragon0307
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Dec 01, 2021 2:45 pm
by Enjl
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Dec 02, 2021 11:30 am
by Twisted4932
Nice codes for customize npcs health :)

Re: Need help with lua? - LunaLua General Help

Posted: Wed Dec 29, 2021 5:38 pm
by Goldenemerl64
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.)

Re: Need help with lua? - LunaLua General Help

Posted: Fri Jan 07, 2022 8:47 pm
by SuperAlex
Hello! Uuuuuufff Is posible to obtain in a Lua code an instance method when the player is inside on the Clearpipe?

Re: Need help with lua? - LunaLua General Help

Posted: Thu Jan 13, 2022 5:02 pm
by Goldenemerl64
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...

Re: Need help with lua? - LunaLua General Help

Posted: Thu Jan 13, 2022 5:17 pm
by SuperAlex
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

Re: Need help with lua? - LunaLua General Help

Posted: Fri Jan 14, 2022 6:53 am
by Goldenemerl64
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! :)