LunaDLL/LunaLUA help thread

The second SMBX collab!
Luigifan2010
Lua squad
Posts: 2
Joined: 8 years ago
First name: Mike
Pronouns: he/him/his
Location: United States

Re: LunaDLL help thread

Post by Luigifan2010 »

double posting because i had some extra thoughts on the death counts system, after playing around and peeking ind epth at the code i figured out what the numbers meant and the downfalls of the system.

first of all, that "total" is on a global basis and this can get kind of annoying. afaik there isn't a way to reset it for a new save so you're kind of just stuck with that. actually, the death counter in general is on a global basis, and honestly i feel like that kind of breaks it. starting a new save loads existing deaths.

the solution? there's gotta be a hex value of sorts that can be read from that contains the path of the levels you'll be reading from. thats where we put our .dmo files. and isntead of it just being demo.dmo, make it save1.dmo save2.dmo etc (there's also gotta be a way to get the current save, its gotta expose that string at some point to write to it/read from it). that way, the two values remain on a per episode basis.

thats not to say we still can't have the globally defined one, we could in fact have 3 numbers if we really wanted to though that would just confuse new players even more. i'm going to try and play around with this and see if i can't find any predefined things and maybe get this system working
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

Are you using VS2013 though? Anything higher than VS2010 is incredibly awful in my experience. I mean the only reason I even use VS is because the IDE has some helpful highlighting and function autocomplete/lookup stuff going on, and... VS2012/13 don't have anything of that, and have awful interfaces.

Yeah you're gonna need winmm for that playsound command. You're probably the 3rd person ever to compile lunadll so I forgot all about that. All it does is shell out the command to Windows.

You're compiling with optimization off right? Optimization breaks the whole thing afaik, for whatever reason. I did some tracing of the asm output and the optimizations tend to optimize out my reads from smbx global memory, again for whatever reason.

For the death counter I wasn't really concerned about any of that stuff much because it was just supposed to be for raocow's a2mbxt LP. Nothing too serious, and I threw it together pretty fast, without getting too embroiled in what's going on with the SMBX save system. The counter is supposed to be off by default but since the only people really using lunadll right now are a2mbxt participants I just left it on. You could probably figure out some way to detect the save and save in the proper folder and filename, but I didn't look into it much, and the .dmo file format is very barebones at the moment. By the way that source is not really up to date. Here's the latest beta I'm working on but I'm in the middle of adding custom sprite framework stuff so I can't guarantee huge debug text won't pop up that I've forgotten to delete http://www.gamearchaeology.com/LunaDllPackage.zip

As for injecting the dll, I wouldn't recommend doing that into a new version of smbx. It took me about 2-3 hours each time (once for a2mbxt.exe and once for smbx.exe) since I had to manually modify the DLL import table of smbx.exe, and then go and painstakingly add the 3 calls from SMBX to lunadll in assembly language.

Those calls hacked into smbx are
- OnlvlLoad (Calls LunaDLL once as a level is loaded, including title screen level)
- TestFunc (Calls LunaDLL just before smbx processes a frame)
- HudHook (Calls LunaDLL every time the HUD is drawn. Can also overwrite the return address to skip drawing the SMBX HUD)
DON'T PM me. Ask your question in the help thread so everyone can be answered.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

EDIT: I made it trigger a set screen boundary event in #3 and it worked! Thank you!!!
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

TiKi wrote:EDIT: I made it trigger a set screen boundary event in #3 and it worked! Thank you!!!
New version I just uploaded has SnapSectionBounds which you could also use to set the camera to just one screen by the way

Code: Select all

// cmd name    section  X      Y
SnapSectionBounds,1,-200000,-200000,0,1,0
DON'T PM me. Ask your question in the help thread so everyone can be answered.
Luigifan2010
Lua squad
Posts: 2
Joined: 8 years ago
First name: Mike
Pronouns: he/him/his
Location: United States

Re: LunaDLL help thread

Post by Luigifan2010 »

Kil wrote:Are you using VS2013 though? Anything higher than VS2010 is incredibly awful in my experience. I mean the only reason I even use VS is because the IDE has some helpful highlighting and function autocomplete/lookup stuff going on, and... VS2012/13 don't have anything of that, and have awful interfaces.
I'm using VS2013 yes, as I said before 2010 Express kept crashing on me whenever I tried to compile :/
Yeah you're gonna need winmm for that playsound command. You're probably the 3rd person ever to compile lunadll so I forgot all about that. All it does is shell out the command to Windows.
Good to note ;)
You're compiling with optimization off right? Optimization breaks the whole thing afaik, for whatever reason. I did some tracing of the asm output and the optimizations tend to optimize out my reads from smbx global memory, again for whatever reason.
Pretty sure
For the death counter I wasn't really concerned about any of that stuff much because it was just supposed to be for raocow's a2mbxt LP. Nothing too serious, and I threw it together pretty fast, without getting too embroiled in what's going on with the SMBX save system. The counter is supposed to be off by default but since the only people really using lunadll right now are a2mbxt participants I just left it on. You could probably figure out some way to detect the save and save in the proper folder and filename, but I didn't look into it much, and the .dmo file format is very barebones at the moment. By the way that source is not really up to date. Here's the latest beta I'm working on but I'm in the middle of adding custom sprite framework stuff so I can't guarantee huge debug text won't pop up that I've forgotten to delete http://www.gamearchaeology.com/LunaDllPackage.zip
The death counter is genius imo, so in my version I enabled it by default. I'll check that source btw, if it breaks on me I'll wait for you to finish up this version before I continue doing whatever.
As for injecting the dll, I wouldn't recommend doing that into a new version of smbx. It took me about 2-3 hours each time (once for a2mbxt.exe and once for smbx.exe) since I had to manually modify the DLL import table of smbx.exe, and then go and painstakingly add the 3 calls from SMBX to lunadll in assembly language.

Those calls hacked into smbx are
- OnlvlLoad (Calls LunaDLL once as a level is loaded, including title screen level)
- TestFunc (Calls LunaDLL just before smbx processes a frame)
- HudHook (Calls LunaDLL every time the HUD is drawn. Can also overwrite the return address to skip drawing the SMBX HUD)
Yikes, and I don't know any asm but this is a good note. Maybe one day I'll take a look at it. Thank you again ;)

Speaking of which, I was going to try and modify the demo coutner to at least save/load per episode but the way it works, it sets its directory once at startup and that's it so it would take alot of modifications probably.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

The new version interrupts the HUD?
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

use this

LunaControl,2,1,0,0,0,0
Last edited by Kil 8 years ago, edited 1 time in total.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

Oh, you meant the DEMOS counter? I thought you meant the actual HUD. Thanks anyways! I'll post this to the SMBX forum.
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

That is for the actual HUD

Actually I was wrong, it's this LunaControl,2,1,0,0,0,0
DON'T PM me. Ask your question in the help thread so everyone can be answered.
User avatar
Mabel
Just west of wierd
Posts: 299
Joined: 9 years ago
https://marbels.talkhaus.com/

Re: LunaDLL help thread

Post by Mabel »

so heres that slightly expanded drown thingy, problem is while it still works, I cant get any of the custom sounds to play, maybe im missing something super obvious again...

Code: Select all

#-1
// reset drown counter
SetVar,0,0,0,0,1,MyDrownCounter


#0
// -> #1000 if in water
OnPlayerMem,0x34,2,0,1000,0,w

// -> #1001 if not in water
OnPlayerMem,0x34,0,0,1001,0,w


#1000
// underwater so add to counter
SetVar,0,1,1,0,1,MyDrownCounter

// Warning timer and sounds begin playing the longer you stay in the water
IfVar,0,1,600,1003,1,MyDrownCounter



#1001

// reset counter when out of water
SetVar,0,0,0,0,1,MyDrownCounter


#1002

// Final kill event when counter is too high
Kill,0,0,0,0,1,0



// also reset counter
SetVar,0,0,0,0,1,MyDrownCounter


#1003
//warning timer starts
IfVar,0,1,900,1004,1,MyDrownCounter
SFX,0,0,0,0,1,drownwarning.wav

#1004
//warning timer starts
IfVar,0,1,1200,1005,1,MyDrownCounter
SFX,0,0,0,0,1,drownwarning.wav

#1005
//warning timer starts
IfVar,0,1,1500,1006,1,MyDrownCounter
SFX,0,0,0,0,1,drownwarning.wav

#1006
//warning timer starts
IfVar,0,1,1800,1002,1,MyDrownCounter
SFX,0,0,0,0,1,drown.wav

#END
Image
Image
Image Image
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

They are playing but they're being played every frame so fast that they don't get a chance to start.

The start of the chain you have going here is IfVar,0,1,600,1003,1,MyDrownCounter which means
"whenever drown counter is above 600". Once it's above 600, this goes off constantly. All of the others go off constantly too, when they're above 1000 and such, making the sound play and cancel really really fast. You only want the sound to play once, when your counter reaches a very specific value in the counter. You can check for that using the equals operator


I tested this and it seems to work

Code: Select all

// DROWN STUFF
#-1
// reset drown counter
SetVar,0,0,0,0,1,MyDrownCounter


#0
// -> #1000 if in water
OnPlayerMem,0x34,2,0,1000,0,w

// -> #1001 if not in water
OnPlayerMem,0x34,0,0,1001,0,w


// UNDERWATER EVENT - Add to counter and check specific values
#1000
SetVar,0,1,1,0,1,MyDrownCounter

// Play the warning sound (#2000) when the counter reaches exact values
IfVar,0,0,600,2000,1,MyDrownCounter
IfVar,0,0,900,2000,1,MyDrownCounter
IfVar,0,0,1200,2000,1,MyDrownCounter
IfVar,0,0,1500,2000,1,MyDrownCounter

// The actual kill event when it reaches 1800 + drown sound
IfVar,0,0,1800,2001,1,MyDrownCounter


// OUT OF WATER EVENT - Reset counter
#1001
SetVar,0,0,0,0,1,MyDrownCounter


#2000
// They all point to here
SFX,0,0,0,0,1,drownwarning.wav


#2001
// Final kill event when counter is too high
Kill,0,0,0,0,1,0

// also reset counter
SetVar,0,0,0,0,1,MyDrownCounter

// drown sound
SFX,0,0,0,0,1,drown.wav


#END
DON'T PM me. Ask your question in the help thread so everyone can be answered.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

Not working sorry
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

TiKi wrote:Not working sorry
Did you download the new dll? it works for me.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

I thought I downloaded it. Could I please have a relink?
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

DON'T PM me. Ask your question in the help thread so everyone can be answered.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

Isn't that the April version?
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

I updated it yesterday on 8/10
DON'T PM me. Ask your question in the help thread so everyone can be answered.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

Redowloaded but it's still not working. Could you please upload the level you're testing this in?
User avatar
Mabel
Just west of wierd
Posts: 299
Joined: 9 years ago
https://marbels.talkhaus.com/

Re: LunaDLL help thread

Post by Mabel »

Its working for me, but of course im not done wanting to add more things to it.

Tried to add and IfNPC that also resets the counter with a coin, buuuut once you actually grab the coin the game...melted into an explosion of perma lag and only pressing esc stopped it(playing from the editor)
Image
Image
Image Image
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

TiKi wrote:Redowloaded but it's still not working. Could you please upload the level you're testing this in?
I mean it's just an empty room I'm testing in. You sure you're using LunaControl,2,1,0,0,0,0 starting with 2,1?
DON'T PM me. Ask your question in the help thread so everyone can be answered.
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

Mabel wrote:Its working for me, but of course im not done wanting to add more things to it.

Tried to add and IfNPC that also resets the counter with a coin, buuuut once you actually grab the coin the game...melted into an explosion of perma lag and only pressing esc stopped it(playing from the editor)
It sounds like you accidentally made an infinite loop, or are activating an event with infinite length more than once. Also if you're going to use coins, the weakness of IfNPC is that it only really works if you have 1 of that NPC in the whole level, which sucks.

You could also try building a coin sensor thing with a new command I made recently, to compare if your coins from last frame are higher than your coins in the current frame, and if they are, that means the player got an extra coin, and to reset the air counter.

This is going to look complicated, but what you're trying to do is pretty complicated as well

Code: Select all

// LEVEL LOADING
#-1
// Reset drown counter
SetVar,0,0,0,0,1,MyDrownCounter

// Make 2 custom variables, "CurrentCoins" and "PreviousCoins"
$CurrentCoins,SetVar,0,0,0,0,1,0
$PreviousCoins,SetVar,0,0,0,0,1,0


// MAIN CODE
#0
// -> #1000 if in water
OnPlayerMem,0x34,2,0,1000,0,w

// -> #1001 if not in water
OnPlayerMem,0x34,0,0,1001,0,w

// Load current coin count into variable "CurrentCoins"
$CurrentCoins,LoadGlobalVar,0x00B2C5A8,0,0,0,0,w

// Compare if current coins is greater than previous coins (if so, activate #1001)
$CurrentCoins,CompareVar,0,1,0,1001,0,PreviousCoins

// Don't forget to update PreviousCoins now after the check
$PreviousCoins,LoadGlobalVar,0x00B2C5A8,0,0,0,0,w

// This will show all variables for educational purposes - DELETE WHEN DONE
$MyDrownCounter,ShowVar,0,300,300,3,0,DROWN CT -
$CurrentCoins,ShowVar,0,300,320,3,0,CUR -
$PreviousCoins,ShowVar,0,300,340,3,0,PREV -


// UNDERWATER EVENT - Add to counter and check specific values
#1000
SetVar,0,1,1,0,1,MyDrownCounter

// Play the warning sound (#2000) when the counter reaches exact values
IfVar,0,0,600,2000,1,MyDrownCounter
IfVar,0,0,900,2000,1,MyDrownCounter
IfVar,0,0,1200,2000,1,MyDrownCounter
IfVar,0,0,1500,2000,1,MyDrownCounter

// The actual kill event when it reaches 1800 + drown sound
IfVar,0,0,1800,2001,1,MyDrownCounter


// OUT OF WATER / COIN COLLECTED - Reset counter
#1001
SetVar,0,0,0,0,1,MyDrownCounter


// SFX EVENT - They all point here
#2000
SFX,0,0,0,0,1,drownwarning.wav


// FINAL KILL EVENT
#2001
Kill,0,0,0,0,1,0

// also reset counter
SetVar,0,0,0,0,1,MyDrownCounter

// drown sound
SFX,0,0,0,0,1,drown.wav


#END
Although it won't work until you update lunadll.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
User avatar
Mabel
Just west of wierd
Posts: 299
Joined: 9 years ago
https://marbels.talkhaus.com/

Re: LunaDLL help thread

Post by Mabel »

Perfect. Although this means that any coin will reset the counter instead of a specific one .
Image
Image
Image Image
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

Do I need to type "#1" and "#END"? I tried that too.
Kil
Posts: 13
Joined: 13 years ago

Re: LunaDLL help thread

Post by Kil »

Well you're doing something wrong because as you can see the hud is gone

https://www.youtube.com/watch?v=gJItFwf ... e=youtu.be
DON'T PM me. Ask your question in the help thread so everyone can be answered.
TiKi
Posts: 690
Joined: 9 years ago

Re: LunaDLL help thread

Post by TiKi »

Here's the level I'm testing in:
http://speedy.sh/scDWR/A-Spongy-Story.zip
Post Reply