If you need help with anything LunaLua related, ask it here!
Please do check the wiki though since it's pretty comprehensive!
LunaLua Help
- The Destroyer of Worlds
- I am become death
- Posts: 1485
- Joined: 6 years ago
LunaLua Help
raocow wrote:Dang it Oyster this level is not called Peregrine Penguin and the Soft Bon-Bon, it clearly says Ghost House with a Ghost in It!
Re: LunaLua Help
Okay lets get cracking!
I want to make a level based around the Starman, but I also want to try making some modifications to it's code (specifically, add a counter for after the music loops end and make use of the Colliders API), I think I understand what's going on for most of it, but some of the functions I have no clue what they do. For instance in starman.onTick there's something called NPC.getIntersecting. Is that for when mario picks up the star?
Another thing I tried to figure out last night is how to make Mario's fireballs shoot correctly (have only two on-screen at a time, with no timer in-between firing, and a change to their x-speed). But when I first tried it I didn't know what function or API I could use to count the fireballs in Mario's current section. I tried NPC.get but it returned some hex values, and NPC.count, which I couldn't figure out. I don't know what arguments .count takes, if any.
EDIT: Alright, I figured out the fireballs, but they persist while offscreen. I figure, I'll just find the screen coordinates and kill the npcs when they're about 4 blocks out, but I don't know how player.screen works. Its a RECT type and I went to look it up. Seems like its a function that returns the four boundary values? But whenever I try to use it I get "==> no such operator defined". Do I have to define a new RECT using player.screen? I'm clueless.
I want to make a level based around the Starman, but I also want to try making some modifications to it's code (specifically, add a counter for after the music loops end and make use of the Colliders API), I think I understand what's going on for most of it, but some of the functions I have no clue what they do. For instance in starman.onTick there's something called NPC.getIntersecting. Is that for when mario picks up the star?
Another thing I tried to figure out last night is how to make Mario's fireballs shoot correctly (have only two on-screen at a time, with no timer in-between firing, and a change to their x-speed). But when I first tried it I didn't know what function or API I could use to count the fireballs in Mario's current section. I tried NPC.get but it returned some hex values, and NPC.count, which I couldn't figure out. I don't know what arguments .count takes, if any.
EDIT: Alright, I figured out the fireballs, but they persist while offscreen. I figure, I'll just find the screen coordinates and kill the npcs when they're about 4 blocks out, but I don't know how player.screen works. Its a RECT type and I went to look it up. Seems like its a function that returns the four boundary values? But whenever I try to use it I get "==> no such operator defined". Do I have to define a new RECT using player.screen? I'm clueless.
Re: LunaLua Help
Okay! I finally figured all that fireball jazz out. It works in the level just fine. So I tried to put it into it's own API, but then I get this error:

I went to mainV2.lua to check it out, but it looks as though its just defining the events for each API. I think it may be that I have to return some data from the API to the host level file but I don't know what needs to be returned.
Code:

I went to mainV2.lua to check it out, but it looks as though its just defining the events for each API. I think it may be that I have to return some data from the API to the host level file but I don't know what needs to be returned.
Code:
Code: Select all
local properFireballs = {}
function properFireballs.onTick()
local fireballs = NPC.get(13,player.section);
local iceballs = NPC.get(265,player.section);
local hammers = NPC.get(171,player.section);
for _, v in pairs(fireballs) do
local offscreen = v:mem(0x128,FIELD_WORD)
if offscreen == -1 then
v:mem(0x12A,FIELD_WORD,0) --If shots are offscreen, set despawn to instant
end
if v.direction > 0 then
v.speedX = 8
else if v.direction < 0 then
v.speedX = -8
end
end
if fireballs[2] == nil then --Checks if second index is filled for player section
player:mem(0x160,FIELD_WORD,0)
else
player:mem(0x160,FIELD_WORD,1)
end
end
for _, v in pairs(iceballs) do
local offscreen = v:mem(0x128,FIELD_WORD)
if offscreen == -1 then
v:mem(0x12A,FIELD_WORD,0)
end
if v.direction > 0 then
v.speedX = 5.6
else if v.direction < 0 then
v.speedX = -5.6
end
end
if iceballs[2] == nil then
player:mem(0x160,FIELD_WORD,0)
else
player:mem(0x160,FIELD_WORD,1)
end
end
for _, v in pairs(hammers) do
local offscreen = v:mem(0x128,FIELD_WORD)
if offscreen == -1 then
v:mem(0x12A,FIELD_WORD,0)
end
if hammers[2] == nil then
player:mem(0x160,FIELD_WORD,0)
else
player:mem(0x160,FIELD_WORD,1)
end
end
end
function properFireballs.onInitAPI()
registerEvent(properFirealls,"onTick","onTick")
end
return properFireballs;
Re: LunaLua Help
Isrieri wrote:registerEvent(properFirealls,"onTick","onTick")
Isrieri wrote:properFirealls
Isrieri wrote:Firealls
Be sure to check your spellingIsrieri wrote:alls





Re: LunaLua Help
Oh my god, that was actually it. I'm so pissed at myself.
Thank you, Hoeloe! Now I know what to do if that error shows up again.
Thank you, Hoeloe! Now I know what to do if that error shows up again.
- KittyTristy
- Coffee-Powered Kittygirl
- Posts: 4
- Joined: 2 years ago
- First name: Tristy
- Pronouns: she/her
- Location: USA
Re: LunaLua Help
No matter what I do, I can't get cinematX to work. I've followed the wiki and examples I've seen, and it just doesn't work at all. :/
Does anyone have any levels using cinematX that are working with SMBX 2.0 that I could take a look at?
Does anyone have any levels using cinematX that are working with SMBX 2.0 that I could take a look at?
Re: LunaLua Help
CinematX is very old and broken and never quite worked properly. It's really not recommended to even try using it.KittyTristy wrote:No matter what I do, I can't get cinematX to work. I've followed the wiki and examples I've seen, and it just doesn't work at all. :/
Does anyone have any levels using cinematX that are working with SMBX 2.0 that I could take a look at?





- KittyTristy
- Coffee-Powered Kittygirl
- Posts: 4
- Joined: 2 years ago
- First name: Tristy
- Pronouns: she/her
- Location: USA
Re: LunaLua Help
Ah. Well it was included with SMBX 2.0 and it's on the wiki so it didn't really seem like that way when I was looking around about it. Oh well. Thanks anyways. :3Hoeloe wrote:CinematX is very old and broken and never quite worked properly. It's really not recommended to even try using it.KittyTristy wrote:No matter what I do, I can't get cinematX to work. I've followed the wiki and examples I've seen, and it just doesn't work at all. :/
Does anyone have any levels using cinematX that are working with SMBX 2.0 that I could take a look at?
Re: LunaLua Help
KittyTristy wrote: Ah. Well it was included with SMBX 2.0 and it's on the wiki so it didn't really seem like that way when I was looking around about it. Oh well. Thanks anyways. :3
It's been kept in for compatibility, but really you shouldn't be using it. There are some tools to do what it does in separate forms. The event scheduling is now part of eventu.lua, there's a simple "follower" script used by Bowser to replicate follower behaviour, pnpc.lua deals with keeping track of and modifying NPCs, and textblox.lua can deal with extra text printing (though that one is undergoing renovation at the moment). There's also imagic.lua, which can be used for drawing things like text boxes and speech bubbles should you want to.





- KittyTristy
- Coffee-Powered Kittygirl
- Posts: 4
- Joined: 2 years ago
- First name: Tristy
- Pronouns: she/her
- Location: USA
Re: LunaLua Help
Ah, okay. That makes sense. And thanks for the heads up and the info on the other plugins. I started poking around with textblox.lua before I read your reply and I was able to get it to work for my purposes, at least for now.Hoeloe wrote:It's been kept in for compatibility, but really you shouldn't be using it. There are some tools to do what it does in separate forms. The event scheduling is now part of eventu.lua, there's a simple "follower" script used by Bowser to replicate follower behaviour, pnpc.lua deals with keeping track of and modifying NPCs, and textblox.lua can deal with extra text printing (though that one is undergoing renovation at the moment). There's also imagic.lua, which can be used for drawing things like text boxes and speech bubbles should you want to.
My other issue at the moment is that LunaLua says Misc.pause() was added in 0.7.3, and it appears that's the same version included with SMBX 2.0, yet it doesn't seem to do anything? I tried looking at LunaLua's source code to see if I might figure out why.. but I don't have a whole lot of experience with C++..
- KittyTristy
- Coffee-Powered Kittygirl
- Posts: 4
- Joined: 2 years ago
- First name: Tristy
- Pronouns: she/her
- Location: USA
Re: LunaLua Help
Welp. Nevermind. It appears that part of the code in SMWcamera.lua was causing a conflict.KittyTristy wrote:My other issue at the moment is that LunaLua says Misc.pause() was added in 0.7.3, and it appears that's the same version included with SMBX 2.0, yet it doesn't seem to do anything? I tried looking at LunaLua's source code to see if I might figure out why.. but I don't have a whole lot of experience with C++..
- Camwood777
- oh man what
- Posts: 15
- Joined: 2 years ago
- First name: Cam
- Pronouns: he/him/his
- Location: the land of tong-nou
Re: LunaLua Help
For whatever reason, I can't get midpoints to work at all. I tried looking it up on the wiki, and it tells me to use multipoints.lua, so I guess it's a Lunalua thing.
At the same time, though, that raises more issues; Lunalua won't even open for me! It tells me to select a program... Can someone help me out here?
At the same time, though, that raises more issues; Lunalua won't even open for me! It tells me to select a program... Can someone help me out here?
also goes by "camwoodstock", "camwood", "cws", or some variant thereof
plays video games i think
plays video games i think
- ztarwuff
- What the heck is a flair and why am I being asked to write one for my profile?
- Posts: 542
- Joined: 5 years ago
- Location: Within 2 miles of the Imperial Crypt of Napoleon III
Re: LunaLua Help
Oh midpoints! Yes, midpoints are very easy.Camwood777 wrote:For whatever reason, I can't get midpoints to work at all. I tried looking it up on the wiki, and it tells me to use multipoints.lua, so I guess it's a Lunalua thing.
At the same time, though, that raises more issues; Lunalua won't even open for me! It tells me to select a program... Can someone help me out here?
The .lua files are basically just text documents. The notepad program that comes bundled with Windows can open them, but it's probably a better idea to get a free version of Notepad++. Notepad++ colour codes your lua code as you go along.
You'll need to create a .lua file called lunadll.lua in your level folder. Notepad doesn't give you the option, so you have to select all files, then type in lunadll.lua. NotePad++ however, does give you the option of saving as a .lua.
Here's a sample from one of my levels submitted to A2XT Episode 2:
Code: Select all
local multipoints = loadAPI("multipoints");
multipoints.addLuaCheckpoint(-19809, -20064, 9);
multipoints.addLuaCheckpoint(-199296, -200063, 0);
So in the above example, I have a midpoint in Section 10 and Section 1.
Re: LunaLua Help
But of an odd question. Is there a way to draw something behind the player without putting it on their sprite sheet? Basically I'd like to imitate how the cape animates in SMW on a custom character, so it can animate independently and be drawn regardless of powerup state.
Re: LunaLua Help
Absolutely! Take a look at the render priority system: http://wohlsoft.ru/pgewiki/LunaLua_Render_Priority
Certain functions in LunaLua allow you to supply a priority. Most priority levels are negative, and if you use a priority below the player (that's more negative than -25) when drawing with Lua, you can draw things behind the player.





Re: LunaLua Help
I want to make a level where things generate at random. There will be a total of 10 random screens generated horizontally before the flagpole and all pipes generated lead to a normal underground bonus section. When they come back up, the flagpole is there immediately.
Re: LunaLua Help
I've re-skinned Ludwig and would like to have him throw hammers instead of fireballs. I feel like a total dope, not knowing this when it seems basic.
A very shy ghost.
Return to “SMBX2 (Current - 2.0 Beta 3)”
Who is online
Users browsing this forum: No registered users and 1 guest