Page 19 of 32
Re: Need help with lua? - LunaLua General Help
Posted: Tue Jul 06, 2021 2:21 pm
by Julia Pseudo
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.
Re: Need help with lua? - LunaLua General Help
Posted: Tue Jul 06, 2021 9:43 pm
by MrDoubleA
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.
Re: Need help with lua? - LunaLua General Help
Posted: Fri Jul 09, 2021 11:19 am
by th360
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?
Re: NPC Extra settings General Help.
Posted: Wed Jul 21, 2021 7:22 pm
by SuperAlex
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.

Re: Need help with lua? - LunaLua General Help
Posted: Wed Jul 21, 2021 8:40 pm
by Hoeloe
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,
Re: Need help with lua? - LunaLua General Help
Posted: Thu Jul 22, 2021 8:58 am
by th360
Hello. How to make a npc transform into another?
Re: Need help with lua? - LunaLua General Help
Posted: Thu Jul 22, 2021 11:45 am
by Emral
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
Re: Need help with lua? - LunaLua General Help
Posted: Fri Jul 23, 2021 3:02 am
by wyldstrykr
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?
Re: Need help with lua? - LunaLua General Help
Posted: Fri Jul 23, 2021 4:43 am
by cato
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.
Re: Need help with lua? - LunaLua General Help
Posted: Fri Jul 23, 2021 1:03 pm
by Hoeloe
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".
Re: Need help with lua? - LunaLua General Help
Posted: Fri Jul 23, 2021 1:08 pm
by cato
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.
Re: Need help with lua? - LunaLua General Help
Posted: Fri Jul 23, 2021 9:35 pm
by TheGameyFireBro105
I'm trying to make this but in SMBX2

What makes a Chuck type enemy play this animation, then become a Chargin' Chuck
I'm specifically looking to apply that property to a SMB3 Hammer Bro.
Re: Need help with lua? - LunaLua General Help
Posted: Thu Jul 29, 2021 1:33 pm
by KnownStranger
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.
Re: Need help with lua? - LunaLua General Help
Posted: Thu Jul 29, 2021 3:18 pm
by th360
How to transform a npc into the another when it's hurted by a specific hurt type?
Re: Need help with lua? - LunaLua General Help
Posted: Thu Aug 05, 2021 5:35 am
by Wiimeiser
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...
Re: Need help with lua? - LunaLua General Help
Posted: Thu Aug 05, 2021 12:04 pm
by Hoeloe
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
Re: Need help with lua? - LunaLua General Help
Posted: Thu Aug 05, 2021 7:35 pm
by Wiimeiser
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
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
)
Re: Need help with lua? - LunaLua General Help
Posted: Sat Aug 07, 2021 8:16 am
by Hoeloe
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.
Re: Need help with lua? - LunaLua General Help
Posted: Sun Aug 08, 2021 2:40 pm
by th360
How could i make a npc transform into another when it's hurt by a specific hurt type??
Re: Need help with lua? - LunaLua General Help
Posted: Wed Aug 11, 2021 9:00 am
by Wiimeiser
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:
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...