Need help with lua? - LunaLua General Help

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
SMBX-Acc
Goomba
Goomba
Posts: 3
Joined: Mon Jan 14, 2019 11:13 am

Re: Need help with lua? - LunaLua General Help

Postby SMBX-Acc » Wed May 29, 2019 11:08 am

How do I use AI (ai.1-5) of an existing NPC for my custom NPC? I'm trying to make a custom koopa shell.

Thanks
Last edited by SMBX-Acc on Fri Jul 12, 2019 10:28 am, edited 1 time in total.

User avatar
timocomsmbx2345
Ninji
Ninji
Posts: 825
Joined: Sat Feb 06, 2016 1:44 pm
Current Project: i dont even know anymore. . . .
Chat Username: same as my username
Contact:

Re: Need help with lua? - LunaLua General Help

Postby timocomsmbx2345 » Thu May 30, 2019 6:50 pm

I'm thinking about using all the scripts for my episode.bhownwouldnongp about doing that?
SMBX 2.0 β4 is here!!! How about 2.0 β5?
ImageImage
Image
Meepyglobix wrote:DON'T SAY "38A??". OR I'll SHOOT YOU.
Spoiler: show
Image Thanks Pixelpest!!!!
Image
Image

User avatar
not rockythechao
Pokey
Pokey
Posts: 215
Joined: Sat Dec 12, 2015 1:00 am
Current Project: A2XT2 and a few others

Re: Need help with lua? - LunaLua General Help

Postby not rockythechao » Fri May 31, 2019 8:59 am

For starters, you don't. Cinematx, textblox, and really all the other ones I made before animatx2 are generally bloated buggy messes and at least one of them doesn't even work anymore. And there's a lot of other folks' older libraries that are outdated/deprecated for similar reasons.

Going with some more recent scripts that fit the design and direction of your project rather than trying to make everything work together will be much more manageable.
Some people just cannot avoid the ads on MediaFire, even with both common sense and popup blockers. It's always a good idea to provide an alternate download link with an ad-free file host such as Dropbox or Google Drive.

I do music, graphics, lua, birthdays, bachelor parties, bar mitzvahs, long walks on the beach, driving through the scenic countryside with my fabulous mutlicolored mustache flowing in the wind, living life on the edge and not playing by the rules, awkwardly standing in the corner of the room with my GBC during important company meetings, all my own stunts and baking cookies with criminally-high quantities of butter
Spoiler: show
Spinda wrote:gdi rocky
Waddle Derp wrote:rocky what the fuck
rockythechao wrote:gfdi me
Bread wrote:rocky
what did you do
ROCKY
Enjl wrote:you're walking a rocky road
Quantix wrote:jesus christ rocky
rockythechao wrote:the sin is indeed mine

User avatar
IttaBaby
Koopa Troopa
Koopa Troopa
Posts: 22
Joined: Sat Apr 08, 2017 8:19 pm
Chat Username: IttaBaby

Re: Need help with lua? - LunaLua General Help

Postby IttaBaby » Sat Jun 01, 2019 10:16 pm

anybody willing to tell me how to switch some buttons? I want to make Wario dash when run is pressed, rather than alt-run. I tried but when I just replace them all it breaks his coding so he dashes forever.

Emerald Galaxy
Cheep-Cheep
Cheep-Cheep
Posts: 14
Joined: Sun Apr 21, 2019 6:27 am
Flair: =w=
Chat Username: Emerald

Re: Need help with lua? - LunaLua General Help

Postby Emerald Galaxy » Mon Jun 03, 2019 12:55 am

Remember that LunaLua tutorial that involved making a Goomba follow Mario. How come it doesn't seem to work anymore?

Emerald Galaxy
Cheep-Cheep
Cheep-Cheep
Posts: 14
Joined: Sun Apr 21, 2019 6:27 am
Flair: =w=
Chat Username: Emerald

Re: Need help with lua? - LunaLua General Help

Postby Emerald Galaxy » Wed Jun 12, 2019 10:12 pm

Hello. I'm trying to give Peach and Toad their own swimming animations, but I'm having trouble doing so. Can I get a little assistance?
Thanks in advance.

Skott
Goomba
Goomba
Posts: 2
Joined: Mon Jun 17, 2019 7:56 pm
Chat Username: Skott

Re: Need help with lua? - LunaLua General Help

Postby Skott » Mon Jun 17, 2019 9:08 pm

Hey all, I'm having some trouble setting up global variables. Here's what I have in lunaworld.lua:

https://hastebin.com/biwerozede.rb

User avatar
Hoeloe
Eerie
Eerie
Posts: 988
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 » Wed Jun 19, 2019 6:52 am

That hastebin file is empty. For global variables you want to store them in either GameData or SaveData, depending on whether you want the value to be saved when you quit the game.

For example:
SaveData.myVariable = SaveData.myVariable or 0

A line like this will set up a global variable that is saved when you save the game, and initialised to 0.

User avatar
Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 7211
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 Jun 19, 2019 10:37 am

Hoeloe wrote:
Wed Jun 19, 2019 6:52 am
That hastebin file is empty. For global variables you want to store them in either GameData or SaveData, depending on whether you want the value to be saved when you quit the game.

For example:
SaveData.myVariable = SaveData.myVariable or 0

A line like this will set up a global variable that is saved when you save the game, and initialised to 0.
It's not empty for me. Here's a repost.

Code: Select all

SaveData.Treasures = SaveData.Treasures
SaveData.Tokens = SaveData.Tokens
local str = "Treasures: "
local str2 = "Tokens: "

function onDraw()
	Text.print(str .. Treasures, 10, 46)

	Text.print(str2 .. Tokens, 10, 26)
end

function onEvent(eventName)
	if eventName == "SM" then
		SaveData.Tokens = SaveData.Tokens + 5
	end
	if eventName == "MM" then
		SaveData.Tokens = SaveData.Tokens + 10
	end
	if eventName == "LM" then
		SaveData.Tokens = SaveData.Tokens + 20
	end
end

function onNPCKill(eventObj, killedNPC, killReason)
	if killedNPC.id ~= 196 then return end

	if killReason ~= HARM_TYPE_OFFSCREEN then return end

	if Colliders.collide(player, killedNPC) then
		SaveData.Treasures = SaveData.Treasures + 1
	end
end

ImageImageImageImage
ImageImageImageImageImageImage

User avatar
Scroll
Birdo
Birdo
Posts: 1557
Joined: Fri Apr 20, 2018 9:28 pm
Flair: :squint:
Current Project: I'm not a spoiler :v
Chat Username: Scroll#6292
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Scroll » Wed Jun 19, 2019 10:46 pm

Since some time I want to use this mechanic but I am not sure how to make it work. It's around switchable blocks:
- In the first jump, the blue blocks appear and the rest of the colors disappear
- In the second jump, the red blocks appear and the rest disappears
- In the third jump, the yellow blocks appear and the rest disappears
- In the fourth jump, the green blocks appear and the rest disappears
- And then that's what is supposed to happen over and over
I also have a video as a reference: https://www.youtube.com/watch?v=6sYTXcKBK5o
Electriking wrote:Signatures are overrated.

User avatar
Hoeloe
Eerie
Eerie
Posts: 988
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 Jun 20, 2019 4:14 am

Enjl wrote:
Wed Jun 19, 2019 10:37 am

It's not empty for me. Here's a repost.
Weird.

Anyway, the issue is that you never initialise the variables:

SaveData.Treasures = SaveData.Treasures
SaveData.Tokens = SaveData.Tokens

These lines do literally nothing - they're assigning variables to themselves, and if they don't exist, well they still don't exist afterwards.

The reason we do things like:

SaveData.myVar = SaveData.myVar or 0

is to initialise the variable. That "or 0" is the important part. What this line means is "if SavaData.myVar exists, then leave its value the same. Otherwise, set it to 0". This is done because, since SaveData loads its values from the save file, it might already be set up at this point, and just assigning it to 0 would make it act just like a regular variable, removing the point of SaveData in the first place.

Skott
Goomba
Goomba
Posts: 2
Joined: Mon Jun 17, 2019 7:56 pm
Chat Username: Skott

Re: Need help with lua? - LunaLua General Help

Postby Skott » Sat Jun 22, 2019 9:12 pm

Thanks, the variables are working perfectly now!

User avatar
Murphmario
Mouser
Mouser
Posts: 1904
Joined: Fri Dec 20, 2013 7:07 pm

Re: Need help with lua? - LunaLua General Help

Postby Murphmario » Sat Jul 06, 2019 10:01 pm

Hey, does anyone know how to make an NPC that behaves identically to a Snake Block other than the block it's initially set to in the PGE editor? I can't figure it out myself, so help would be appriciated.
Now taking graphics requests:
https://docs.google.com/forms/d/1urWpFq ... #responses

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

Nothing is coming on Christmas. Why? Because I missed my past promises and should stop putting release dates on my stuff.

User avatar
MisterZygarde64
Spiny
Spiny
Posts: 40
Joined: Wed Jun 08, 2016 9:43 pm

Re: Need help with lua? - LunaLua General Help

Postby MisterZygarde64 » Sun Jul 07, 2019 10:24 pm

How am I supposed to run the code for this?
http://www.supermariobrosx.org/forums/v ... 87&t=13566

I'm making an episode where Mario and Luigi are the only playable characters but I want to make the episode easier so it can be more acessable. So I decided to download this lua code. (Credit to PixelPest). I just have no experience with LunaLua. I just need to know how I can have the code run so when Fire Mario his hit, he becomes big Mario instead of small Mario

*Edit* Nevermind. I figured it out.
Last edited by MisterZygarde64 on Tue Jul 09, 2019 4:33 pm, edited 1 time in total.

User avatar
Electriking
Posts: 4203
Joined: Mon Jun 06, 2016 4:32 pm
Flair: I have NO idea what to put here
Current Project: Something
Chat Username: ElectriKing
Contact:

Re: Need help with lua? - LunaLua General Help

Postby Electriking » Mon Jul 08, 2019 1:43 am

Murphmario wrote:
Sat Jul 06, 2019 10:01 pm
Hey, does anyone know how to make an NPC that behaves identically to a Snake Block other than the block it's initially set to in the PGE editor? I can't figure it out myself, so help would be appriciated.
Changed the block ID for the snake block NPCs in the properties, then place that block between them.
Signatures are overrated.

User avatar
Murphmario
Mouser
Mouser
Posts: 1904
Joined: Fri Dec 20, 2013 7:07 pm

Re: Need help with lua? - LunaLua General Help

Postby Murphmario » Mon Jul 08, 2019 10:09 am

I said a NEW NPC, as in, not the same ID as a regular Snake Block.
Now taking graphics requests:
https://docs.google.com/forms/d/1urWpFq ... #responses

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

Nothing is coming on Christmas. Why? Because I missed my past promises and should stop putting release dates on my stuff.

cato
Rex
Rex
Posts: 83
Joined: Thu Aug 24, 2017 3:06 am
Chat Username: cato

Re: Need help with lua? - LunaLua General Help

Postby cato » Fri Jul 12, 2019 5:29 am

How do I script an autoscroll in other sections in SMBX 2.0 Beta 3?
It is possible in MAGLX3 or PAL version. Is it possible in the previous sections?

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Fri Jul 12, 2019 5:42 am

Murphmario wrote:
Mon Jul 08, 2019 10:09 am
I said a NEW NPC, as in, not the same ID as a regular Snake Block.
Why? What Electriking said makes the snake block look like it were of the block you entered.
A demo can be found in this blog post:
http://codehaus.wohlsoft.ru/blog/2017/0 ... loodgates/
cato wrote:
Fri Jul 12, 2019 5:29 am
How do I script an autoscroll in other sections in SMBX 2.0 Beta 3?
It is possible in MAGLX3 or PAL version. Is it possible in the previous sections?
Literally the same as in the MAGLX3 builds.
ImageImageImageImage
ImageImageImageImageImageImage

cato
Rex
Rex
Posts: 83
Joined: Thu Aug 24, 2017 3:06 am
Chat Username: cato

Re: Need help with lua? - LunaLua General Help

Postby cato » Fri Jul 12, 2019 10:38 am

Well nope, legitly copied it from your video. Doesn't even scroll at all in Beta3. When I tested it on the PAL version, works perfectly fine.
I think the problem would be the argument "autoscroll.scrollRight(1)".

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

Re: Need help with lua? - LunaLua General Help

Postby Enjl » Fri Jul 12, 2019 10:59 am

cato wrote:
Fri Jul 12, 2019 10:38 am
Well nope, legitly copied it from your video. Doesn't even scroll at all in Beta3. When I tested it on the PAL version, works perfectly fine.
I think the problem would be the argument "autoscroll.scrollRight(1)".
The only thing that changed in autoscroll.lua between beta 3 and maglx3 is that a buffer was introduced to ensure the first scroll command is guaranteed to be executed after the first onCameraUpdate, to prevent the camera from scrolling before it has properly reset. In Beta 3 you have to take care of that manually if you want the scroll to start immediately. No difference when starting a scroll later though, which is the primary use case anyway.
ImageImageImageImage
ImageImageImageImageImageImage


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest