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 ). 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.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.
LunaLua Offical Thread
Re: Presenting: Lunadll for Lua!
Re: Presenting: Lunadll for Lua!
Don't mind that, I'll cope. It doesn't seem to have updated the file on the drive, though, which is odd.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 >_<
-
- https://www.youtube.com/watch?v=BODxOghVmko
- Posts: 1864
- Joined: 10 years ago
- First name: Mack
- https://rixithechao.talkhaus.com/
Re: Presenting: Lunadll for Lua!
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!
- 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!
Delightful Adventure Enhanced is out now!
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)
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)
Re: Presenting: Lunadll for Lua!
A direct draw function would be amazing. I could probably write a 3D renderer if we had access to one of those.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.
Ah, awesome, thanks!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!
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.
-
- https://www.youtube.com/watch?v=BODxOghVmko
- Posts: 1864
- Joined: 10 years ago
- First name: Mack
- https://rixithechao.talkhaus.com/
Re: Presenting: Lunadll for Lua!
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.
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 Rixithechao 9 years ago, edited 1 time in total.
Delightful Adventure Enhanced is out now!
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)
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)
Re: Presenting: Lunadll for Lua!
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.
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.
-
- ? Title Title Title Title ?
- Posts: 30
- Joined: 14 years ago
- Location: USA
Re: Presenting: Lunadll for Lua!
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??
Am I missing something? Is it just not possible because the stupid engine constantly rewrites her speedY value??
Re: Presenting: Lunadll for Lua!
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.
Re: Presenting: Lunadll for Lua!
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.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.
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?
Re: Presenting: Lunadll for Lua!
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?
Re: Presenting: Lunadll for Lua!
LunaLua v0.2.7 is out
Changes:
Changes:
Since I added lunaworld.lua, I get crashes too. I will investergate further.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?
Maybe kil could add a hook for the event trigger function. Other than that it might get difficult.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?
Re: Presenting: Lunadll for Lua!
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.
Re: Presenting: Lunadll for Lua!
Can we at least get lua hooks for all the functions available to LunaDLL now? For example, the BlockTrigger function?Kevsoft wrote: Maybe kil could add a hook for the event trigger function. Other than that it might get difficult.
Re: Presenting: Lunadll for Lua!
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
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.
Re: Presenting: Lunadll for Lua!
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.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
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.
Re: Presenting: Lunadll for Lua!
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...
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...
Re: Presenting: Lunadll for Lua!
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.
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.
-
- ? Title Title Title Title ?
- Posts: 30
- Joined: 14 years ago
- Location: USA
Re: Presenting: Lunadll for Lua!
Yeeessss.Kevsoft wrote:LunaLua v0.2.7 is out
Changes:
* Added function for getting/setting earthquake, gravity and jumpheight.
Re: Presenting: Lunadll for Lua!
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?
Re: Presenting: Lunadll for Lua!
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):
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):
Re: Presenting: Lunadll for Lua!
Do you have the code which crashes the editor?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.
It is in the order as smbx internally order it.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?
Re: Presenting: Lunadll for Lua!
Kevsoft wrote: Do you have the code which crashes the editor?
Code: Select all
myRect = RECT()
Is there any indication of how that is done, or is it unknown?Kevsoft wrote: It is in the order as smbx internally order it.
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
Re: Presenting: Lunadll for Lua!
Would it be a simple alteration to use button inputs to change character instead of a block in your example?
Re: Presenting: Lunadll for Lua!
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.Xirix wrote:Would it be a simple alteration to use button inputs to change character instead of a block in your example?
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...
Re: Presenting: Lunadll for Lua!
Oh neat, I'll have a little experiment with that function then I guess.