Need help with lua? - LunaLua General Help

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
User avatar
Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 7570
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Need help with lua? - LunaLua General Help

Postby Enjl » Mon Mar 14, 2016 6:40 pm

So you're trying to get into LunaLua but
1) Don't know where to get started?
2) Have a question?

LOOK NO FURTHER THAN THIS THREAD!

How to get started
If you don't have LunaLua installed, follow these instructions:
Download the latest version of SMBX 2.0. Major updates to LunaLua and SMBX are synched.
If you want to try a laboratory build of LunaLua before the next version of SMBX, try . The Button "Download latest nightly/dev build" will provide you a download to the laboratory version of LunaLua.

If you're new to LunaLua, I suggest checking out [url=http://www.supermariobrosx.org/forums/v ... 87&t=12548]pyro's lua tutorials
. They're pretty outdated but still a good introduction to lua coding. Here's a few quirks you should know about, though:
-onLoop is deprecated and has been replaced with onTick
-onLoad is deprecated and has been replaced with onStart

If you're looking for documentation of any kind, you're going to find it here.

Do you have a question?

If you have a question about why your code isn't working or how to optimize something you've been working on, just reply in this thread. If you feel like your issue is major and are afraid it'll drag on over several pages or get lost, don't hesitate to make a topic about it in the forum, though.
There are many people who are experienced in lunalua (myself included) who're glad to help you out.

Just make sure that you provide enough information on your issue so we can help you. Taking a screenshot of the error message (if there is one) or posting your code using the "code" bbcode or using http://hastebin.com/ are things you should always do. If your code is long and you are getting an error, make sure to specify which lines the error is tied to (and post to hastebin rather than using the bbcode, because hastebin has line numbers). (To find which line an error appears in, look at the number at the end of the directory in the first line of the error message, or just post a picture of the error along with the code).

With that out of the way, if you have any questions regarding how to do something in lua or regarding your lua code, this is the place to go.
Last edited by Enjl on Tue Jan 24, 2017 11:14 am, edited 2 times in total.
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
Quantix
Ripper II
Ripper II
Posts: 325
Joined: Tue Jan 26, 2016 5:04 pm

Re: Need help with lua? - LunaLua General Help

Postby Quantix » Mon Mar 14, 2016 7:05 pm

Would you happen to know to specific code for getting the player to accelerate to top speed faster?
viewtopic.php?f=69&p=286856#p286855

Generic Quote Collection:
Spoiler: show
Skant wrote:The egg will fuck you if you don't catch it
rockythechao wrote:f6 is an over-the-counter generic run-of-the-mill store-brand bootleg knockoff f5
some people wrote:The021stYoshiFromThe021stCentury: Who would win, a tophat wearing a tophat, or hoeloe wearing hoeloe?
Hoeloe: yes
glitch4: f6
rockythecomet: that's a trick question
rockythecomet: a top hat wearing a hoeloe
Waffles & Stuff (timocomlita) wrote:No matter what you do, it's impossible to get rid of the impossible.
Petrifying wrote:Piss off with your sex doll SMBX 2.0
Enjl wrote:it puts a twist on classic 4 step level design which i like to call "2 and a half steps backwards design"

User avatar
RoundPiplup
Grinder
Grinder
Posts: 1142
Joined: Sun Jun 15, 2014 12:03 pm

Re: Need help with lua? - LunaLua General Help

Postby RoundPiplup » Mon Mar 14, 2016 7:05 pm

I need something like a step by step instructions on how to properly install/update Luna Lua on SMBX 1.3.0.1 or on SMBX 2.0. Don't know if it's just me
The Past still haunts me.
Spoiler: show
Image

Image
...

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Mon Mar 14, 2016 7:22 pm

RoundPiplup wrote:I need something like a step by step instructions on how to properly install/update Luna Lua on SMBX 1.3.0.1 or on SMBX 2.0. Don't know if it's just me
Right. Added to the first post.
Quantix wrote:Would you happen to know to specific code for getting the player to accelerate to top speed faster?
While I haven't seen code like that before, you should be able to use player.speedX and function onKeyDown(keyCode) to get this result. You need to watch out for edge cases though. If you're not careful, the player might be able to accelerate by holding down and right at the same time. Helpful pages for this type of code:
http://wohlsoft.ru/pgewiki/LunaLua_events
http://wohlsoft.ru/pgewiki/Player_%28class%29
http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
WerewolfGD
Wart
Wart
Posts: 3256
Joined: Tue Dec 02, 2014 2:28 am
Flair: Daily life of Alagirez
Current Project: Questioning my life
Chat Username: Alagirez
Contact:

Re: Need help with lua? - LunaLua General Help

Postby WerewolfGD » Mon Mar 14, 2016 7:36 pm

Pls tell me how to change the character without hitting a character block with lunalua..........

A former SMBX level designner
If you want to to talk with me, go here : Alagirez#2056
Also a furry

Image
YT Channel |MxW2 for those who wants it
My osu! Profile | My twitter
Image

Awooo!

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Mon Mar 14, 2016 7:45 pm

Harvey36Dice wrote:Pls tell me how to change the character without hitting a character block with lunalua..........
http://wohlsoft.ru/pgewiki/Player_%28class%29
player.character = x
where x = 1 or CHARACTER_MARIO for Mario, 2 or CHARACTER_LUIGI for Luigi, 3 or CHARACTER_PEACH for Peach, 4 or CHARACTER_TOAD for Toad, 5 or CHARACTER_LINK for Linik.
Just make sure to wrap the line above into onStart or something.
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
Quantix
Ripper II
Ripper II
Posts: 325
Joined: Tue Jan 26, 2016 5:04 pm

Re: Need help with lua? - LunaLua General Help

Postby Quantix » Mon Mar 14, 2016 7:45 pm

Enjl wrote:
Quantix wrote:Would you happen to know to specific code for getting the player to accelerate to top speed faster?
While I haven't seen code like that before, you should be able to use player.speedX and function onKeyDown(keyCode) to get this result. You need to watch out for edge cases though. If you're not careful, the player might be able to accelerate by holding down and right at the same time. Helpful pages for this type of code:
http://wohlsoft.ru/pgewiki/LunaLua_events
http://wohlsoft.ru/pgewiki/Player_%28class%29
http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Well that's good enough I suppose. The player offsets thing looks intimidating, though.
viewtopic.php?f=69&p=286856#p286855

Generic Quote Collection:
Spoiler: show
Skant wrote:The egg will fuck you if you don't catch it
rockythechao wrote:f6 is an over-the-counter generic run-of-the-mill store-brand bootleg knockoff f5
some people wrote:The021stYoshiFromThe021stCentury: Who would win, a tophat wearing a tophat, or hoeloe wearing hoeloe?
Hoeloe: yes
glitch4: f6
rockythecomet: that's a trick question
rockythecomet: a top hat wearing a hoeloe
Waffles & Stuff (timocomlita) wrote:No matter what you do, it's impossible to get rid of the impossible.
Petrifying wrote:Piss off with your sex doll SMBX 2.0
Enjl wrote:it puts a twist on classic 4 step level design which i like to call "2 and a half steps backwards design"

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Mon Mar 14, 2016 7:50 pm

Quantix wrote:
Enjl wrote:
Quantix wrote:Would you happen to know to specific code for getting the player to accelerate to top speed faster?
While I haven't seen code like that before, you should be able to use player.speedX and function onKeyDown(keyCode) to get this result. You need to watch out for edge cases though. If you're not careful, the player might be able to accelerate by holding down and right at the same time. Helpful pages for this type of code:
http://wohlsoft.ru/pgewiki/LunaLua_events
http://wohlsoft.ru/pgewiki/Player_%28class%29
http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Well that's good enough I suppose. The player offsets thing looks intimidating, though.
Using player offsets isn't that difficult, actually. Pyro explains it in episode 2 of her lua tutorials series, but I'll go over it real quick.
To modify offsets, you need to use
player:mem(offset, type)
to get values and
player:mem(offset, type, value)
to set values.
For example, if you want to get the player powerup (this is redundant due to player.powerup which you should use instead, but it serves as an example), you do
local variable = player:mem(0x112, FIELD_WORD)
if you want to set it to, say, mushroom, you do
player:mem(0x112, FIELD_WORD, 2)

You can use Text.print to find out proper values for different offsets.
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
RoundPiplup
Grinder
Grinder
Posts: 1142
Joined: Sun Jun 15, 2014 12:03 pm

Re: Need help with lua? - LunaLua General Help

Postby RoundPiplup » Mon Mar 14, 2016 7:56 pm

I got this error when I decided to do a full install on latest version.

Says "MSVCP140.dll" is missing.
The Past still haunts me.
Spoiler: show
Image

Image
...

User avatar
Quill
Rydia
Rydia
Posts: 811
Joined: Tue Dec 03, 2013 12:51 pm
Current Project: Apocalypse of Foroze...?
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Quill » Mon Mar 14, 2016 8:06 pm

RoundPiplup wrote:I got this error when I decided to do a full install on latest version.

Says "MSVCP140.dll" is missing.
Try downloading this

User avatar
RoundPiplup
Grinder
Grinder
Posts: 1142
Joined: Sun Jun 15, 2014 12:03 pm

Re: Need help with lua? - LunaLua General Help

Postby RoundPiplup » Mon Mar 14, 2016 8:24 pm

Ok I installed it. Do I have to restart the computer or is there something else I had to do after downloading and installing it?
The Past still haunts me.
Spoiler: show
Image

Image
...

User avatar
Quantix
Ripper II
Ripper II
Posts: 325
Joined: Tue Jan 26, 2016 5:04 pm

Re: Need help with lua? - LunaLua General Help

Postby Quantix » Tue Mar 15, 2016 7:38 pm

Ok, this might be a dumb question, but you can use both LunaDll and LunaLua in the same level, right?
viewtopic.php?f=69&p=286856#p286855

Generic Quote Collection:
Spoiler: show
Skant wrote:The egg will fuck you if you don't catch it
rockythechao wrote:f6 is an over-the-counter generic run-of-the-mill store-brand bootleg knockoff f5
some people wrote:The021stYoshiFromThe021stCentury: Who would win, a tophat wearing a tophat, or hoeloe wearing hoeloe?
Hoeloe: yes
glitch4: f6
rockythecomet: that's a trick question
rockythecomet: a top hat wearing a hoeloe
Waffles & Stuff (timocomlita) wrote:No matter what you do, it's impossible to get rid of the impossible.
Petrifying wrote:Piss off with your sex doll SMBX 2.0
Enjl wrote:it puts a twist on classic 4 step level design which i like to call "2 and a half steps backwards design"

User avatar
Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 7570
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 Mar 15, 2016 7:43 pm

Quantix wrote:Ok, this might be a dumb question, but you can use both LunaDll and LunaLua in the same level, right?
Yes.
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
Ness-Wednesday
Purple Yoshi Egg
Purple Yoshi Egg
Posts: 1372
Joined: Sun Jun 28, 2015 3:50 pm
Flair: Diverse Scouts
Current Project: TBA ;)
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Ness-Wednesday » Tue Mar 15, 2016 7:53 pm

Quantix wrote:Ok, this might be a dumb question, but you can use both LunaDll and LunaLua in the same level, right?
What Enjl said.
Basically, this can go quite well if you know how to use them in a good way.
Although, I don't think there are alot of people who do this because Lunalua could do pretty much everything Lunadll can do.
#Therealmofloveandhate

Join my Discord server!
Spoiler: show
Image
Do you love Villagers? I know I do!
(Image is not by me)
Will Toad truly get an actual project, will something happen who knows?
OR

User avatar
HenryRichard
Ludwig von Koopa
Ludwig von Koopa
Posts: 2844
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: Need help with lua? - LunaLua General Help

Postby HenryRichard » Tue Mar 15, 2016 8:34 pm

So I'm trying to set the player's current frame using setCurrentSpriteIndex and that doesn't work at all. Any alternative suggestions?
Image

I'm on Soundcloud | My graphics pack!

Jesus is my savior.

User avatar
snoruntpyro
Pokey
Pokey
Posts: 223
Joined: Sun Oct 11, 2015 9:36 am
Contact:

Re: Need help with lua? - LunaLua General Help

Postby snoruntpyro » Tue Mar 15, 2016 8:36 pm

HenryRichard wrote:So I'm trying to set the player's current frame using setCurrentSpriteIndex and that doesn't work at all. Any alternative suggestions?
Try using player mem value 0x114. Documentation of that is on the wiki. Also, make sure you're doing all of this in onCameraUpdate, it only works there afaik.
Spoiler: show
Image
Spoiler: show
Image

User avatar
HenryRichard
Ludwig von Koopa
Ludwig von Koopa
Posts: 2844
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: Need help with lua? - LunaLua General Help

Postby HenryRichard » Tue Mar 15, 2016 9:10 pm

Thanks; it's working great!

EDIT: How would I make a ribbon trail with particles.lua?
Image

I'm on Soundcloud | My graphics pack!

Jesus is my savior.

User avatar
Hani
Volcano Lotus
Volcano Lotus
Posts: 564
Joined: Mon Apr 13, 2015 6:34 pm
Flair: Spring (봄)

Re: Need help with lua? - LunaLua General Help

Postby Hani » Wed Mar 16, 2016 12:32 pm

I'll just ask 2 questions at a time.
Would it be possible to make an npc deadly? Like instead of just hurting you, you get instant death.
And, how do I make particles / or set up particles? Like this kind of particle.
Spoiler: show
Image
The lava specks rising into the air.
Well I hope you guys get an answer for these.. Thank you. :)
Image

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Wed Mar 16, 2016 4:49 pm

Catastrophe wrote:I'll just ask 2 questions at a time.
Would it be possible to make an npc deadly? Like instead of just hurting you, you get instant death.
And, how do I make particles / or set up particles? Like this kind of particle.
Spoiler: show
Image
The lava specks rising into the air.
Well I hope you guys get an answer for these.. Thank you. :)
For your first question, you are able to attach a collider to an npc object and have that npc kill the player on collision. More information:
http://wohlsoft.ru/pgewiki/Colliders.lua
http://wohlsoft.ru/pgewiki/Player_%28class%29

For your second question:
http://wohlsoft.ru/pgewiki/Particles.lua
If you have this API, you can create .ini files to set rules for how your particles should move and where they should appear in their region in which they spawn, their colour, etc. It might be a bit overwhelming at first but I suggest just toying around with the contents of your ini until you have something which you're satisfied with.
ImageImageImageImage
ImageImageImageImageImageImage

User avatar
WerewolfGD
Wart
Wart
Posts: 3256
Joined: Tue Dec 02, 2014 2:28 am
Flair: Daily life of Alagirez
Current Project: Questioning my life
Chat Username: Alagirez
Contact:

Re: Need help with lua? - LunaLua General Help

Postby WerewolfGD » Thu Mar 17, 2016 1:57 am

HALPLAPLAPPALPLPLA
Pls tel me how to load an image (Image name : badge-1.png) in a level......

A former SMBX level designner
If you want to to talk with me, go here : Alagirez#2056
Also a furry

Image
YT Channel |MxW2 for those who wants it
My osu! Profile | My twitter
Image

Awooo!


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest