(shouting)

LunaLua Offical Thread

The second SMBX collab!
Post Reply

Shall I stream some LunaLua live development?

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

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

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

I've compiled my trigger system into a relatively easy-to-manage library file! Now, you only need to use two functions, one to create the Trigger data structure, and the other to test for the triggers. With a tiny bit of setting up in SMBX, you can easily create events that trigger Lua code!

Download Trigger Library
Image
Image
Image
Image
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Okay, I've done a definitive test.

onLoadSection#() does not work. At all.

Also, in the cinematX library, it seems that the first line of the anonymous function runs, but the rest doesn't. This is really quite odd.

EDIT: Okay, it's not the first line, but most functions seem to be completely ignored, including the "wait for seconds", "walk right" and "play music" functions. I suspect this is to do with me just using the runCoroutine function, rather than runProcess, as all the other examples do, but runProcess seems to never be defined...
Image
Image
Image
Image
Image
KingTwelveSixteen
? Title Title Title Title ?
Posts: 30
Joined: 14 years ago
Location: USA

Re: Presenting: Lunadll for Lua!

Post by KingTwelveSixteen »

Hoeloe wrote:Okay, I've done a definitive test.

onLoadSection#() does not work. At all.
Really? It seems to work fine for me.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

KingTwelveSixteen wrote:
Hoeloe wrote:Okay, I've done a definitive test.

onLoadSection#() does not work. At all.
Really? It seems to work fine for me.

Code: Select all

function onLoadSection0()
    player.powerup = 2;
end
Does nothing.

Code: Select all

function onLoad()
    player.powerup = 2;
end
Makes the player big.

(I have also tried onLoadSection1, too).
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Hoeloe wrote:onLoadSection#() does not work. At all.
Yea just tested it too. It might broke after I added lunaworld.lua. I'll have a look tomorrow.
In the meanwhile use my fast written script (might have some bugs)

Code: Select all

oldsection = -1
function onLoad()
    oldsection = -1
end

function onLoop()
    playerSection = player:mem(0x15A, FIELD_WORD)
    if(playerSection ~= oldsection)then
        if(_G["onLoadSection"..tostring(playerSection)])
            _G["onLoadSection"..tostring(playerSection)]()
        end
        oldsection = playerSection
    end
end

KingTwelveSixteen
? Title Title Title Title ?
Posts: 30
Joined: 14 years ago
Location: USA

Re: Presenting: Lunadll for Lua!

Post by KingTwelveSixteen »

???

This entire code works for me.

Code: Select all

--SPACE JUMP--
function onLoadSection1()
gravity(4)
jumpheight(35)
end



--WIND TUNNEL--
function onLoadSection2()
resetJumpDefaults() --reset these because of space jump section
windTimer = 300
SMBMushroomNPCs = findnpcs(184, 2)
topScreenNPCMarker = SMBMushroomNPCs[0] --SMB shroom marks top of screen area
topScreenY = topScreenNPCMarker.y - 90 --save to variable. Move 90 pixels up.
end
function onLoopSection2()
windTimer = windTimer + 1 --increment wind counter

--Do wind stuff
if(windTimer < 150) then
	player.speedY = -3
	--Kill player if they fall off top of screen when windy
	if(topScreenY - 90 > player.y) then
	windTimer = 401 --prevents code from executing after death
	player:kill() 
	end
end
--Reset wind stuff
if(windTimer == 400) then
	windTimer = 0
end
end



--BUNNY HOP--
function onLoadSection3()
bunniesHopTimer = 0
end
function onLoopSection3()
bunniesHopTimer = bunniesHopTimer + 1
if(bunniesHopTimer == 100) then
	bunniesHopTimer = 0
	bigBunnies = findnpcs(162, 3) --Find all big bunnies (Rex). Small ones can't hop.
	--a for loop, goes through each bunny in the section
	for bunnies, bunny in pairs(bigBunnies) do
		bunny.speedY = -5 --this bunny hops!
	end
end
function onJumpEnd(playerIndex)
	player.speedY = -15
end
end




function resetJumpDefaults()
gravity(12)
jumpheight(20)
end
Important note: in SMBX editor section 2 is the one with space-jump, and so on.
It's slightly dumb like that.

EDIT: This code looks much prettier in notepad++ with all the different colors. :?
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Do you have lunaworld.lua installed in your game?
KingTwelveSixteen wrote: Important note: in SMBX editor section 2 is the one with space-jump, and so on.
It's slightly dumb like that.
This is because SMBX sections are 1-indexed, while LunaLua is 0-indexed. onLoadSection0 should do it for section 1.
Image
Image
Image
Image
Image
KingTwelveSixteen
? Title Title Title Title ?
Posts: 30
Joined: 14 years ago
Location: USA

Re: Presenting: Lunadll for Lua!

Post by KingTwelveSixteen »

Hoeloe wrote:Do you have lunaworld.lua installed in your game?
Huh. No, I don't.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

KingTwelveSixteen wrote:
Hoeloe wrote:Do you have lunaworld.lua installed in your game?
Huh. No, I don't.
Ah. I do, and apparently this is causing the problem.
Image
Image
Image
Image
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1858
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

Argh, I've been doing a horrible job of keeping up with things this weekend, and I don't really have any good excuses for that especially considering I was more or less stuck in my room all day yesterday for reasons I'd rather not talk about.

runProcess is runCoroutine, I changed the name for some stupid reason and didn't fix all the broken references because I kept jumping around with all the different things... man, I have been super-disorganized in my efforts to make this stuff more organized >_<

I'm still working on fixing all the issues you've been mentioning, Hoeloe. I cannot apologize enough for how disastrously broken my code has become. In the meantime, has anyone gotten the old pastebin of the Broadsword script work without the other scripts? No lunaworld, no cinematX or modified lapi, just that LunaDLL file + the images, npc codes and level file?
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to discuss Demo games and follow their development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rockythechao wrote: I'm still working on fixing all the issues you've been mentioning, Hoeloe. I cannot apologize enough for how disastrously broken my code has become. In the meantime, has anyone gotten the old pastebin of the Broadsword script work without the other scripts? No lunaworld, no cinematX or modified lapi, just that LunaDLL file + the images, npc codes and level file?
Yeah, I had that one mostly working other than freezing the player, it was just super messy to use.


EDIT: Okay, done a little more digging into cinematX, and it looks like the "waitSeconds" command doesn't work, and just halts the coroutine.

I might see if I can compile together a version that doesn't use coroutines.

EDIT EDIT: Oh. No wonder it doesn't work. None of the functions are actually there. It looks like startDialog has no definition, and neither do any of the NPC functions. That might explain why I can't get anything to actually happen. The odd thing is that when I have functions that clearly don't exist, it doesn't throw any errors, suggesting it's not even attempting to run them...

I think there are a lot of bugs in lunaworld. I'd suggest trying to reconstruct both from scratch, with as much code put into the cinematX library as possible.
Image
Image
Image
Image
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1858
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

I did it, I finally got the coroutines working... well, the waitSeconds command, anyway. I had the current and previous frame variables swapped in the timing update. It was counting backwards. >_<

But, uh, yeah, just uploaded the current version of cinematX and the broadsword level's lunadll.lua to the drive folder.
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to discuss Demo games and follow their development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rockythechao wrote:I did it, I finally got the coroutines working... well, the waitSeconds command, anyway. I had the current and previous frame variables swapped in the timing update. It was counting backwards. >_<

But, uh, yeah, just uploaded the current version of cinematX and the broadsword level's lunadll.lua to the drive folder.
WaitSeconds still doesn't seem to be working. I have a function called "beginCutscene" that places a sprite on the screen. If I have it as the first call in the coroutine, it's fine. If I call waitSeconds first, it never appears.

It seems that "deltaTime" is always returning 0. This seems extremely odd.

Ah, hold on, it seems to be recording time in seconds, which means deltaTime is 0 most of the time, and 1 once per second. Apparently this is all that is supported by Lua, though. I'm not sure why this isn't working for me.

EDIT: Fixed it! Just had the wrong identifier for cinematX.


Oh, I also seem to be getting an irrevocable print of "Augustus Leopold Braodsword Esq. III" at the bottom of my screen, for no readily apparent reason.


One more thing - even after deleting lunaworld.lua, onLoadSection# still does not work.


EDIT: Okay, found a couple of bugs in cinematX, where variables are referred to without the identifier "cinematX", which messes up a lot of the code. I've currently got it displaying some text, but it's not quite working right...

EDIT: Next bug - you test textTime, and stop displaying text if it's 0, but that's the timer counting how long text takes to appear, meaning it will disappear after the text has finished the typewriter effect.

My current stage is that the text does not show in the typewriter effect, but all at once, and cannot be progressed with X.

EDIT: Okay, pressing X can now progress dialogue. The issue is that it... doesn't quite work. Progressing dialogue moves it immediately to the last section of dialogue, skipping out all the rest in between.

EDIT: Fixed that. Now just the typewriter effect to go!

Almost there. For some reason it's only displaying the first "dialogTime" characters. In my case, 30.
Image
Image
Image
Image
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Done! I've managed to run my cutscene (without NPC animation or movement yet), and it all works.

I will note that I haven't tested things like boss functionality, so it's perfectly possible that I've broken that horribly. A lot of the problems seemed to be that the variable dialogTextTime seems to have changed its purpose slightly, so old code using it broke horrifically. Here's my altered version. Feel free to rip it apart or ignore it entirely:

https://dl.dropboxusercontent.com/u/308 ... nematX.lua

Once the animation and NPC controls work, I'll try and get a video together demonstrating part of the level I'm building with this.
Image
Image
Image
Image
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

I've had a thought about disabling player input.

You can, in SMBX, force the player to be pressing a certain button via events. While doing this, the player's controls are frozen. The reason we can't use this directly is that it prevents the LunaDLL onKeyDown function from working (and thus prevents you from continuing cutscenes).

However, it may be possible to trace back to where this function is called, and find how SMBX disables keyboard input. From there, it might be possible to disable all keys except the run key (used to progress text), and thus freeze the player's movement. Just a thought.
Image
Image
Image
Image
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1858
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

Oh, thanks, I'll see about merging the two versions! Does this incorporate your own message box stuff with showSprite?

The Augstus Leopold etc etc thing is the boss name. At first I thought it was stuck in boss mode for some reason, but it turns out that I was missing a few more instances of "cinematX.", mostly on the constants themselves. It's fixed now in my version.

I tried implementing a different timer script for a more accurate deltaTime, but that required a separate module and blargh. So I tweaked the existing timing code to show a few more decimal points, but the timing's only really accurate to 1/100 of a second.

I haven't tested the Broadsword boss yet but I know he's going to be completely broken. I need to convert all of his code from the previous format to a coroutine and add "cinematX." to a lot of stuff, plus all the NPC animation and movement stuff. Those are still commented out because I'm still trying to see if I can define them as member functions and variables, but it looks like I won't be able to do that unless I start contributing to the source (and I'm all set up to do so, I've just been holding of for various reasons).

But aside from the boss UI stuff and health variables there's not much real boss "functionality", so to speak. I'll eventually add a startBoss function that'll just set a few properties (name, HP, maybe even an HP bar type) and call a coroutine of the user's choice. Beyond that, it's up to the user how they program their boss, how it interacts with the bossHP/bossHPMax variables, exit conditions, which NPCs are used, all of that stuff.

Regarding player input, that's more or less what I figured the best way to approach it would be. For the time being I'll probably use the hack I suggested before: snapping the player to a custom NPC re-sprited to look like them.
Delightful Adventure Enhanced is out now!

Image

There's an official ASMT Discord server! Check it out to discuss Demo games and follow their development! thread, invite link

(Entry requires verification, either with a connected Youtube/Twitter/Twitch/etc account or manually by the server staff.)


Itch.io (albums and eventually games), Youtube (dofur pass and I guess other videos)
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Rockythechao wrote:Oh, thanks, I'll see about merging the two versions! Does this incorporate your own message box stuff with showSprite?
It's not built into the library I uploaded. I should explain how I do it, though. I only call "placeSprite" once, in the onLoad function. This places resource number 999998 (chosen because it's stupidly high and unlikely to cause collisions with other resources). Instead of calling placeSprite every frame I want the box to show (which lags the game up horrifically), I just change what is stored in the resource, between a black box of the right size, and a 1x1 white box, with the transparency colour set as white. This changes what placeSprite draws to, effectively, nothing, so the screen is clear again. I have this set up in different functions.

I should give you some info about what I've done to the library, too. I looked at the dialogTextTime variable, and noted that a lot of things stopped when it hit 0 (including the display of text). The problem was that this was counting down from the "textTime" set in the startDialog function. This caused a lot of problems, so I replaced a few of the tests of it with tests of "dialogOn", and removed some others entirely. As for the player input, there was no actual call to onKeyDown in the example, so that needed to be done in my lunadll.lua. As well as that, there was a misnamed label in one of the "signal" functions, and the call to "signal" to wake up the sleeping threads when the X key is pressed was missing. I stuck that at the end of "endDialogLine".
Rockythechao wrote: The Augstus Leopold etc etc thing is the boss name. At first I thought it was stuck in boss mode for some reason, but it turns out that I was missing a few more instances of "cinematX.", mostly on the constants themselves. It's fixed now in my version.
Yeah, I thought the same, and fixed it in mine, too.
Rockythechao wrote: I tried implementing a different timer script for a more accurate deltaTime, but that required a separate module and blargh. So I tweaked the existing timing code to show a few more decimal points, but the timing's only really accurate to 1/100 of a second.
Apparently Lua only natively supports per-second timing, which sucks, but at least it works.
Rockythechao wrote: I haven't tested the Broadsword boss yet but I know he's going to be completely broken. I need to convert all of his code from the previous format to a coroutine and add "cinematX." to a lot of stuff, plus all the NPC animation and movement stuff. Those are still commented out because I'm still trying to see if I can define them as member functions and variables, but it looks like I won't be able to do that unless I start contributing to the source (and I'm all set up to do so, I've just been holding of for various reasons).
Well, I'm worried my changes might have broken a lot of stuff too, but the cutscene system is at least more or less working.
Rockythechao wrote: But aside from the boss UI stuff and health variables there's not much real boss "functionality", so to speak. I'll eventually add a startBoss function that'll just set a few properties (name, HP, maybe even an HP bar type) and call a coroutine of the user's choice. Beyond that, it's up to the user how they program their boss, how it interacts with the bossHP/bossHPMax variables, exit conditions, which NPCs are used, all of that stuff.
Ah, fair enough. That makes sense. I may have broken some of the UI things, though.
Rockythechao wrote: Regarding player input, that's more or less what I figured the best way to approach it would be. For the time being I'll probably use the hack I suggested before: snapping the player to a custom NPC re-sprited to look like them.
Yeah, that seems reasonable. Would be nice to at least have the snapping and displaying of a user-defined NPC (just plugging the NPC ID in here will be good) in the library for now, though.
Image
Image
Image
Image
Image
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Potential level spoilers ahead!

So this is a demonstration of what I've got with my version of CinematX, alongside my Trigger library. You can also see the raocoin counter in the top right, which is in my lunaworld.lua.

This is the start of a level I intend to submit, so if people don't want any level spoilers, best avoid this video.


Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

I am currently redesigning the documentary. I am sorry for not currently working on LunaLua. I will promise to continue work on LunaLua when I finished the redesign!
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:I am currently redesigning the documentary. I am sorry for not currently working on LunaLua. I will promise to continue work on LunaLua when I finished the redesign!
It's pretty good so far as it is, but there's always more to improve on!

I recommend, by the way, including things like cinematX as standard libraries for this, when they're done, of course. The extra functionality provided makes a lot of things so much easier.
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

If you don't mind I will move the whole thing to lapi.lua.

That's the purpos of lapi.lua: The "standard-library" for SMBX written in lua.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:If you don't mind I will move the whole thing to lapi.lua.

That's the purpos of lapi.lua: The "standard-library" for SMBX written in lua.
Hmm... it's usually best not to do that, actually. Having everything in one standard library is actually not a good thing. First of all, if you needed, say, triggers, but not cutscenes, when they're separate, you only have to load in the trigger library. If they're together, you have to load up everything, even if you're not using it. This takes up memory. Secondly, it means different libraries can't share identifiers, so they can't use the same function or variable names, which is a problem if they're coded separately. It also helps a lot of function and variable names have more meaning. A function called "updateUI" doesn't have nearly as much meaning as "cinematX.updateUI", for example. It helps show what exactly the variables and functions are referring to.

It's generally a better idea to keep them separate. I've been putting everything into a subfolder called lua, which contains the library lua files, then using require statements to import them independently. This is how the majority of programming languages work, and for good reason. I strongly recommend LunaLua should too.
Image
Image
Image
Image
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Good point, I think the best move would be to have folder "lua" located at the root directory and load up every module which ends with ".lua". What do you think?
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kevsoft wrote:Good point, I think the best move would be to have folder "lua" located at the root directory and load up every module which ends with ".lua". What do you think?
Yeah, that works. Just including that folder in the download, and letting people use the libraries they like with require statements will be best, I think.
Image
Image
Image
Image
Image
Kil
Posts: 13
Joined: 15 years ago

Re: Presenting: Lunadll for Lua!

Post by Kil »

So is there a way to get the level name in Lua like a global function? Failing that, maybe I could dereference the pointer to the level name string and get it that way?
DON'T PM me. Ask your question in the help thread so everyone can be answered.
Post Reply