LunaLua Offical Thread

The second SMBX collab!

Shall I stream some LunaLua live development?

Yes
23
92%
No
2
8%
 
Total votes: 25

User avatar
romajiQuadhash
typos "raocow" as "roacow" (and I TAS)
Posts: 12
Joined: 8 years ago
First name: Romaji Quadhash
Pronouns: ke/keh/ker
Location: ""Canada""

Re: Presenting: Lunadll for Lua!

Post by romajiQuadhash »

Rednaxela wrote:
romajiQuadhash wrote:]I tryed running that. Should I do it again?
If you already installed that trying again likely won't do anything. Just to check... if you go to 'start game' when you run smbx.exe, does the title screen show something like this in the top left?
Nope. It doesn't.
Does it show up on the A2XT version also?
Since that's the only version I run
This is a sig
User avatar
romajiQuadhash
typos "raocow" as "roacow" (and I TAS)
Posts: 12
Joined: 8 years ago
First name: Romaji Quadhash
Pronouns: ke/keh/ker
Location: ""Canada""

Re: Presenting: Lunadll for Lua!

Post by romajiQuadhash »

This is a sig
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 9 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

romajiQuadhash wrote:Here's a .zpaq with my entire A2XT main game file inside
This can be opened using PeaZip
Heh, way to make it a pain with zpaq. Btw, PeaZip didn't want to read this file, it thought it was empty. I managed to extract it with zpaq64.exe instead though, which only wanted to extract by absolute path. Sure was a hassle...

Anyway, LunaLua didn't work in your installation there as-is... but it started working if I simply extracted the latest version of LunaDLL from the link in the first page of this thread into your "Main Game" directory. :roll:
User avatar
romajiQuadhash
typos "raocow" as "roacow" (and I TAS)
Posts: 12
Joined: 8 years ago
First name: Romaji Quadhash
Pronouns: ke/keh/ker
Location: ""Canada""

Re: Presenting: Lunadll for Lua!

Post by romajiQuadhash »

Rednaxela wrote:
romajiQuadhash wrote:Here's a .zpaq with my entire A2XT main game file inside
This can be opened using PeaZip
Heh, way to make it a pain with zpaq. Btw, PeaZip didn't want to read this file, it thought it was empty. I managed to extract it with zpaq64.exe instead though, which only wanted to extract by absolute path. Sure was a hassle...

Anyway, LunaLua didn't work in your installation there as-is... but it started working if I simply extracted the latest version of LunaDLL from the link in the first page of this thread into your "Main Game" directory. :roll:
I copmressed it with that to make the file size small. Didn't work, huh?
Which link? I tried extracting stuff from a link on the first page of the thread, but which one should I instal?
This is a sig
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 9 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

romajiQuadhash wrote:I copmressed it with that to make the file size small. Didn't work, huh?
Which link? I tried extracting stuff from a link on the first page of the thread, but which one should I instal?
The "Download SDL version" link is the only one I needed to unzip into your installation to make it work.

You may also need "Visual C++ Redistributable Packages for Visual Studio 2013", or you may not, it depends.
User avatar
romajiQuadhash
typos "raocow" as "roacow" (and I TAS)
Posts: 12
Joined: 8 years ago
First name: Romaji Quadhash
Pronouns: ke/keh/ker
Location: ""Canada""

Re: Presenting: Lunadll for Lua!

Post by romajiQuadhash »

Rednaxela wrote:
romajiQuadhash wrote:I copmressed it with that to make the file size small. Didn't work, huh?
Which link? I tried extracting stuff from a link on the first page of the thread, but which one should I instal?
The "Download SDL version" link is the only one I needed to unzip into your installation to make it work.

You may also need "Visual C++ Redistributable Packages for Visual Studio 2013", or you may not, it depends.
Oh. Woops.
This is a sig
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

I'm having some issues updating my Multipoints library. I've set it up to use the new Data and Event systems, but now it's crashing when I run the example level.

I did some debugging, and it initialises the checkpoints correctly, but then SMBX stops responding before it tries to call anything else. It gets through onInitAPI fine, and my checkpoint initialiser (twice, as it should), but doesn't ever touch any of the other functions - it just stops responding. I thought this might be to do with using onEvent in an API, but having commented out that code, it still seems to crash. I'll have to look into it in more detail, but the results I'm getting from debugging don't make any sense.

I put a windowDebug statement at the start of every function, and the result I get is:

onInitAPI
addCheckpoint
addCheckpoint

Crash.

But I also put a windowDebug at the end of addCheckpoint, and that ran fine, too.

EDIT: Okay, this is a rather big issue. It breaks the old version of Multipoints too, with the same bug. It looks like the API system might be broken.
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Updated to LunaLua v0.6.0.3 fixing a serious issue.

Events should now work again properly without problems!
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

And a new version of Multipoints is out that requires the new fixed version of LunaLua. It no longer needs the Triggers library to operate properly!
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 9 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Just noticed you were updating the NPC struct Kev, and have a few little corrections:

The "Unknown decrementing timer" comment should be on 0x06, not 0x08

Code: Select all

short unknown_A8; //+0xA8
short unknown_AA; //+0xAA
double spawnX; //+0xAC
float spawnY; //+0xB4 NOTE: In the wiki we have double noted, but it does not match with the 8-Byte
Should be:

Code: Select all

double spawnX; //+0xA8
double spawnY; //+0xB0
(I fixed this one on the Wiki just now)

Code: Select all

short unknown_148; //+0x148
short unknown_14A; //+0x14A
is known to be

Code: Select all

float hitCount; //+0x148
(Wiki labeled the row unknown even when it had the description, just fixed that)
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

New library get!

Colliders.lua is a library designed to make collision testing a lot simpler. It has two functions for primary use, "collide" and "speedCollide". The first of these will test if two objects are touching (and will work for Players, NPCs, or custom collision boxes as you see fit). The second will use the object's speed values to calculate if the two objects will collide next frame. This is useful if you want to override the behaviour SMBX would normally use when these two objects collide (an example of this is making Boos killable with fireballs. Using regular collisions will cause the Boo to kill the fireball before the code is registered, but using speedCollide, the Lua code executes first).
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 9 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Hah, funny timing. Just yesterday I threw together custom collision detection for my MaGL X2 level, though in my case it's just the limited to "caller-specified rectangle collides with any on-screen NPC that damages players" with some performance optimizations specific to that case.

Much more generally useful thing you have there.
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rednaxela wrote: Much more generally useful thing you have there.
Though I curse Lua's lack of typing. Getting the same function to work for multiple types was awkward, I had to manually do some checks to determine the type of an object (I believe one of my tests was "does it have a field called "powerup"? Then it's a player").
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 9 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Hoeloe wrote:
Rednaxela wrote:Much more generally useful thing you have there.
Though I curse Lua's lack of typing. Getting the same function to work for multiple types was awkward, I had to manually do some checks to determine the type of an object (I believe one of my tests was "does it have a field called "powerup"? Then it's a player").
Though, that type of check does mean it'll seamlessly work with pNPC objects with no fuss, which could be a nice combination for some cases, hah.
Onule
Posts: 3
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Post by Onule »

Hoeloe wrote:This is useful if you want to override the behaviour SMBX would normally use when these two objects collide
So it would be possible to make a fully working starman?

Also, I think the new version of multipoint on the PGE wiki is missing the library file itself. :?:
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rednaxela wrote:
Hoeloe wrote:
Rednaxela wrote:Much more generally useful thing you have there.
Though I curse Lua's lack of typing. Getting the same function to work for multiple types was awkward, I had to manually do some checks to determine the type of an object (I believe one of my tests was "does it have a field called "powerup"? Then it's a player").
Though, that type of check does mean it'll seamlessly work with pNPC objects with no fuss, which could be a nice combination for some cases, hah.
Should do. I believe the NPC only makes use of the id, x and y fields, and the mem function.
Onule wrote:
Hoeloe wrote:This is useful if you want to override the behaviour SMBX would normally use when these two objects collide
So it would be possible to make a fully working starman?

Also, I think the new version of multipoint on the PGE wiki is missing the library file itself. :?:
Yep. Quite easily, actually. It should be just this (though this will destroy powerups, coins, midpoints, etc. so you may want to filter that):

Code: Select all

function onLoop()
	for _,v in pairs(findnpcs(-1,player.section)) do
		if(colliders.speedCollide(player,v)) then
			v:kill();
		end
	end
end
Also, oops. That's totally possible. Will rectify momentarily.

EDIT: Done. Should be there now.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 9 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

Hoeloe wrote:
Onule wrote:
Hoeloe wrote:This is useful if you want to override the behaviour SMBX would normally use when these two objects collide
So it would be possible to make a fully working starman?
Yep. Quite easily, actually. It should be just this (though this will destroy powerups, coins, midpoints, etc. so you may want to filter that):

Code: Select all

function onLoop()
	for _,v in pairs(findnpcs(-1,player.section)) do
		if(colliders.speedCollide(player,v)) then
			v:kill();
		end
	end
end
For the case of making a starman, I'd also suggest including something like

Code: Select all

player:mem(0x140, FIELD_WORD, 2) -- Invincibility frames
player:mem(0x142, FIELD_WORD, 0) -- Don't blink invisible
As a just-in-case measure to ensure the player is truly invincible during that time even to something you may filter out of getting destroyed.

Hmm... It's a shame the memory region where a player character's level-specific spritesheet is loaded isn't well-known... because if that was it might be possible to implement starman player sprite animation (well... I mean one could always use loadImage/placeSprite, but that doesn't layer the same way as the player sprite does normally...)
User avatar
romajiQuadhash
typos "raocow" as "roacow" (and I TAS)
Posts: 12
Joined: 8 years ago
First name: Romaji Quadhash
Pronouns: ke/keh/ker
Location: ""Canada""

Re: Presenting: Lunadll for Lua!

Post by romajiQuadhash »

So, I installed everything that people on the thread suggested, and I'm still not getting the LunaLua version text to show up.
Any other suggestions?
Maybe I can just download someone else's Main Game?
This is a sig
TiKi
Posts: 690
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by TiKi »

1. Please add this offset as a variable like PlayerIsFast. So others can use it. It's the Sonicstooslow variable, and 0xFFFF = on I think.
0x00B2C8AE
2. Is there an easy way to make all NPCs act like they're underwater with lua? If so could you please post the whole code for just that? Thanks.

RE: npc movement: try multiplying by 0 instead of setting. I couldn't multiply something in auto code by 0.5 to make it fall slower but I could divide by 2. So it can be finicky.
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

TiKi wrote:I couldn't multiply something in auto code by 0.5 to make it fall slower but I could divide by 2. So it can be finicky.
I think that's just a weirdness of autocode's syntax. It will be fine doing either in Lua.
Image
Image
Image
Image
Image
User avatar
Lejes
Posts: 78
Joined: 9 years ago
https://lejes.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Lejes »

Can someone explain how to use onEvent()? I thought the argument to this function would just be the event name in quotes, but the error message is saying it expects something else.
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Lejes wrote:Can someone explain how to use onEvent()? I thought the argument to this function would just be the event name in quotes, but the error message is saying it expects something else.
That should be exactly what it is. Can you post the error message, and your code?
Image
Image
Image
Image
Image
User avatar
Lejes
Posts: 78
Joined: 9 years ago
https://lejes.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Lejes »

Code: Select all

function onEvent("Starman Get")
	starman = true;
end
Image
User avatar
Hoeloe
A2XT person
Posts: 962
Joined: 11 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Lejes wrote:

Code: Select all

function onEvent("Starman Get")
	starman = true;
end
Image
Ah. That's not how function arguments work at all. Function arguments are variables, and you need to test their values, like this:

Code: Select all

function onEvent(event)
	if(event == "Starman Get") then
		starman = true;
	end
end
I think there's a bit of an explanation of this on the basic tutorials on the wiki.
Image
Image
Image
Image
Image
User avatar
romajiQuadhash
typos "raocow" as "roacow" (and I TAS)
Posts: 12
Joined: 8 years ago
First name: Romaji Quadhash
Pronouns: ke/keh/ker
Location: ""Canada""

Re: Presenting: Lunadll for Lua!

Post by romajiQuadhash »

Hoeloe wrote:
Lejes wrote:

Code: Select all

function onEvent("Starman Get")
	starman = true;
end
Image
Ah. That's not how function arguments work at all. Function arguments are variables, and you need to test their values, like this:

Code: Select all

function onEvent(event)
	if(event == "Starman Get") then
		starman = true;
	end
end
I think there's a bit of an explanation of this on the basic tutorials on the wiki.
Or, to put it another way, this isn't Haskall.
This is a sig
Post Reply