Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
User avatar
Julia Pseudo
Ludwig
Ludwig
Posts: 5584
Joined: Wed Jan 08, 2014 12:04 am
Flair: gay gaymer girl
Pronouns: She/her

Re: Need help with lua? - LunaLua General Help

Postby Julia Pseudo » Tue Jul 06, 2021 2:21 pm

th360 wrote:
Tue Jul 06, 2021 1:57 pm
Hello! I'm trying to make a goombrat and a para-goombrat (like, npcs 1 and 244 but cliffturn), and i don't want to overwrite another sprite. Where are the .lua files for the npcs 1 and 244? Or it is completely hardcoded?
NPCs that existed in SMBX 1.3 don't have Lua files, as SMBX wasn't built in Lua when the original creator Redigit was working on it.

I am not experienced with LunaLua, so there may be a better way to do this, but the solution to this I know about means you have to overwrite other enemies. I would recommend simply replacing the Super Mario Land 2 goombas (npc-242 and npc-243, also SMBX 1.3 NPCs) with your goombrats and applying cliffturn=1 to them. Assuming this is an episode-wide thing you're implementing, you can simply overwrite npc-1 and npc-244 with the Mario Land 2 goombas on a per-level basis if you need them again for some reason.
My SMBX project: The Great Goo Blaster Demo
My youtube channel

"sterydy Behemoth expiable novae iconically night owl ticklish turbocharger bactrian riveting . Solidus quits frothy managua scrimper shadowy enthusiastically rearrangement curviness matronliness pinyin piroshki gradual hysterically locker room versed . Horrendous unicorn transnational parka lasso very forbiddingly laborsaving cochabamba hair-raising floozy philter transnational ."
- a spam account, 2016


User avatar
MrDoubleA
Posts: 301
Joined: Mon Aug 20, 2018 7:02 am
Pronouns: he/him
Contact:

Re: Need help with lua? - LunaLua General Help

Postby MrDoubleA » Tue Jul 06, 2021 9:43 pm

th360 wrote:
Tue Jul 06, 2021 1:57 pm
Hello! I'm trying to make a goombrat and a para-goombrat (like, npcs 1 and 244 but cliffturn), and i don't want to overwrite another sprite. Where are the .lua files for the npcs 1 and 244? Or it is completely hardcoded?
It's hardcoded. NPC's of IDs 292 and below are from 1.3 and as such aren't made with lua. You can find their behaviour in the source code's modNPC.bas, but honestly it may likely be easier to just do it from scratch.
Hi. I make some stuff.
(MrDoubleA#3124 on Discord)

MrDoubleA's NPC Pack
rooms.lua - Quick respawn & Celeste-styled rooms
Extended Koopas

Image

More stuff: show
Shiny Medals ooo:

Image
Image
Image
Image
Image

I support:
Image
Image

th360
Shy Guy
Shy Guy
Posts: 5
Joined: Tue Jul 06, 2021 1:41 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby th360 » Fri Jul 09, 2021 11:19 am

Hello again. I already did my sprite of the goombrat, but i'm having some problems on the para-goombrat. How to transform the para-goombrat npc into the goombrat npc when it's stomped?

User avatar
SuperAlex
Bit
Bit
Posts: 78
Joined: Mon Nov 02, 2020 3:02 pm
Contact:

Re: NPC Extra settings General Help.

Postby SuperAlex » Wed Jul 21, 2021 7:22 pm

Hello please, I need a percent of helpful tools.
I have a simple problem while I created a custom clouddrop with Extra Settings like the travelling distance "ranger" but appears a red screen while took the npc. I put the data right.
In lunalua (clouddrop2.0) and npc.json, they can verify it and I do not know if it is wrong or at least I need it at one level to put any credit.

Image
I believe and I accept Jesus Christ as my Lord and Savior. If you do, put this in your signature.
Image
Image
Image
Image

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Wed Jul 21, 2021 8:40 pm

A red block means a parsing error in the .json file. In this case, you have a trailing comma on the line that reads "value-max": 50,

th360
Shy Guy
Shy Guy
Posts: 5
Joined: Tue Jul 06, 2021 1:41 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby th360 » Thu Jul 22, 2021 8:58 am

Hello. How to make a npc transform into another?

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Thu Jul 22, 2021 11:45 am

th360 wrote:
Thu Jul 22, 2021 8:58 am
Hello. How to make a npc transform into another?
If you have a reference to the NPC you want to transform, you use the npc:transform method on it:
https://docs.codehaus.moe/#/reference/n ... ce-methods
All my assets from packs and episodes are free to use for non-Stargate levels and projects, as long as proper credit is given.

wyldstrykr
Koopa
Koopa
Posts: 18
Joined: Mon May 31, 2021 11:20 pm

Re: Need help with lua? - LunaLua General Help

Postby wyldstrykr » Fri Jul 23, 2021 3:02 am

how to make a red rectangle of varying sizes?? like 1 blocks by 10 blocks and 2 blocks by 5 blocks?? do i need 2 images for that?

User avatar
cato
Lakitu
Lakitu
Posts: 466
Joined: Thu Aug 24, 2017 3:06 am
Flair: Creative, opinionated, but poor expression
Contact:

Re: Need help with lua? - LunaLua General Help

Postby cato » Fri Jul 23, 2021 4:43 am

Correct me if I am wrong.

But

Code: Select all

local Room = Section(0)

function onStart()
Room.effects.screenEffects = SEFFECT_WAVY
Room.effects.weather = WEATHER_RAIN
end
only changes the weather in the section. The value of weather is an integer while the value of the screenEffects is nil. Either the SMBX2 documentation is inaccurate or changing the screenEffects are more complex than just 1 line of code.
Freedom, Human Rights, Fairness, Democracy, Rule of Law, Righteousness, Courageness, Human Nature, Conscience, Goodwill, Ethics, Beliefs, Hope.

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Jul 23, 2021 1:03 pm

cato wrote:
Fri Jul 23, 2021 4:43 am
The value of weather is an integer while the value of the screenEffects is nil.
That's because the variable is "screenEffect" not "screenEffects".

User avatar
cato
Lakitu
Lakitu
Posts: 466
Joined: Thu Aug 24, 2017 3:06 am
Flair: Creative, opinionated, but poor expression
Contact:

Re: Need help with lua? - LunaLua General Help

Postby cato » Fri Jul 23, 2021 1:08 pm

Hoeloe wrote:
Fri Jul 23, 2021 1:03 pm
cato wrote:
Fri Jul 23, 2021 4:43 am
The value of weather is an integer while the value of the screenEffects is nil.
That's because the variable is "screenEffect" not "screenEffects".
I guess the variable on the SMBX2 doc is wrong then.
Freedom, Human Rights, Fairness, Democracy, Rule of Law, Righteousness, Courageness, Human Nature, Conscience, Goodwill, Ethics, Beliefs, Hope.

User avatar
TheGameyFireBro105
Rocky Wrench
Rocky Wrench
Posts: 636
Joined: Thu Jan 09, 2020 6:09 pm
Flair: Good at remakes

Re: Need help with lua? - LunaLua General Help

Postby TheGameyFireBro105 » Fri Jul 23, 2021 9:35 pm

I'm trying to make this but in SMBX2
Image
What makes a Chuck type enemy play this animation, then become a Chargin' Chuck

Image

I'm specifically looking to apply that property to a SMB3 Hammer Bro.
I love these episodes and packs; Go and support:
Image
Image
Image
Image
Image
Image

User avatar
Weirdgoomba4932
Swooper
Swooper
Posts: 54
Joined: Fri Jun 18, 2021 4:36 pm
Flair: Makes graphics for fun
Pronouns: He/him

Re: Need help with lua? - LunaLua General Help

Postby Weirdgoomba4932 » Thu Jul 29, 2021 1:33 pm

What properties must have a custom npc.lua file? I want to know how to make things like put an effect for dead npcs and make collision and movement.
Image

th360
Shy Guy
Shy Guy
Posts: 5
Joined: Tue Jul 06, 2021 1:41 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby th360 » Thu Jul 29, 2021 3:18 pm

How to transform a npc into the another when it's hurted by a specific hurt type?

User avatar
Wiimeiser
Snifit
Snifit
Posts: 204
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: Need help with lua? - LunaLua General Help

Postby Wiimeiser » Thu Aug 05, 2021 5:35 am

So these three packs are giving me a hard time with removing PNPC:
viewtopic.php?f=101&t=24387
viewtopic.php?f=101&t=24083
viewtopic.php?f=101&t=24835
I have no idea what I'm doing, and I doubt the original authors are ever going to update them... I guess I'll just have to live with error popups interrupting my testing...

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Thu Aug 05, 2021 12:04 pm

Wiimeiser wrote:
Thu Aug 05, 2021 5:35 am
So these three packs are giving me a hard time with removing PNPC:
Generally, any time you see "pnpc.wrap(something)" just replace it with "something", for a quick and dirty fix.

For example:

local v = pnpc.wrap(w).speedX

would be replaced with:

local v = w.speedX

User avatar
Wiimeiser
Snifit
Snifit
Posts: 204
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: Need help with lua? - LunaLua General Help

Postby Wiimeiser » Thu Aug 05, 2021 7:35 pm

Yes, that worked. Thanks!

Now I just need to fix an issue where the SMW Bullet Bill Blaster fires bullets extremely rapidly (it creates a literal wall of whatever it fires)
viewtopic.php?f=101&t=24125
and I'm also having issues with the Celeste Boost Bubble being an invalid image type.
viewtopic.php?f=101&t=26570
Or I could just add water...

EDIT: I fixed the issue with the Bill Blaster by changing

Code: Select all

	if data.waiter == configuration.timer then

to

Code: Select all

	if data.waiter == 150 then
so it seems the "Timer" command in local npcSettings doesn't actually do anything.

EDIT4: MegaDood seems to have fixed the carrot.

But I'm stuck trying to figure out why this code is returning an invalid image:

Code: Select all

	Graphics.drawImageToSceneWP(
		bubbleImage,
		v.x + 0.5 * v.width - 24,
		v.y + 0.5 * v.height - 24,
		48 * (4 - v.ai5),
		48 * v.animationFrame,
		48,
		48,
		-25
	)

User avatar
Hoeloe
Foo
Foo
Posts: 1403
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Sat Aug 07, 2021 8:16 am

Wiimeiser wrote:
Thu Aug 05, 2021 7:35 pm
so it seems the "Timer" command in local npcSettings doesn't actually do anything.
That suggests either the NPC was set up wrong, or your npc.txt was set up wrong.


As for the invalid image, that just means that "bubbleImage" has tried to load a file that doesn't exist.

th360
Shy Guy
Shy Guy
Posts: 5
Joined: Tue Jul 06, 2021 1:41 pm
Pronouns: he/him

Re: Need help with lua? - LunaLua General Help

Postby th360 » Sun Aug 08, 2021 2:40 pm

How could i make a npc transform into another when it's hurt by a specific hurt type??

User avatar
Wiimeiser
Snifit
Snifit
Posts: 204
Joined: Mon Jun 24, 2019 4:36 am
Flair: What?

Re: Need help with lua? - LunaLua General Help

Postby Wiimeiser » Wed Aug 11, 2021 9:00 am

I'm trying to resolve an issue with the rocket from this pack. The problem is that when I enter the rocket, it turns into a white square. If I comment out this line:

Code: Select all

sceneCoords = true
or change it to "false" the rocket instead turns invisible when activated.

"sceneCoords" isn't listed anywhere in the handbook, so I assume the function is deprecated?

Why is the lua breaking for me and only for me? Did I corrupt my game files somehow?

EDIT: Since no amount of editing the draw routine seems to make the "object" draw I've decided to just outright delete the NPC from my game. A shame since it's a cool one, but unfixable issues require full deletion. I'm leaving the graphics as a BGO, though that's about it.

EDIT2: In the event I re-add it, I'll be fixing it up to not show anything while moving a visible player around, and changing the graphics to a can of beans.

Which I have now done.

EDIT3: I think the problem is that my game/editor is corrupt, I have issues with grid snapping/anchoring and the * next to the filename, as well as with saving bookmarks on the world map. Those features just aren't working, suggesting the problem might be a corrupt installation for all I know. The filename "World.bY8hqLY5OLEq.wld.meta" seems abnormal to me...


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests