Page 1 of 1

3 Questions about LunaLua.

Posted: Sat Jan 25, 2020 5:51 pm
by Chiller
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

Re: 3 Questions about LunaLua.

Posted: Sat Jan 25, 2020 6:16 pm
by Emral
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.

Re: 3 Questions about LunaLua.

Posted: Sat Feb 01, 2020 1:54 pm
by Chiller
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.

Re: 3 Questions about LunaLua.

Posted: Sat Feb 01, 2020 3:27 pm
by Emral
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

Re: 3 Questions about LunaLua.

Posted: Sun Feb 02, 2020 7:41 pm
by Chiller
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?