Page 1 of 76

Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 6:40 pm
by Enjl
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:05 pm
by Quantix
Would you happen to know to specific code for getting the player to accelerate to top speed faster?

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:05 pm
by RoundPiplup
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

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:22 pm
by Enjl
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

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:36 pm
by WerewolfGD
Pls tell me how to change the character without hitting a character block with lunalua..........

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:45 pm
by Enjl
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:45 pm
by Quantix
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:50 pm
by Enjl
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.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 7:56 pm
by RoundPiplup
I got this error when I decided to do a full install on latest version.

Says "MSVCP140.dll" is missing.

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 8:06 pm
by Quill
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

Re: Need help with lua? - LunaLua General Help

Posted: Mon Mar 14, 2016 8:24 pm
by RoundPiplup
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?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Mar 15, 2016 7:38 pm
by Quantix
Ok, this might be a dumb question, but you can use both LunaDll and LunaLua in the same level, right?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Mar 15, 2016 7:43 pm
by Enjl
Quantix wrote:Ok, this might be a dumb question, but you can use both LunaDll and LunaLua in the same level, right?
Yes.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Mar 15, 2016 7:53 pm
by Ness-Wednesday
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.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Mar 15, 2016 8:34 pm
by HenryRichard
So I'm trying to set the player's current frame using setCurrentSpriteIndex and that doesn't work at all. Any alternative suggestions?

Re: Need help with lua? - LunaLua General Help

Posted: Tue Mar 15, 2016 8:36 pm
by snoruntpyro
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.

Re: Need help with lua? - LunaLua General Help

Posted: Tue Mar 15, 2016 9:10 pm
by HenryRichard
Thanks; it's working great!

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

Re: Need help with lua? - LunaLua General Help

Posted: Wed Mar 16, 2016 12:32 pm
by Hani
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. :)

Re: Need help with lua? - LunaLua General Help

Posted: Wed Mar 16, 2016 4:49 pm
by Enjl
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.

Re: Need help with lua? - LunaLua General Help

Posted: Thu Mar 17, 2016 1:57 am
by WerewolfGD
HALPLAPLAPPALPLPLA
Pls tel me how to load an image (Image name : badge-1.png) in a level......