Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
User avatar
SPEEDIE
Bit
Bit
Posts: 149
Joined: Sat Nov 03, 2018 6:22 pm
Flair: Avatar is what life should be like.
Current Project: A SMBX Episode
Chat Username: SPEEDIE
Contact:

Re: Need help with lua? - LunaLua General Help

Postby SPEEDIE » Sat Nov 23, 2019 11:56 am

I want to make a death counter on the top left part of the screen, it starts at 0, and when you die, it adds up, I want it to show in on every level (the total deaths on the entire episode)
I tried some stuff I found on pgewiki but it didn't work.
If something sounds too good to be true, it probably is.
Image

Finished Projects:

Image

Ongoing Projects:

None, however I am updating A SMBX Episode sometimes.

User avatar
Bulby_VR
Bob-omb
Bob-omb
Posts: 33
Joined: Wed Aug 07, 2019 11:18 am
Current Project: Bulby's Movement Pack
Chat Username: Bulby

Re: Need help with lua? - LunaLua General Help

Postby Bulby_VR » Sat Nov 23, 2019 1:02 pm

Would changing defines on the fly negatively affect performance, or is that impossible?

Added in 1 minute 52 seconds:
Nevermind, there's no point if your thing is compatible with 2 player
an ace at making garbo code
When I use mediafire, I use adblock, and you should too when using my links.

User avatar
Bulby_VR
Bob-omb
Bob-omb
Posts: 33
Joined: Wed Aug 07, 2019 11:18 am
Current Project: Bulby's Movement Pack
Chat Username: Bulby

Re: Need help with lua? - LunaLua General Help

Postby Bulby_VR » Tue Nov 26, 2019 8:22 am

What are the default defines for new characters? I see bowser’s jump height is much lower, but what else changes?
an ace at making garbo code
When I use mediafire, I use adblock, and you should too when using my links.

MarioLover64
Hoopster
Hoopster
Posts: 169
Joined: Fri Apr 26, 2019 6:09 pm

Re: Need help with lua? - LunaLua General Help

Postby MarioLover64 » Sat Dec 14, 2019 5:43 pm

How do I make a fade out effect?

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Sun Dec 15, 2019 1:49 am

Bulby_VR wrote:
Tue Nov 26, 2019 8:22 am
What are the default defines for new characters? I see bowser’s jump height is much lower, but what else changes?
I don't know them off the top of my head, but each character script has an initialisation function that runs when the player turns into that character. In that function, all character-specific global fields are set.
MarioLover64 wrote:
Sat Dec 14, 2019 5:43 pm
How do I make a fade out effect?
Put this in onDraw and manually control OPACITY (from 0 to 1). Priority 5 is hud priority. https://wohlsoft.ru/pgewiki/LunaLua_Render_Priority

Graphics.drawScreen{color = Color.black .. OPACITY, priority = 5}
The ABC of Creation
________________________________________________________
Image

User avatar
Locus
Cheep-Cheep
Cheep-Cheep
Posts: 16
Joined: Sun Mar 17, 2019 12:47 pm
Current Project: Overcoming existential dread

Re: Need help with lua? - LunaLua General Help

Postby Locus » Sun Dec 15, 2019 5:56 am

https://imgur.com/a/AuE1nko

I seem to have a problem with my parallaxing background. The water is moving but when I move left it somehow stops until I stand still again. If anyone could help me solve this issue this would be appreciated.

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Sun Dec 15, 2019 5:58 am

Looks like an optical illusion. The water still moves at the same speed, you're just "moving it back" by moving the camera at a rate at which the parallaxing effect cancels out the movement of the water. Double the water speed to see the impact of the effect more clearly.
The ABC of Creation
________________________________________________________
Image

User avatar
Locus
Cheep-Cheep
Cheep-Cheep
Posts: 16
Joined: Sun Mar 17, 2019 12:47 pm
Current Project: Overcoming existential dread

Re: Need help with lua? - LunaLua General Help

Postby Locus » Sun Dec 15, 2019 6:08 am

https://i.imgur.com/4bVnlKE.mp4

This time I doubled the speed and this is the result. It's like you said, making it more obvious to notice that it "stops".

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Sun Dec 15, 2019 6:14 am

Yes, the optical illusion is more obvious here. You can greatly increase the layer's depth to reduce the impact camera movement has on the layer.
The ABC of Creation
________________________________________________________
Image

User avatar
cato
Ripper II
Ripper II
Posts: 386
Joined: Thu Aug 24, 2017 3:06 am
Flair: Creative, opinionated, but poor expression
Current Project: https://docs.google.com/spreadsheets/d/ ... sp=sharing
Chat Username: Cato
Contact:

Re: Need help with lua? - LunaLua General Help

Postby cato » Thu Dec 26, 2019 10:09 am

How do I print text function like the SMBX textbox, while appearing characters frame by frame?

Edit: I think I have a bigger problem.
How do I make something like:
if you play the level for the first time, it gives you text A on level start
then if you play the level after getting something, it gives you text B on level start
then if you replay the level for neither the first time nor the second time, nothing happens.

I tried:

Code: Select all

firstime = true
secondtime = false // will turn into true later
function onStart()
    if firstime == false and secondtime == false then return end
    if firstime == true then
        Text.showMessageBox("A")   
    firstime = false
    end
    if secondtime == true then 
        Text.showMessageBox("B")
        secondtime = false
    end
end   
but still can't grasp the logical error that I have since firstime is always true every time the code is executed, yet I needed something to show that it is the player's first time in the level.

User avatar
RudeGuy
Luigi
Luigi
Posts: 4987
Joined: Fri Dec 27, 2013 7:36 am
Flair: help
Current Project: a random smw hack
Chat Username: rudeguy

Re: Need help with lua? - LunaLua General Help

Postby RudeGuy » Fri Dec 27, 2019 8:11 am

You need to use the SaveData library to save variables between different runs of a level.
im bored

User avatar
Murphmario
Larry Koopa
Larry Koopa
Posts: 2163
Joined: Fri Dec 20, 2013 7:07 pm
Current Project: Project planned; waiting for SMBX2 Beta 4

Re: Need help with lua? - LunaLua General Help

Postby Murphmario » Sat Dec 28, 2019 4:56 pm

I'm trying to make an NPC that uses the AI of a Paratroopa, but I'm having two problems.

1. How do I make it face Mario without having to make it not be able to move?
2. The more major issue I'm having right now; how do I have the normal Paratroopa options show up in the editor? I copied from the Paratroopa's item code, and that didn't work.

Edit: I just decided to move onto another NPC, and now I need help with tracking the player's Y position. player.y isn't working.
Now taking graphics requests:
https://docs.google.com/forms/d/1urWpFq ... #responses

My graphics pack:
http://www.supermariobrosx.org/forums/v ... t=1960/url

Really tempted to just make a general graphics thread for all of my graphics instead of just making individual threads for each of them.

User avatar
FireyPaperMario
Peach
Peach
Posts: 5835
Joined: Sat Sep 27, 2014 1:39 pm
Flair: 90's kid born in late 1993 ^_^
Current Project: SEGA Genesis/Mega Drive GFXs
Chat Username: Shin FireyPaperMario
Contact:

Re: Need help with lua? - LunaLua General Help

Postby FireyPaperMario » Tue Jan 07, 2020 12:12 pm

I got this Lunalua script idea for the enemy npcs from some Japanese Super Mario Bros. 1 ROM Hack that based off the god-awful famicom Transformers game, Convoy no Nazo, where the enemies fire a small projectile at you every set of seconds. Is that possible?!?


The ROM hack is called "The Mystery of Luigi/Luigi no Nazo" if any of y'all were wondering
Image
(Mega Drive GFX Pack coming soon)
Mario RPG goals (62% of the goals completed)
My Pixiv
I'm autistic & have ADHD.

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Tue Jan 07, 2020 3:28 pm

FireyPaperMario wrote:
Tue Jan 07, 2020 12:12 pm
I got this Lunalua script idea for the enemy npcs from some Japanese Super Mario Bros. 1 ROM Hack that based off the god-awful famicom Transformers game, Convoy no Nazo, where the enemies fire a small projectile at you every set of seconds. Is that possible?!?


The ROM hack is called "The Mystery of Luigi/Luigi no Nazo" if any of y'all were wondering
This thread is for people who are stuck in their code and need help in figuring out where the problem lies or how to continue. I'm willing to help once you run into such a situation, but I think the question above can be easily answered by looking at the PAL build's existing enemy roster and considering similarities between what's already been made and what you would like to make. From your description, I don't know anything about what you're actually trying to do, so please examine what already exists to determine whether the concept is possible.

(In general, pretty much anything is possible, as long as you aren't deliberately trying to break some boundary).
The ABC of Creation
________________________________________________________
Image

User avatar
Chilly14
Bit
Bit
Posts: 132
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Current Project: Lots

Re: Need help with lua? - LunaLua General Help

Postby Chilly14 » Wed Jan 08, 2020 8:29 pm

I mostly succeeded in having a Venus Fire Trap to shoot two or more fireballs with help from 1AmPlayer. However, it doesn't work properly with multiple Venus Fire Traps onscreen:
Spoiler: show
Image
Three of the Venus Fire Traps almost constantly shoot fireballs instead of just two, while one of them briefly hides after shooting a single fireball. Plus, it's random on which one hides and which ones don't. Is there a way to fix this?
Current Code:
Spoiler: show

Code: Select all

for _,v in ipairs(NPC.get(245,player.section)) do
		local v = pnpc.wrap(v)
		local data = v.data
		
		if v.ai1 == 0 and v.ai2 == 1 then
			maxfireballs = 2
		end
		if v.ai1 == 50 and v.ai2 == 2 then
			v.ai1 = 0
			v.ai2 = 2
			maxfireballs = maxfireballs - 1
		end
		if v.ai2 == 2 and maxfireballs == 0 then
			v.ai1 = 51
			maxfireballs = -1
		end
	end
Discord username: Chilly Bean BAM!#8857
Image
For the love of god, please use an adblocker (I prefer uBlock Origin) when using MediaFire to download my stuff.
Check out my levels!
Chilly14's Graphics Pack
Chilly's NPCs
screenRotate.lua
venusFireTrapPlus.lua
I support:
Spoiler: show
Image
Image

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1226
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Thu Jan 09, 2020 4:10 pm

The problem is that you're manipulating one variable with all your NPCs. You need to save the variables you want inside the data table you define, otherwise every NPC is going to share the same variable.

User avatar
Chilly14
Bit
Bit
Posts: 132
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Current Project: Lots

Re: Need help with lua? - LunaLua General Help

Postby Chilly14 » Thu Jan 09, 2020 4:46 pm

Hoeloe wrote:
Thu Jan 09, 2020 4:10 pm
The problem is that you're manipulating one variable with all your NPCs. You need to save the variables you want inside the data table you define, otherwise every NPC is going to share the same variable.
Uhhh...what do you mean by "saving the variables you want inside the data table you define?"
Discord username: Chilly Bean BAM!#8857
Image
For the love of god, please use an adblocker (I prefer uBlock Origin) when using MediaFire to download my stuff.
Check out my levels!
Chilly14's Graphics Pack
Chilly's NPCs
screenRotate.lua
venusFireTrapPlus.lua
I support:
Spoiler: show
Image
Image

User avatar
Hoeloe
Kamikaze Koopa
Kamikaze Koopa
Posts: 1226
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Current Project: A2XT Episode 2

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Jan 10, 2020 2:15 am

Chilly14 wrote:
Thu Jan 09, 2020 4:46 pm
Hoeloe wrote:
Thu Jan 09, 2020 4:10 pm
The problem is that you're manipulating one variable with all your NPCs. You need to save the variables you want inside the data table you define, otherwise every NPC is going to share the same variable.
Uhhh...what do you mean by "saving the variables you want inside the data table you define?"

Code: Select all

local data = v.data
You make a variable called "data" here, and then never use it. This line basically just allows you to use data as a shorthand for v.data, which is the NPCs internal storage table. If you want each NPC to measure things individually, you have to store the data inside its storage table, not just floating in space.

User avatar
Chilly14
Bit
Bit
Posts: 132
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Current Project: Lots

Re: Need help with lua? - LunaLua General Help

Postby Chilly14 » Fri Jan 10, 2020 3:05 pm

Hoeloe wrote:
Fri Jan 10, 2020 2:15 am
Chilly14 wrote:
Thu Jan 09, 2020 4:46 pm
Hoeloe wrote:
Thu Jan 09, 2020 4:10 pm
The problem is that you're manipulating one variable with all your NPCs. You need to save the variables you want inside the data table you define, otherwise every NPC is going to share the same variable.
Uhhh...what do you mean by "saving the variables you want inside the data table you define?"

Code: Select all

local data = v.data
You make a variable called "data" here, and then never use it. This line basically just allows you to use data as a shorthand for v.data, which is the NPCs internal storage table. If you want each NPC to measure things individually, you have to store the data inside its storage table, not just floating in space.
Okay, I'll try to figure it out.
Discord username: Chilly Bean BAM!#8857
Image
For the love of god, please use an adblocker (I prefer uBlock Origin) when using MediaFire to download my stuff.
Check out my levels!
Chilly14's Graphics Pack
Chilly's NPCs
screenRotate.lua
venusFireTrapPlus.lua
I support:
Spoiler: show
Image
Image

User avatar
Murphmario
Larry Koopa
Larry Koopa
Posts: 2163
Joined: Fri Dec 20, 2013 7:07 pm
Current Project: Project planned; waiting for SMBX2 Beta 4

Re: Need help with lua? - LunaLua General Help

Postby Murphmario » Sat Jan 11, 2020 3:58 pm

Once again having issues. Got the player.Y thing to work, but I'm getting this syntax error.
Image
Image
I tried to just change where the "end" is located, but then none of the of the code works, including the separate onNPCKill (which I referenced from Enjl's video).

Edit: I have an older NPC, and player.x = v.x doesn't seem to be working anymore. Is there a possible workaround?

Edit 2: Sorry for so many questions, but I'm now focusing on a different NPC. I'm now wondering how to fix "attempt to index local tbl (a number value)."
Now taking graphics requests:
https://docs.google.com/forms/d/1urWpFq ... #responses

My graphics pack:
http://www.supermariobrosx.org/forums/v ... t=1960/url

Really tempted to just make a general graphics thread for all of my graphics instead of just making individual threads for each of them.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 4 guests