Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

MarioWasTaken
Shy Guy
Shy Guy
Posts: 7
Joined: Sat May 01, 2021 8:10 pm
Flair: a moron who likes Super Mario Bros 2
Pronouns: he
Contact:

Re: Need help with lua? - LunaLua General Help

Postby MarioWasTaken » Sat May 01, 2021 8:17 pm

I need help with costume.lua where the player grows from small to big with 3 frames, like in the original Super Mario Brothers
Image

Goldenemerl64
Fighter Fly
Fighter Fly
Posts: 38
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Sun May 09, 2021 3:57 pm

Idk if this belongs here, but...
Spoiler: show
Image
Is this supposed to be here in this version, Is currently in testing, is it safe to use, or no?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Mon May 10, 2021 1:34 pm

Goldenemerl64 wrote:
Sun May 09, 2021 3:57 pm
Idk if this belongs here, but...
Spoiler: show
Image
Is this supposed to be here in this version, Is currently in testing, is it safe to use, or no?
Good catch! It's indeed safe to use. It just slipped through the changelog revision. The changelog site will update to reflect its proper inclusion soon.

Goldenemerl64
Fighter Fly
Fighter Fly
Posts: 38
Joined: Tue Jul 07, 2020 3:50 pm

Re: Need help with lua? - LunaLua General Help

Postby Goldenemerl64 » Mon May 10, 2021 8:52 pm

Enjl wrote:
Mon May 10, 2021 1:34 pm
Goldenemerl64 wrote:
Sun May 09, 2021 3:57 pm
Idk if this belongs here, but...
Spoiler: show
Image
Is this supposed to be here in this version, Is currently in testing, is it safe to use, or no?
Good catch! It's indeed safe to use. It just slipped through the changelog revision. The changelog site will update to reflect its proper inclusion soon.
Ah, Ok, thanks!

LunarCatUSA
Monty Mole
Monty Mole
Posts: 115
Joined: Sat Mar 06, 2021 9:56 am
Flair: Soda-Butler

Re: Need help with lua? - LunaLua General Help

Postby LunarCatUSA » Sat May 22, 2021 2:29 pm

How do I transform an NPC into another?

Say I had that mobile tank wheels npc, ID:78 and I wanted to turn it into a block, ID:80. How would I go about doing this?

cato
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Thu Aug 24, 2017 3:06 am
Flair: Koishi enjoyer
Contact:

Re: Need help with lua? - LunaLua General Help

Postby cato » Sat Jun 05, 2021 11:47 am

How do I increment a value slowly with inputs?
Say like, you have to hold the "drop item" button and press the "up" button to increment a value. Laconically saying, one press equal to adding the value by one. However, it is too fast whenever I put it in the "onTick" function or the "onInputUpdate" function. Calling routine and putting routine.wait() before and after the increment doesn't make it slower. I tried using Lunatime. tick() as well but it doesn't increment the value.

Edit:
Spoiler: show
I gave up on this. Found an alternative way.
How do I respawn an enemy with delay after killed?
I was trying to use Routine after onNPCKill, then spawn the same enemy in the same position. The problem is that it spawns two of them stacked on each other instead of one.

Edit:
Spoiler: show
Find a solution that kills the NPC if a projectile is within the NPC in onTickNPC(), starts a routine, waits, and then respawns.

How do I set up multiple zones that do stuff every time the player goes in?
For instance, I have different liquid zones with the layer name "DisabledZone". The level then detects it and check whether the player collides inside with the zones and do stuff. However, the component "DisabledZone.collider = Colliders.Box(v.x,v.y,v.width,v.height)" after "for _, v in ipairs(Liquid.get())" doesn't work because it only defines 0/1 zones instead of multiple ones. The x-y position is only detected once and unchanged.

Edit:
Spoiler: show
I was doing it backwards. Instead of finding out whether the player is in the zone, I made it that whether the zone is within the player. I was looking at MrDoubleA's room Lua until I looked at Enjl's Spawnzone. Lua.
How do I set up a chain effect for BGOs?
I have an idea to detect whether the same BGOs within 1x3 horizontal and 1x3 vertical range by "For k, v in ipairs(BGO.getIntersecting(x1, y1, x2, y2))" and update the position of the new BGO over the previous one by (x1 = v.x, x2 = v.y) on loop until it can't find any of its same BGOs anymore. I thought it would work, but when I tried to implement it to a custom NPC so it activates when it dies next to the BGOs, SMBX can't even load or it would crash on the spot.

Edit:
Spoiler: show
I brute-forced the entire code and found out that you can't put a loop in the npc-n.Lua file. All I did is to activate the whole thing "onNPCKill" in the main program and check if the id matches. I also used a separate BGO (background-199) that if the program detects it it automatically breaks the loop, else it would crash without that specific BGO.
Edit: It took me less time for me to figure everything on my own than to wait for someone to help. God I love this thread.
Last edited by cato on Sat Jun 19, 2021 4:22 am, edited 3 times in total.

fawfulthegreat64
Goomba
Goomba
Posts: 2
Joined: Mon Jun 14, 2021 2:07 am
Pronouns: She/her

Re: Need help with lua? - LunaLua General Help

Postby fawfulthegreat64 » Mon Jun 14, 2021 7:27 am

What's the harm_type code for a shell? I want to make an enemy take 2 hits to kill, except by a shell which kills it instantly. I tried HARM_TYPE_SHELL but it did nothing.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Mon Jun 14, 2021 5:47 pm

fawfulthegreat64 wrote:
Mon Jun 14, 2021 7:27 am
What's the harm_type code for a shell? I want to make an enemy take 2 hits to kill, except by a shell which kills it instantly. I tried HARM_TYPE_SHELL but it did nothing.
It's HARM_TYPE_NPC, but you also need to filter for "if NPC.SHELL_MAP[v.id] then" if you wanna filter out shells.

KnownStranger
Blooper
Blooper
Posts: 155
Joined: Fri Jun 18, 2021 4:36 pm
Flair: Retired for my own good

Re: Need help with lua? - LunaLua General Help

Postby KnownStranger » Tue Jun 29, 2021 1:35 pm

What program I must use for make LUA codes?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Tue Jun 29, 2021 5:03 pm

Weirdgoomba4932 wrote:
Tue Jun 29, 2021 1:35 pm
What program I must use for make LUA codes?
any text editing software, but something that lets you highlight syntax like notepad++ or visual studio code is recommended.

KnownStranger
Blooper
Blooper
Posts: 155
Joined: Fri Jun 18, 2021 4:36 pm
Flair: Retired for my own good

Re: Need help with lua? - LunaLua General Help

Postby KnownStranger » Tue Jun 29, 2021 5:13 pm

Enjl wrote:
Weirdgoomba4932 wrote:
Tue Jun 29, 2021 1:35 pm
What program I must use for make LUA codes?
any text editing software, but something that lets you highlight syntax like notepad++ or visual studio code is recommended.
Can you give me a link for download the lua program for save something as a lua file? (Example: NpcCode.lua) Also notepad++ is good for windows 7?

ShadowXeldron
Snifit
Snifit
Posts: 232
Joined: Sun Dec 08, 2019 8:21 am
Flair: phpBB > ProBoards
Pronouns: He/Him
Contact:

Re: Need help with lua? - LunaLua General Help

Postby ShadowXeldron » Wed Jun 30, 2021 4:48 am

Weirdgoomba4932 wrote:
Tue Jun 29, 2021 5:13 pm
Enjl wrote:
Weirdgoomba4932 wrote:
Tue Jun 29, 2021 1:35 pm
What program I must use for make LUA codes?
any text editing software, but something that lets you highlight syntax like notepad++ or visual studio code is recommended.
Can you give me a link for download the lua program for save something as a lua file? (Example: NpcCode.lua) Also notepad++ is good for windows 7?
I personally use Visual Studio Code: https://code.visualstudio.com/. Note that for this program you need a plugin for Lua compatability
Also, here's Notepad++: https://notepad-plus-plus.org/
There's also ZeroBrane, which is explicitly designed for Lua but from my experience it is very complicated: https://studio.zerobrane.com/

On the topic of how well Notepad++ would run on Windows 7, it mainly boils down to your PC components. Although I'd say it would likely run much better than Visual Studio Code, I'd advise not using Windows 7 anymore because it stopped receiving security updates last year.

KnownStranger
Blooper
Blooper
Posts: 155
Joined: Fri Jun 18, 2021 4:36 pm
Flair: Retired for my own good

Re: Need help with lua? - LunaLua General Help

Postby KnownStranger » Wed Jun 30, 2021 12:39 pm

Dragon0307 wrote:
Wed Jun 30, 2021 4:48 am
Weirdgoomba4932 wrote:
Tue Jun 29, 2021 5:13 pm
Enjl wrote:

any text editing software, but something that lets you highlight syntax like notepad++ or visual studio code is recommended.
Can you give me a link for download the lua program for save something as a lua file? (Example: NpcCode.lua) Also notepad++ is good for windows 7?
I personally use Visual Studio Code: https://code.visualstudio.com/. Note that for this program you need a plugin for Lua compatability
Also, here's Notepad++: https://notepad-plus-plus.org/
There's also ZeroBrane, which is explicitly designed for Lua but from my experience it is very complicated: https://studio.zerobrane.com/

