smbx communitypge projectmario fan games galaxy

happy birthday talkhaus!!!

LunaLua Help

User avatar
Horikawa Otane
The MaGL Goddess
Posts: 1441
Joined: 4 years ago
First name: Servalan
Location: The Last of the Babylon Stations

LunaLua Help

Postby Horikawa Otane » 9 months ago

If you need help with anything LunaLua related, ask it here!

Please do check the wiki though since it's pretty comprehensive!
Image
Watch my Butt on the YouTubes
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!

User avatar
Isrieri
Creatively Bankrupt
Posts: 49
Joined: 4 years ago
Location: Courtroom No.4

Re: LunaLua Help

Postby Isrieri » 8 months ago

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.

User avatar
Isrieri
Creatively Bankrupt
Posts: 49
Joined: 4 years ago
Location: Courtroom No.4

Re: LunaLua Help

Postby Isrieri » 8 months ago

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:

Image

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;

User avatar
Hoeloe
One of them Lua people
Posts: 824
Joined: 5 years ago
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 8 months ago

Isrieri wrote:registerEvent(properFirealls,"onTick","onTick")
Isrieri wrote:properFirealls
Isrieri wrote:Firealls
Isrieri wrote:alls
Be sure to check your spelling
Image
Image
Image
Image

User avatar
Isrieri
Creatively Bankrupt
Posts: 49
Joined: 4 years ago
Location: Courtroom No.4

Re: LunaLua Help

Postby Isrieri » 8 months ago

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.

User avatar
KittyTristy
Coffee-Powered Kittygirl
Posts: 4
Joined: 7 months ago
First name: Tristy
Pronouns: she/her
Location: USA

Re: LunaLua Help

Postby KittyTristy » 7 months ago

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?

User avatar
Hoeloe
One of them Lua people
Posts: 824
Joined: 5 years ago
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 7 months ago

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?
CinematX is very old and broken and never quite worked properly. It's really not recommended to even try using it.
Image
Image
Image
Image

User avatar
KittyTristy
Coffee-Powered Kittygirl
Posts: 4
Joined: 7 months ago
First name: Tristy
Pronouns: she/her
Location: USA

Re: LunaLua Help

Postby KittyTristy » 7 months ago

Hoeloe wrote:
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?
CinematX is very old and broken and never quite worked properly. It's really not recommended to even try using it.
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

User avatar
Hoeloe
One of them Lua people
Posts: 824
Joined: 5 years ago
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 7 months ago

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.
Image
Image
Image
Image

User avatar
KittyTristy
Coffee-Powered Kittygirl
Posts: 4
Joined: 7 months ago
First name: Tristy
Pronouns: she/her
Location: USA

Re: LunaLua Help

Postby KittyTristy » 7 months ago

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.
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.

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++..

User avatar
KittyTristy
Coffee-Powered Kittygirl
Posts: 4
Joined: 7 months ago
First name: Tristy
Pronouns: she/her
Location: USA

Re: LunaLua Help

Postby KittyTristy » 7 months ago

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++..
Welp. Nevermind. It appears that part of the code in SMWcamera.lua was causing a conflict.

User avatar
Camwood777
oh man what
Posts: 15
Joined: 9 months ago
First name: Cam
Pronouns: he/him/his
Location: the land of tong-nou

Re: LunaLua Help

Postby Camwood777 » 3 months ago

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?
also goes by "camwoodstock", "camwood", "cws", or some variant thereof
plays video games i think

User avatar
ztarwuff
What the heck is a flair and why am I being asked to write one for my profile?
Posts: 496
Joined: 4 years ago
Location: Within 2 miles of the Imperial Crypt of Napoleon III

Re: LunaLua Help

Postby ztarwuff » 3 months ago

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?
Oh midpoints! Yes, midpoints are very easy.

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);
You need the first line to load the Multipoints API. The third and fourth lines are the midpoints. The numbers in the brackets are your coordinates: X, Y and Section Number. You get the X and Y coordinates from the debugger. Just switch the debugger on, and hover your mouse over where you want the midpoint goes. Write down the coordinates the debugger gives you. The section number is always one less than the actual one.

So in the above example, I have a midpoint in Section 10 and Section 1.

User avatar
Tyty
Posts: 28
Joined: 7 years ago

Re: LunaLua Help

Postby Tyty » 3 months ago

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.

User avatar
Hoeloe
One of them Lua people
Posts: 824
Joined: 5 years ago
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 3 months ago

Tyty wrote: 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.
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.
Image
Image
Image
Image


Return to “SMBX2 (Current - 2.0 Beta 3)”

Who is online

Users browsing this forum: No registered users and 1 guest

cron