(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 »

Kil wrote: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?
As far as I know, you'd need to find the pointer in global memory, and dereference it from there. I'm not sure whether SMBX actually keeps track of that while you're in the level, though.
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 »

Uhm, there is no function yet to get the level name. I'll add it later.

I might also try to add mem-function support for strings.
Kil
Posts: 13
Joined: 15 years ago

Re: Presenting: Lunadll for Lua!

Post by Kil »

Hoeloe wrote:
Kil wrote: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?
As far as I know, you'd need to find the pointer in global memory, and dereference it from there. I'm not sure whether SMBX actually keeps track of that while you're in the level, though.
It does actually. I've been using that pointer for awhile for various things like the variable bank. If you guys add the ability to read wchar_t type or pointers to it (smbx uses it for everything) it would probably be quite useful to you. Format of the standard wchar_t smbx expects is just 2 byte little endian characters, and the final byte is 00 00 marking the end of the string.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Kil wrote: It does actually. I've been using that pointer for awhile for various things like the variable bank. If you guys add the ability to read wchar_t type or pointers to it (smbx uses it for everything) it would probably be quite useful to you. Format of the standard wchar_t smbx expects is just 2 byte little endian characters, and the final byte is 00 00 marking the end of the string.
That would be super useful. I can already think of a number of great uses for that. If we could follow and interpret SMBX's string pointers, it would open a lot of doors.
Image
Image
Image
Image
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1855
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

Kil wrote:It does actually. I've been using that pointer for awhile for various things like the variable bank. If you guys add the ability to read wchar_t type or pointers to it (smbx uses it for everything) it would probably be quite useful to you. Format of the standard wchar_t smbx expects is just 2 byte little endian characters, and the final byte is 00 00 marking the end of the string.
So, wait, you mentioned in the LunadDLL help thread that the strings being pointed to in the NPC memory are formatted strangely. Is that the case with the level name as well?
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)
Kil
Posts: 13
Joined: 15 years ago

Re: Presenting: Lunadll for Lua!

Post by Kil »

Well that's kind of true. They're just wchar_t's, but their object wrapper is strange. Basically, changing those strings is hard, but reading them should be fine.

Why:
SMBX's old VB6 relies on immutable strings internally, and one of the things that allowed them to do was use associative memory based on hashing the string. So the memory allocation for a string object might look like

Hello => 0x78010244

But if you change it, the memory lookup algorithm might be totally different

Hell =>0x8B036404

So when it goes to free that string, it's not gonna free the right memory anymore, and then the best case scenario is just a memory leak, and the worst case would be the program crashing. So yeah, probably don't try and change the smbx strings, but again, reading them should be fine.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1855
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

Well, I really don't care about changing the string so much as rendering the NPC "mute", so to speak. If I can somehow disable the player's ability to trigger NPC messages then I'll be free to set up my own NPC dialogue/event trigger system based on a table of the message strings.

I'm assuming SMBX has bad or non-existent garbage collection, so I probably can't just change the pointer itself into whatever default address/offset is used by non-speaking NPCs... Pay attention, past me, he outright said "memory leak"!
Last edited by Rixithechao 9 years ago, edited 1 time in total.
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
Narolas
Posts: 0
Joined: 11 years ago

Re: Presenting: Lunadll for Lua!

Post by Narolas »

You people here are code wizards, it's fantastic.

Hoeloe, is there any way to get your level + cutscene thing ? I'm working on a level and i'd love to be able to have a short dialogue sequence at the start of it, with an example I could probably figure out how it works and apply it to my stuff.

Seriously the things you guys are doing with lunaLua are awesome, the Broadsword fight looks fantastic! I think people are going to be blown away by this new tech when Ep.2 comes out (eventually).
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Narolas wrote:You people here are code wizards, it's fantastic.

Hoeloe, is there any way to get your level + cutscene thing ? I'm working on a level and i'd love to be able to have a short dialogue sequence at the start of it, with an example I could probably figure out how it works and apply it to my stuff.

Seriously the things you guys are doing with lunaLua are awesome, the Broadsword fight looks fantastic! I think people are going to be blown away by this new tech when Ep.2 comes out (eventually).
It's actually pretty simple - I can post the code for a simple cutscene right here! If you get the version of cinematX I posted, and put it in a folder called "lua" in the same location as the base game exe file, then you can use the following code to run a simple cutscene:

Code: Select all

package.path = package.path .. ";./worlds/?/?.lua" .. ";./?.lua"
cinematxLib = require ("cinematX")

inCutscene = true;

function onLoad()
  loadImage("textbox.bmp", 999998, 0xFFFFFF);
  placeSprite(1, 999998, 0, 472);
  
  
  endCutscene();
  
  cinematxLib.init ()

  cinematxLib.runCutscene(introCutscene);

  cutscenePhase = 0
  cutsceneFrame = 0
end

function onKeyDown(keycode, playerIndex)
	cinematxLib.onKeyDown(keycode);
end

function introCutscene()
						beginCutscene();
						cinematxLib.startDialog(NPCID_IRIS, "Iris", "I'm in a cutscene!", 30,30,"");
                                                cinematxLib.waitForDialog();
						cinematxLib.startDialog(NPCID_IRIS, "Iris", "It's super awesome!", 30,30,"");
                                                cinematxLib.waitForDialog();
						endCutscene();
end

function onLoop()
  cinematxLib.update ()
end

function endCutscene()
    if inCutscene then
		loadImage("emptyBox.bmp", 999998, 0xFFFFFF);
		inCutscene = false;
	end
end

function beginCutscene()
    if inCutscene == false then
		loadImage("textbox.bmp", 999998, 0xFFFFFF);
		inCutscene = true;
	end
end
You'll also need these two images, which I have in my level folder, but I'm sure we'll eventually put together as part of the library. They will need converting to bmp files (NOT gif files), and should have the name given under them.:

http://i.imgur.com/NoG7b1F.png
emptyBox.bmp

http://i.imgur.com/Zaf819U.png
textbox.bmp

Unfortunately, I can only upload as a png, so you'll have to convert them manually.

You can run a cutscene at any time using this, by just changing when you call cinematxLib.runCutscene. In my level, for example, you can see a couple which are triggered by SMBX events using my Trigger library.
Image
Image
Image
Image
Image
Kil
Posts: 13
Joined: 15 years ago

Re: Presenting: Lunadll for Lua!

Post by Kil »

Rockythechao wrote:Well, I really don't care about changing the string so much as rendering the NPC "mute", so to speak.
Can't you just not give it a message then? And set it to friendly or whatever. Reading SMBX strings won't really help you on that front.
Last edited by Kil 9 years ago, edited 1 time in total.
DON'T PM me. Ask your question in the help thread so everyone can be answered.
User avatar
Narolas
Posts: 0
Joined: 11 years ago

Re: Presenting: Lunadll for Lua!

Post by Narolas »

It Does seem fairly simple actually, neat.

Thanks a ton. I'll set it up that way now, but i'll keep an eye out to how the lua stuff will be implemented in the future, since it's probably going to change a bit.
I'll play with it later today, if it works i'll share the results :)
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

Small update/question about the documentary:
Recently Wohlstand made up a wiki for his project AND for LunaDLL stuff. So I wrote up a part now in the wiki;

Here the link: http://engine.wohlnet.ru/wiki/index.php ... _functions

My question is: Do you like it? It has some advantages, especially that people can now help me with the docs. Also with that we're able to write one page for every functions easily.
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1855
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

Kil wrote:
Rockythechao wrote:Well, I really don't care about changing the string so much as rendering the NPC "mute", so to speak.
Can't you just not give it a message then? And set it to friendly or whatever. Reading SMBX strings won't really help you on that front.
Because I need to index the messages first. Once I've got a table of all speaking enemies and their messages, I disable talking to NPCs through SMBX and then handle NPC dialogue through cinematX. I'd be able to set it up so that folks could make coroutine calls through the editor and other cool stuff.

The new wiki looks cool from a quick glance, I'll give it a more thorough read through later.
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)
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Darkchaox100 »

Hoeloe: Does your cscenes Script make the Text scroll or will it just been drawn?
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Darkchaox100 wrote:Hoeloe: Does your cscenes Script make the Text scroll or will it just been drawn?
The script I've got uses the cinematX library, which looks exactly as it does in my demo video - that is, it will appear in a typewriter effect.
Image
Image
Image
Image
Image
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1855
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

CinematX currently doesn't have any way to handle overflowing text. I'm still implementing Hoeloe's bugfixes so I can't test it myself, but either it'll stop displaying text at the end of the fourth line or just run off the screen.

I could implement overflow scrolling in the future, but for now I'm focusing on getting a bunch of important functionality working again after a major rewrite broke most of the library. After that, basic Yes/No choices and possibly overriding SMBX's NPC message system.
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
Mabel
Just west of wierd
Posts: 302
Joined: 10 years ago
https://marbels.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Mabel »

dumb question but BlockTrigger works in the .lua code right?

or at the lease, can i use BlockTrigger in the .dll and have it activate the lua?
Image
Image
Image Image
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Darkchaox100 »

Hoeloe wrote:
Darkchaox100 wrote:Hoeloe: Does your cscenes Script make the Text scroll or will it just been drawn?
The script I've got uses the cinematX library, which looks exactly as it does in my demo video - that is, it will appear in a typewriter effect.
Awesome i just tested it and it works nicely!
Just one question,can i adjust the speed of the typewriter effect?
Rixithechao
https://www.youtube.com/watch?v=BODxOghVmko
Posts: 1855
Joined: 10 years ago
First name: Mack
https://rixithechao.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Rixithechao »

I believe there should be a variable in there for the number of letters it shows per frame. More advanced timing controls, like X-second pauses mid-text, are another eventual goal. In the meantime, you can achieve those using waitSeconds() and messing with the dialog____ variables.
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)
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Darkchaox100 »

Rockythechao wrote:I believe there should be a variable in there for the number of letters it shows per frame. More advanced timing controls, like X-second pauses mid-text, are another eventual goal. In the meantime, you can achieve those using waitSeconds() and messing with the dialog____ variables.
Ah found it,its cinematX.dialogTextSpeed
Set it to 0.2 and it's just as fast as SMW :3
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Mabel wrote:dumb question but BlockTrigger works in the .lua code right?

or at the lease, can i use BlockTrigger in the .dll and have it activate the lua?
I don't think it does, actually. It hasn't been implemented yet, as far as I know.

Still, while Autocode and Lua can't communicate directly, you can probably use a roundabout method to send messages from one to the other. I'd use the trigger library I made, for example, and have the Autocode (standard LunaDLL code) trigger an SMBX event, that then triggers Lua code. A bit awkward, but it should work at least.
Image
Image
Image
Image
Image
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Darkchaox100 »

Hey Hoeloe,how can i disable the skipping if the text has not finished drawing?
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Darkchaox100 wrote:Hey Hoeloe,how can i disable the skipping if the text has not finished drawing?
Ah, that's something my fix didn't implement, but isn't too hard to do. If you look at the cinematX library, you'll find a function called onKeyDown, which looks like this:

Code: Select all

	function cinematX.onKeyDown (keycode)
		-- Skip dialog if allowed
		if(keycode == KEY_X  and  cinematX.dialogEndWithInput == true  and  (cinematX.dialogOn  or  cinematX.dialogSpeakerTime > 0)) then
			playSFX(23) -- 10 = skid, 14 = coin, 23 = shckwup
			cinematX.endDialogLine()
		end
	end
If you just change that to this:

Code: Select all

	function cinematX.onKeyDown (keycode)
		-- Skip dialog if allowed
		if(keycode == KEY_X  and  cinematX.dialogEndWithInput == true  and  (cinematX.dialogOn  or  cinematX.dialogSpeakerTime > 0)) then
                       if(cinematX.dialogNumCharsCurrent < string.len (cinematX.dialogTextFull)) then
                           cinematX.dialogNumCharsCurrent = string.len(cinematX.dialogTextFull;
                       else
			 playSFX(23) -- 10 = skid, 14 = coin, 23 = shckwup
			 cinematX.endDialogLine()
                       end
		end
	end
then that should change the behaviour so that pressing X while the typewriter effect is unfinished won't skip to the next section of text, but will skip to the end of the typewriter.
Image
Image
Image
Image
Image
Darkchaox100
Posts: 0
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Darkchaox100 »

Hoeloe wrote:...
I mean if the text has finished drawing,then you are able to press x,and not while its still typing.
User avatar
Hoeloe
A2XT person
Posts: 1022
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Darkchaox100 wrote:
Hoeloe wrote:...
I mean if the text has finished drawing,then you are able to press x,and not while its still typing.
Yeah, that's what that does. It will prevent text from progressing unless it's finished typing.
Image
Image
Image
Image
Image
Post Reply