On the topic of how well Notepad++ would run on Windows 7, it mainly boils down to your PC components. Although I'd say it would likely run much better than Visual Studio Code, I'd advise not using Windows 7 anymore because it stopped receiving security updates last year.
I'll try download notepad++. Or else I will make vanilla levels. My family's economy isn't good, so it's impossible buy a new PC for this year.

ElTipsta
Lakitu
Lakitu
Posts: 485
Joined: Fri Dec 20, 2013 3:16 pm
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby ElTipsta » Mon Jul 05, 2021 8:53 pm

my question - i'm wanting to use multiple lunalua NPCs other have made in the same level, however many of them have the same filename (often npc-751 or upwards). However, if i change the filenames like with a non-lua NPC, it breaks and dosen't work in SMBX. how can i fix it to use multiple luna npcs in the same level?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Tue Jul 06, 2021 1:05 am

ElTipsta wrote:
Mon Jul 05, 2021 8:53 pm
my question - i'm wanting to use multiple lunalua NPCs other have made in the same level, however many of them have the same filename (often npc-751 or upwards). However, if i change the filenames like with a non-lua NPC, it breaks and dosen't work in SMBX. how can i fix it to use multiple luna npcs in the same level?
NPCs in the custom range SHOULD be modular and renamable following the instructions in this thread. It's difficult to give further advice without knowing what pack is being used and what the error looks like.

ElTipsta
Lakitu
Lakitu
Posts: 485
Joined: Fri Dec 20, 2013 3:16 pm
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby ElTipsta » Tue Jul 06, 2021 11:00 am

Enjl wrote:
Tue Jul 06, 2021 1:05 am
ElTipsta wrote:
Mon Jul 05, 2021 8:53 pm
my question - i'm wanting to use multiple lunalua NPCs other have made in the same level, however many of them have the same filename (often npc-751 or upwards). However, if i change the filenames like with a non-lua NPC, it breaks and dosen't work in SMBX. how can i fix it to use multiple luna npcs in the same level?
NPCs in the custom range SHOULD be modular and renamable following the instructions in this thread. It's difficult to give further advice without knowing what pack is being used and what the error looks like.
the error screen is this:

Image

I was trying to put in your SM3DW Ring Burner as well as MrDoubleA's Propeller and Bullet Helmets.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Tue Jul 06, 2021 11:28 am

ElTipsta wrote:
Tue Jul 06, 2021 11:00 am
Enjl wrote:
Tue Jul 06, 2021 1:05 am
ElTipsta wrote:
Mon Jul 05, 2021 8:53 pm
my question - i'm wanting to use multiple lunalua NPCs other have made in the same level, however many of them have the same filename (often npc-751 or upwards). However, if i change the filenames like with a non-lua NPC, it breaks and dosen't work in SMBX. how can i fix it to use multiple luna npcs in the same level?
NPCs in the custom range SHOULD be modular and renamable following the instructions in this thread. It's difficult to give further advice without knowing what pack is being used and what the error looks like.
the error screen is this:

Image

I was trying to put in your SM3DW Ring Burner as well as MrDoubleA's Propeller and Bullet Helmets.
The error says that the lua file "ringBurner" in the subfolder "ai" is missing. Did you make sure to copy all relevant files?

ElTipsta
Lakitu
Lakitu
Posts: 485
Joined: Fri Dec 20, 2013 3:16 pm
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby ElTipsta » Tue Jul 06, 2021 12:34 pm

Enjl wrote:
Tue Jul 06, 2021 11:28 am
ElTipsta wrote:
Tue Jul 06, 2021 11:00 am
Enjl wrote:
Tue Jul 06, 2021 1:05 am

NPCs in the custom range SHOULD be modular and renamable following the instructions in this thread. It's difficult to give further advice without knowing what pack is being used and what the error looks like.
the error screen is this:

Image

I was trying to put in your SM3DW Ring Burner as well as MrDoubleA's Propeller and Bullet Helmets.
The error says that the lua file "ringBurner" in the subfolder "ai" is missing. Did you make sure to copy all relevant files?
I did but thought the ringburner had to be in the same folder as the other graphics, not the AI folder.

I also hadn't done the ringBurner = require("ringBurner") required in the luna.lua file for it to work which i've now done and it works perfectly! Thanks :)

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Tue Jul 06, 2021 1:14 pm

Well, the ai file was in the ai subfolder because it's common convention to keep all the shared AIs in that folder, but I guess changing the folder structure and the necessary require calls works too...

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 » 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?


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari