Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
User avatar
LunarCatUSA
Bit
Bit
Posts: 66
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!

User avatar
LunarCatUSA
Bit
Bit
Posts: 66
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?

User avatar
Dragon0307
Monty Mole
Monty Mole
Posts: 127
Joined: Sun Dec 08, 2019 8:21 am
Flair: Faux Affably Evil
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.
If you are still running Windows 7, your security is at stake. And no, Antivirus is not enough. Switch to Linux!™

This ForumPost® is the intellectual property (IP) of Kamekverse LTD. All rights reserved.
UNAUTHORIZED USAGE IS VIABLE FOR CRIMINAL CHARGES ON THE GROUNDS OF COPYRIGHT INFRINGEMENT
ForumPost® is a registered patent of Kamekverse LTD.
Spoiler: show
THIS SPACE IS FOR RENT

User avatar
LunarCatUSA
Bit
Bit
Posts: 66
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.

User avatar
Dragon0307
Monty Mole
Monty Mole
Posts: 127
Joined: Sun Dec 08, 2019 8:21 am
Flair: Faux Affably Evil
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.
If you are still running Windows 7, your security is at stake. And no, Antivirus is not enough. Switch to Linux!™

This ForumPost® is the intellectual property (IP) of Kamekverse LTD. All rights reserved.
UNAUTHORIZED USAGE IS VIABLE FOR CRIMINAL CHARGES ON THE GROUNDS OF COPYRIGHT INFRINGEMENT
ForumPost® is a registered patent of Kamekverse LTD.
Spoiler: show
THIS SPACE IS FOR RENT

User avatar
FirestarPlays
Spike
Spike
Posts: 280
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
Image

User avatar
deice
Bit
Bit
Posts: 68
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.

User avatar
FirestarPlays
Spike
Spike
Posts: 280
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?
Image

User avatar
deice
Bit
Bit
Posts: 68
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.

User avatar
FirestarPlays
Spike
Spike
Posts: 280
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.
Image

User avatar
MarioLover64
Spike
Spike
Posts: 252
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

User avatar
Weirdgoomba4932
Bit
Bit
Posts: 61
Joined: Fri Jun 18, 2021 4:36 pm
Pronouns: He/him

Re: Need help with lua? - LunaLua General Help

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

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

User avatar
Dragon0307
Monty Mole
Monty Mole
Posts: 127
Joined: Sun Dec 08, 2019 8:21 am
Flair: Faux Affably Evil
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.
If you are still running Windows 7, your security is at stake. And no, Antivirus is not enough. Switch to Linux!™

This ForumPost® is the intellectual property (IP) of Kamekverse LTD. All rights reserved.
UNAUTHORIZED USAGE IS VIABLE FOR CRIMINAL CHARGES ON THE GROUNDS OF COPYRIGHT INFRINGEMENT
ForumPost® is a registered patent of Kamekverse LTD.
Spoiler: show
THIS SPACE IS FOR RENT

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9273
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.
All my assets from packs and episodes are free to use for non-Stargate levels and projects, as long as proper credit is given.

User avatar
Weirdgoomba4932
Bit
Bit
Posts: 61
Joined: Fri Jun 18, 2021 4:36 pm
Pronouns: He/him

Re: Need help with lua? - LunaLua General Help

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

Nice codes for customize npcs health :)
Image


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest