Need help with lua? - LunaLua General Help

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

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?
Circle Guy
Rocky Wrench
Rocky Wrench
Posts: 645
Joined: Mon Jan 04, 2016 9:25 pm

Re: Need help with lua? - LunaLua General Help

Postby Circle Guy » Fri Apr 08, 2016 6:58 am

PixelPest wrote:
Circle Guy wrote:
HenryRichard wrote:Did you set the .wld file's name in the editor?
Yeah, but I mean NO world names are showing up. Even the Invasion 2!
Oh. You mean on the main screen. I don't think you could really fix that easily. Have you actually checked to see if the .wld files have names inside the file?
Yeah, they do. Maybe I'll just look through and see what happened later.

HenryRichard
Reznor
Reznor
Posts: 2843
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 » Fri Apr 08, 2016 5:06 pm

Sounds like you need to reinstall smbx.

pal4
Swooper
Swooper
Posts: 63
Joined: Wed Dec 23, 2015 7:57 pm

Re: Need help with lua? - LunaLua General Help

Postby pal4 » Fri Apr 08, 2016 5:49 pm

Quantumenace wrote:The legacy editor should use lunalua scripts. I've never gotten the new editor to test correctly. Is the folder you posted the folder for the level? If so, why are there .lvl files in there?
It's the folder the level is in. I've been grouping levels by world.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Fri Apr 08, 2016 7:18 pm

pal4 wrote:
Quantumenace wrote:The legacy editor should use lunalua scripts. I've never gotten the new editor to test correctly. Is the folder you posted the folder for the level? If so, why are there .lvl files in there?
It's the folder the level is in. I've been grouping levels by world.
Then your lunalua file won't work. It has to be inside the level folder, with the level itself outside that folder.

pal4
Swooper
Swooper
Posts: 63
Joined: Wed Dec 23, 2015 7:57 pm

Re: Need help with lua? - LunaLua General Help

Postby pal4 » Sat Apr 09, 2016 10:30 am

Hoeloe wrote:
pal4 wrote:
Quantumenace wrote:The legacy editor should use lunalua scripts. I've never gotten the new editor to test correctly. Is the folder you posted the folder for the level? If so, why are there .lvl files in there?
It's the folder the level is in. I've been grouping levels by world.
Then your lunalua file won't work. It has to be inside the level folder, with the level itself outside that folder.
How do I make a level folder? My computer won't let me name the folder like my level is named.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Sat Apr 09, 2016 12:08 pm

pal4 wrote: How do I make a level folder? My computer won't let me name the folder like my level is named.
You don't add ".lvl" to the end, but if it still won't let you you need to change your level name.

pal4
Swooper
Swooper
Posts: 63
Joined: Wed Dec 23, 2015 7:57 pm

Re: Need help with lua? - LunaLua General Help

Postby pal4 » Sat Apr 09, 2016 1:06 pm

Okay, I did it, but the code still does nothing. I put in a Text.print() code, to show my variable and still no changes occurred. Nothing showed up.

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Sat Apr 09, 2016 1:10 pm

pal4 wrote:Okay, I did it, but the code still does nothing. I put in a Text.print() code, to show my variable and still no changes occurred. Nothing showed up.
Can you show another screenshot of your level folder, and post your code?

Hani
Volcano Lotus
Volcano Lotus
Posts: 565
Joined: Mon Apr 13, 2015 6:34 pm

Re: Need help with lua? - LunaLua General Help

Postby Hani » Sat Apr 09, 2016 6:34 pm

Oh! I wonder if there is a way where I can make all blocks slippery instead of just selecting a block and enable slippery.

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Sun Apr 10, 2016 2:40 am

To do something with multiple objects you need to use a loop. If you want every block in the entire level,

Block.get()

returns a table with references to all the blocks. To do something with them you can use the "pairs" keyword which cycles through all entries in the table using the variables provided:

for k,v in pairs(Block.get()) do ...... end

In this case, v represents the value at index k in the table. The value v is a reference to the block, and you can modify its "slippery" flag with v.slippery = true.

Code: Select all

for k,v in pairs(Block.get()) do 
	v.slippery = true
end
Don't forget the "end" or you'll get a "function failed to close" error.

You need to put this in an onStart() function or something, just putting it outside functions will try to run it before the blocks are even loaded.

Anyways, the wiki has a lot of information on this stuff. This page is a good place to start on the basics.

Quantix
Chain Chomp
Chain Chomp
Posts: 333
Joined: Tue Jan 26, 2016 5:04 pm

Re: Need help with lua? - LunaLua General Help

Postby Quantix » Sun Apr 10, 2016 11:29 am

So, I'm trying to use the Raocoins.lua for my episode, but when I put this in the lunaworld file:

Code: Select all

local raocoin = loadAPI("raocoin");
...the thing crashes. I read the error and it's something about it using registerEvent with strings. Is there anything I can do to fix this?

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Need help with lua? - LunaLua General Help

Postby Hoeloe » Sun Apr 10, 2016 12:32 pm

Quantix wrote:So, I'm trying to use the Raocoins.lua for my episode, but when I put this in the lunaworld file:

Code: Select all

local raocoin = loadAPI("raocoin");
...the thing crashes. I read the error and it's something about it using registerEvent with strings. Is there anything I can do to fix this?
You're using the wrong library. "raocoin" is an old outdated library, while "raocoin2" is a modern one.

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Apr 10, 2016 1:49 pm

Hoeloe wrote:
Quantix wrote:So, I'm trying to use the Raocoins.lua for my episode, but when I put this in the lunaworld file:

Code: Select all

local raocoin = loadAPI("raocoin");
...the thing crashes. I read the error and it's something about it using registerEvent with strings. Is there anything I can do to fix this?
You're using the wrong library. "raocoin" is an old outdated library, while "raocoin2" is a modern one.
Also use API.load since loadAPI is deprecated

Hani
Volcano Lotus
Volcano Lotus
Posts: 565
Joined: Mon Apr 13, 2015 6:34 pm

Re: Need help with lua? - LunaLua General Help

Postby Hani » Sun Apr 10, 2016 2:04 pm

Quantumenace wrote:To do something with multiple objects you need to use a loop. If you want every block in the entire level,

Block.get()

returns a table with references to all the blocks. To do something with them you can use the "pairs" keyword which cycles through all entries in the table using the variables provided:

for k,v in pairs(Block.get()) do ...... end

In this case, v represents the value at index k in the table. The value v is a reference to the block, and you can modify its "slippery" flag with v.slippery = true.

Code: Select all

for k,v in pairs(Block.get()) do 
	v.slippery = true
end
Don't forget the "end" or you'll get a "function failed to close" error.

You need to put this in an onStart() function or something, just putting it outside functions will try to run it before the blocks are even loaded.

Anyways, the wiki has a lot of information on this stuff. This page is a good place to start on the basics.
This is what the code looks like when I made it, it crashed.

Code: Select all

onStart() function

for k,v in pairs(Block.get()) do 
   v.slippery = true
end
I don't know what I did wrong.

Mario_and_Luigi_55
Spike
Spike
Posts: 270
Joined: Sat Feb 27, 2016 12:01 pm

Re: Need help with lua? - LunaLua General Help

Postby Mario_and_Luigi_55 » Sun Apr 10, 2016 2:07 pm

Catastrophe wrote:
Quantumenace wrote:To do something with multiple objects you need to use a loop. If you want every block in the entire level,

Block.get()

returns a table with references to all the blocks. To do something with them you can use the "pairs" keyword which cycles through all entries in the table using the variables provided:

for k,v in pairs(Block.get()) do ...... end

In this case, v represents the value at index k in the table. The value v is a reference to the block, and you can modify its "slippery" flag with v.slippery = true.

Code: Select all

for k,v in pairs(Block.get()) do 
	v.slippery = true
end
Don't forget the "end" or you'll get a "function failed to close" error.

You need to put this in an onStart() function or something, just putting it outside functions will try to run it before the blocks are even loaded.

Anyways, the wiki has a lot of information on this stuff. This page is a good place to start on the basics.
This is what the code looks like when I made it, it crashed.

Code: Select all

onStart() function

for k,v in pairs(Block.get()) do 
   v.slippery = true
end
I don't know what I did wrong.
1. Function onStart() not onStart() function
2. On start does things once, when level starts. Use function onLoop() or function onTick() there

underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: Need help with lua? - LunaLua General Help

Postby underFlo » Sun Apr 10, 2016 2:10 pm

^ Also, you need one more end

(even though I'm pretty sure that onStart() would be the right function for this, but I may be wrong)

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Apr 10, 2016 2:12 pm

Catastrophe wrote:
You really need take some time to learn the basics, if you don't even know where to put "function"

Hani
Volcano Lotus
Volcano Lotus
Posts: 565
Joined: Mon Apr 13, 2015 6:34 pm

Re: Need help with lua? - LunaLua General Help

Postby Hani » Sun Apr 10, 2016 2:15 pm

The code didn't crash when I added the other end but it's not making the blocks slippery. ???

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Apr 10, 2016 2:16 pm

Catastrophe wrote:The code didn't crash when I added the other end but it's not making the blocks slippery. ???
Then use function onTick(). That should work

Hani
Volcano Lotus
Volcano Lotus
Posts: 565
Joined: Mon Apr 13, 2015 6:34 pm

Re: Need help with lua? - LunaLua General Help

Postby Hani » Sun Apr 10, 2016 2:18 pm

PixelPest wrote:
Catastrophe wrote:The code didn't crash when I added the other end but it's not making the blocks slippery. ???
Then use function onTick(). That should work
function onTick() also doesn't work.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari