Page 18 of 32

Re: Need help with lua? - LunaLua General Help

Posted: Sat May 01, 2021 8:17 pm
by MarioWasTaken
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

Re: Need help with lua? - LunaLua General Help

Posted: Sun May 09, 2021 3:57 pm
by Goldenemerl64
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?

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 10, 2021 1:34 pm
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon May 10, 2021 8:52 pm
by Goldenemerl64
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!

Re: Need help with lua? - LunaLua General Help

Posted: Sat May 22, 2021 2:29 pm
by LunarCatUSA
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?

Re: Need help with lua? - LunaLua General Help

Posted: Sat Jun 05, 2021 11:47 am
by cato
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jun 14, 2021 7:27 am
by fawfulthegreat64
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jun 14, 2021 5:47 pm
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jun 29, 2021 1:35 pm
by KnownStranger
What program I must use for make LUA codes?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jun 29, 2021 5:03 pm
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jun 29, 2021 5:13 pm
by KnownStranger
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?

Re: Need help with lua? - LunaLua General Help

Posted: Wed Jun 30, 2021 4:48 am
by ShadowXeldron
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.

Re: Need help with lua? - LunaLua General Help

Posted: Wed Jun 30, 2021 12:39 pm
by KnownStranger
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Jul 05, 2021 8:53 pm
by ElTipsta
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?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jul 06, 2021 1:05 am
by Emral
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.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jul 06, 2021 11:00 am
by ElTipsta
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.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jul 06, 2021 11:28 am
by Emral
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?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jul 06, 2021 12:34 pm
by ElTipsta
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 :)

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jul 06, 2021 1:14 pm
by Emral
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...

Re: Need help with lua? - LunaLua General Help

Posted: Tue Jul 06, 2021 1:57 pm
by th360
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?