3 Questions about LunaLua.

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Chiller
Shy Guy
Shy Guy
Posts: 6
Joined: Wed Jul 03, 2019 1:43 pm

3 Questions about LunaLua.

Postby Chiller » Sat Jan 25, 2020 5:51 pm

After using 2.0 for a while I've wanted to dabble in scripting with LunaLua but a couple questions have crossed my mind.
Question 1: Is it possible to use LunaLua APIs from beta 3 in latest version of 2.0(Pal)?
Question 2:How do you load Lunalua scripts from the editor. I'm trying to get Enjl wall jumping script to work when I test my level but it doesn't
Question 3:How do you make a custom hud with Lunalua. In 1.4 I see custom huds everywhere and how to install them but I rarely see them in 2.0.

Thx if anyone responds

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9888
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: 3 Questions about LunaLua.

Postby Emral » Sat Jan 25, 2020 6:16 pm

1. Libraries only stop working if relevant code in basegame was changed. Load the libraries you're curious about and see if they error. By reading the error you can figure out what needs to be done to fix it. Most scripts still work.
2. From the editor? What happens when you press F5 and load into the level is the same thing that happens when you load into a level or episode without using the editor. Simply use require("nameofyourluafilewithout.luaextension") (example: require("spawnzones"))
3. Clever mix of Graphics.drawImage() and accessing variables from within the game.
https://wohlsoft.ru/pgewiki/LunaLua_glo ... _functions - drawImage
https://wohlsoft.ru/pgewiki/SMBX_Global_Memory - Stuff like coin counter and lives counter
https://wohlsoft.ru/pgewiki/Player_(class) - Player-specific information like powerup state.

Chiller
Shy Guy
Shy Guy
Posts: 6
Joined: Wed Jul 03, 2019 1:43 pm

Re: 3 Questions about LunaLua.

Postby Chiller » Sat Feb 01, 2020 1:54 pm

About question 2, I put the the code in and it didn't work. I thought updating to beta 4 and putting the code would work but things didn't change.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9888
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: 3 Questions about LunaLua.

Postby Emral » Sat Feb 01, 2020 3:27 pm

Sounds like your problem is moreso that you struggle to load a lunalua library regardless of the editor or anything.
By default, the file names luna.lua will run for your level. You can create it in the editor if you go into script -> lunalua local. This will create a file and open it.
To then load a library, put:
local myLibrary = require("libraryname")
so for this case:
local anotherWalljump = require("anotherwalljump")

This assumes anotherwalljump is in the level folder.
For anotherwalljump, the topic I posted also contains an usage example directly below the gif spoiler:
viewtopic.php?f=101&t=24793

Chiller
Shy Guy
Shy Guy
Posts: 6
Joined: Wed Jul 03, 2019 1:43 pm

Re: 3 Questions about LunaLua.

Postby Chiller » Sun Feb 02, 2020 7:41 pm

I also did that it didn't work.Is there something wrong with my version or do I just don't know how to load it?


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari