LunaLua Offical Thread
- Lejes
- Posts: 78
- Joined: 10 years ago
- https://lejes.talkhaus.com/
Re: Presenting: Lunadll for Lua!
Ah. I had tried declaring the string as a variable first, but I hadn't realized that onEvent runs the way it does.
Re: Presenting: Lunadll for Lua!
This might be a stupid line of questions but I have yet to actually make use of LunaLua before now. How possible would it be to do the following?
I have an idea for a Link based episode that'll be done somewhat Zelda II style. For it I'll need an item system. That item system will need to do a few things.
1.) Collected items should show up in the hud.
2.) Select should cycle the current item forward.
3.) Collected items also need to be saved to a file.
4.) (Kinda really obvious one here.) The currently selected item needs to be usable. (I'm thinking alt run for this would be good.)
I think that #s 1 and 3 are possible but I'm not entirely sure how feasible they would be and I'm not sure on #s 2 and 4 at all. (#1 would just be placing sprites on the screen in a screen based fashion, I think, and #3 should be possible soon because you're already adding functionality to store info in external files from MaGLx2 from what I recall reading recently.)
Also a note: I'm not new to programming, though I've never been particularly good at it, and I've never actually used Lua in particular before.
I have an idea for a Link based episode that'll be done somewhat Zelda II style. For it I'll need an item system. That item system will need to do a few things.
1.) Collected items should show up in the hud.
2.) Select should cycle the current item forward.
3.) Collected items also need to be saved to a file.
4.) (Kinda really obvious one here.) The currently selected item needs to be usable. (I'm thinking alt run for this would be good.)
I think that #s 1 and 3 are possible but I'm not entirely sure how feasible they would be and I'm not sure on #s 2 and 4 at all. (#1 would just be placing sprites on the screen in a screen based fashion, I think, and #3 should be possible soon because you're already adding functionality to store info in external files from MaGLx2 from what I recall reading recently.)
Also a note: I'm not new to programming, though I've never been particularly good at it, and I've never actually used Lua in particular before.
- romajiQuadhash
- typos "raocow" as "roacow" (and I TAS)
- Posts: 12
- Joined: 9 years ago
- First name: Romaji Quadhash
- Pronouns: ke/keh/ker
- Location: ""Canada""
Re: Presenting: Lunadll for Lua!
2 and 3 are quite easy (the ability to save stuff to files is not new in any way. What is new is sharing between episodes).1 would be kinda hacky, but doable.Alice wrote:This might be a stupid line of questions but I have yet to actually make use of LunaLua before now. How possible would it be to do the following?
I have an idea for a Link based episode that'll be done somewhat Zelda II style. For it I'll need an item system. That item system will need to do a few things.
1.) Collected items should show up in the hud.
2.) Select should cycle the current item forward.
3.) Collected items also need to be saved to a file.
4.) (Kinda really obvious one here.) The currently selected item needs to be usable. (I'm thinking alt run for this would be good.)
I think that #s 1 and 3 are possible but I'm not entirely sure how feasible they would be and I'm not sure on #s 2 and 4 at all. (#1 would just be placing sprites on the screen in a screen based fashion, I think, and #3 should be possible soon because you're already adding functionality to store info in external files from MaGLx2 from what I recall reading recently.)
Also a note: I'm not new to programming, though I've never been particularly good at it, and I've never actually used Lua in particular before.
4 is the real hard bit. I suppose you could make a generator and have the item teleport, or maybe the spawn functionality was made to work
This is a sig
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: Presenting: Lunadll for Lua!
Actually #1 is pretty easy. The loadImage/placeSprite API is perfect for that and I wouldn't call it hacky at all.romajiQuadhash wrote:2 and 3 are quite easy (the ability to save stuff to files is not new in any way. What is new is sharing between episodes).1 would be kinda hacky, but doable.Alice wrote:I have an idea for a Link based episode that'll be done somewhat Zelda II style. For it I'll need an item system. That item system will need to do a few things.
1.) Collected items should show up in the hud.
2.) Select should cycle the current item forward.
3.) Collected items also need to be saved to a file.
4.) (Kinda really obvious one here.) The currently selected item needs to be usable. (I'm thinking alt run for this would be good.)
4 is the real hard bit. I suppose you could make a generator and have the item teleport, or maybe the spawn functionality was made to work
#4 is also rather easy if all you want using the item to do is spawn something (i.e. a bomb, arrow, etc). The spawnNPC lua code I made works wonders (I use it extensively in my MaGL X2 level), and the current version of LunaLua has a C++ translation of that routine too.
i'd say most of the work is simply making the glue/infrastructure code to keep track of the items for the item system.
Re: Presenting: Lunadll for Lua!
It won't necessarily need to be a physical item. In the case of something like bombs yeah, but for something like a hookshot it would just need to play some sort of animation centered on Link according to the direction he's facing and would simply need to find the next block in the direction he's facing within a certain distance. I don't know that using a generator would necessarily be required for something like bombs either though but that one I'm less sure on.romajiQuadhash wrote:4 is the real hard bit. I suppose you could make a generator and have the item teleport, or maybe the spawn functionality was made to work
As for #1 I haven't looked into doing it at all yet but is there any way to hook into the game's hud or maybe use something from CinematX (did I get the name right on that?) to accomplish that?
That should work perfectly for the hud idea then. For #4 though would that hinge on being pre-existing items only such as the bomb npcs or could they be custom things like my hookshot idea I mentioned in my response for romajiQuadhash?Rednaxela wrote:Actually #1 is pretty easy. The loadImage/placeSprite API is perfect for that and I wouldn't call it hacky at all.
#4 is also rather easy if all you want using the item to do is spawn something (i.e. a bomb, arrow, etc). The spawnNPC lua code I made works wonders (I use it extensively in my MaGL X2 level), and the current version of LunaLua has a C++ translation of that routine too.
i'd say most of the work is simply making the glue/infrastructure code to keep track of the items for the item system.
- romajiQuadhash
- typos "raocow" as "roacow" (and I TAS)
- Posts: 12
- Joined: 9 years ago
- First name: Romaji Quadhash
- Pronouns: ke/keh/ker
- Location: ""Canada""
Re: Presenting: Lunadll for Lua!
I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.Alice wrote:It won't necessarily need to be a physical item. In the case of something like bombs yeah, but for something like a hookshot it would just need to play some sort of animation centered on Link according to the direction he's facing and would simply need to find the next block in the direction he's facing within a certain distance. I don't know that using a generator would necessarily be required for something like bombs either though but that one I'm less sure on.romajiQuadhash wrote:4 is the real hard bit. I suppose you could make a generator and have the item teleport, or maybe the spawn functionality was made to work
As for #1 I haven't looked into doing it at all yet but is there any way to hook into the game's hud or maybe use something from CinematX (did I get the name right on that?) to accomplish that?That should work perfectly for the hud idea then. For #4 though would that hinge on being pre-existing items only such as the bomb npcs or could they be custom things like my hookshot idea I mentioned in my response for romajiQuadhash?Rednaxela wrote:Actually #1 is pretty easy. The loadImage/placeSprite API is perfect for that and I wouldn't call it hacky at all.
#4 is also rather easy if all you want using the item to do is spawn something (i.e. a bomb, arrow, etc). The spawnNPC lua code I made works wonders (I use it extensively in my MaGL X2 level), and the current version of LunaLua has a C++ translation of that routine too.
i'd say most of the work is simply making the glue/infrastructure code to keep track of the items for the item system.
The custom thing would require more code, since SMBX doesn't really like the idea of custom powerup states.
You can definitly do that, I'm just not sure of all the components.
This is a sig
Re: Presenting: Lunadll for Lua!
Or... just use the HUD setting on placeSprite.romajiQuadhash wrote: I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: Presenting: Lunadll for Lua!
Hookshot would be doable but get much trickier. The way I'd do it is make the hookshot tip+chain at maximum reach into into a NPC sprite, and then use spawnNPC, and then Lua code to manipulate it's width/gfxwidth parameters (this is similar to what the game engine internally does for piranha plants extending out of pipes). Give it a xSpeed and manipulate it's x value a bit to compensate for width changes when moving right (not needed when moving left), and detect block collisions using offsets 0x0A/0x0C/0x0E/0x10. Once detected stop moving it and start moving the player. For manipulating it from tick-to-tick it's easiest with the pNPC library and a coroutine, but don't have to go that route.Alice wrote:That should work perfectly for the hud idea then. For #4 though would that hinge on being pre-existing items only such as the bomb npcs or could they be custom things like my hookshot idea I mentioned in my response for romajiQuadhash?
While the routine is active, you'd want to freeze Link's movement. Easiest way is to create SMBX events to disable player controls and re-enable them and use triggerEvent. Add a little playSFXSDL when triggered also and you'll be golden.
It's not easy but well, there. I've outlined a way to do it there. Might be curious enough to try implementing it some time :)
Aye... Those options aren't very well documented right now (basically only here so far as I've seen), but they're rather handy.Hoeloe wrote:Or... just use the HUD setting on placeSprite.romajiQuadhash wrote:I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.
- romajiQuadhash
- typos "raocow" as "roacow" (and I TAS)
- Posts: 12
- Joined: 9 years ago
- First name: Romaji Quadhash
- Pronouns: ke/keh/ker
- Location: ""Canada""
Re: Presenting: Lunadll for Lua!
... didn't know that existed. someone need to add that to docsHoeloe wrote:Or... just use the HUD setting on placeSprite.romajiQuadhash wrote: I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.
This is a sig
Re: Presenting: Lunadll for Lua!
I know there's documentation with tutorials but I don't have the link (probably in the OP but I'd like specific recommendations from people who know a bit more than I about this), does anyone have ones to a basic intro to using LunaLua as well as anything that might be more pertinent to my goal once I get that bit down?
Re: Presenting: Lunadll for Lua!
http://engine.wohlnet.ru/pgewiki/Category:LunaLua_APIAlice wrote:I know there's documentation with tutorials but I don't have the link (probably in the OP but I'd like specific recommendations from people who know a bit more than I about this), does anyone have ones to a basic intro to using LunaLua as well as anything that might be more pertinent to my goal once I get that bit down?
- Isocitration
- Posts: 33
- Joined: 13 years ago
Re: Presenting: Lunadll for Lua!
I feel like I might be missing something obvious here, but is there a simple way to completely disable the player's block collision?
- Rednaxela
- Maker of Shenanigans
- Posts: 897
- Joined: 10 years ago
- Pronouns: they/them
- https://rednaxela.talkhaus.com
Re: Presenting: Lunadll for Lua!
I wish I knew one. It would have made one bit of trickery in my MaGL X2 level more flexible.Isocitration wrote:I feel like I might be missing something obvious here, but is there a simple way to completely disable the player's block collision?
I'm sure it could be done, given one can set player x/y position and that'll ignore blocks, though the game will try shoving the player back out of blocks horizontally and stuff. One could counteract that I'm sure, but eh... it all gets messy/hacky.
Re: Presenting: Lunadll for Lua!
Out of curiosity, since there's no readme in the zip or install instructions in the op (only update instructions), do I just unzip the LunaLua stuff straight into the base folder for SMBX?
- romajiQuadhash
- typos "raocow" as "roacow" (and I TAS)
- Posts: 12
- Joined: 9 years ago
- First name: Romaji Quadhash
- Pronouns: ke/keh/ker
- Location: ""Canada""
Re: Presenting: Lunadll for Lua!
Yep.Alice wrote:Out of curiosity, since there's no readme in the zip or install instructions in the op (only update instructions), do I just unzip the LunaLua stuff straight into the base folder for SMBX?
Or I can just send my working install
This is a sig
Re: Presenting: Lunadll for Lua!
Hm, that's what I did but it doesn't seem to be working. I setup my test level and used this example code:romajiQuadhash wrote:Yep.
Or I can just send my working install
Code: Select all
myVar = 0;
function onLoop()
MyFunction();
printText(tostring(myVar),3,0,0);
end
function MyFunction()
myVar = myVar + 1;
end
- romajiQuadhash
- typos "raocow" as "roacow" (and I TAS)
- Posts: 12
- Joined: 9 years ago
- First name: Romaji Quadhash
- Pronouns: ke/keh/ker
- Location: ""Canada""
Re: Presenting: Lunadll for Lua!
The files are in the right place.Alice wrote:Hm, that's what I did but it doesn't seem to be working. I setup my test level and used this example code:romajiQuadhash wrote:Yep.
Or I can just send my working installjust to make sure it's working but I get nothing. To make sure I'm getting this right, "worlds/world name/level name/lunadll.lua" is where my lua file should be and "world name/level name.lvl" is where my level file itself should be, right? I also remember reading something earlier in the thread about how there should be some text at the top of the title screen about LunaLua but I'm seeing nothing there either.Code: Select all
myVar = 0; function onLoop() MyFunction(); printText(tostring(myVar),3,0,0); end function MyFunction() myVar = myVar + 1; end
if you don't see the text, it's not running properly.
So, on the line where you got the install files from in the OP,there's this thing to install. try that.
This is a sig
Re: Presenting: Lunadll for Lua!
Do you mean the VC++2013 redistributable stuff? Cause I already have that. Going to try just reinstalling it to be safe but I don't think it'll accomplish anything.
Edit: Yep. I tried those as well as reinstalling LunaLua itself but id didn't work.
Edit: Yep. I tried those as well as reinstalling LunaLua itself but id didn't work.
- romajiQuadhash
- typos "raocow" as "roacow" (and I TAS)
- Posts: 12
- Joined: 9 years ago
- First name: Romaji Quadhash
- Pronouns: ke/keh/ker
- Location: ""Canada""
Re: Presenting: Lunadll for Lua!
Alright, I'll upload my set up toomorow later todayAlice wrote:Do you mean the VC++2013 redistributable stuff? Cause I already have that. Going to try just reinstalling it to be safe but I don't think it'll accomplish anything.
Edit: Yep. I tried those as well as reinstalling LunaLua itself but id didn't work.
This is a sig
- Lejes
- Posts: 78
- Joined: 10 years ago
- https://lejes.talkhaus.com/
Re: Presenting: Lunadll for Lua!
There seems to be some kind of problem with this code.
But I can't figure out what it is. It checks if the player is holding a key just fine, but crashes if the player has a Yoshi or turns into a Tanooki statue. The problem seems to be specifically with the line where npcID is declared.
Code: Select all
if (player.holdingNPC ~= nil) then
local npcID = player.holdingNPC.id
if (npcID == 31) then
--printText(tostring(v.speedX), 3, 0, 0);
--printText(tostring(v.speedY), 3, 0, 32);
holding_key = true;
end
end
Re: Presenting: Lunadll for Lua!
Tried and no crashes, but: while on Yoshi/in statue form, player.holdingNPC.id is always 0 (whether you'e holding an item or not).Lejes wrote:There seems to be some kind of problem with this code.
But I can't figure out what it is. It checks if the player is holding a key just fine, but crashes if the player has a Yoshi or turns into a Tanooki statue. The problem seems to be specifically with the line where npcID is declared.Code: Select all
if (player.holdingNPC ~= nil) then local npcID = player.holdingNPC.id if (npcID == 31) then --printText(tostring(v.speedX), 3, 0, 0); --printText(tostring(v.speedY), 3, 0, 32); holding_key = true; end end
BTW, holdingNPC is not listed at http://engine.wohlnet.ru/docs/_PGE/struct_Player.txt
Where would I look to find things like these?
Re: Presenting: Lunadll for Lua!
Here: http://engine.wohlnet.ru/pgewiki/Player_%28class%29S1eth wrote: Where would I look to find things like these?
- Lejes
- Posts: 78
- Joined: 10 years ago
- https://lejes.talkhaus.com/
Re: Presenting: Lunadll for Lua!
I suspected Yoshi and statue forms are altering held item IDs, but if they're ID 0 I'm not sure why that would cause a problem. npcID would be declared as 0, and the conditional immediately after would just evaluate to false. What version of LunaLua are you using? I'm somewhat sure this wasn't happening before, and I might roll it back to check. I've got the most recent now.S1eth wrote: Tried and no crashes, but: while on Yoshi/in statue form, player.holdingNPC.id is always 0 (whether you'e holding an item or not).
Re: Presenting: Lunadll for Lua!
Whichever version was packaged with the MaGL X 2 devkit zip, probably 0.5.2. (EDIT: 0.5.3.1)
Last edited by S1eth 9 years ago, edited 1 time in total.
- Lejes
- Posts: 78
- Joined: 10 years ago
- https://lejes.talkhaus.com/
Re: Presenting: Lunadll for Lua!
Yeah, I was using 5.2 as well until I updated to 6.0.3 yesterday. I don't think this Tanooki issue was happening then, but I'm less and less sure of that. Maybe the problem-free statue was before I implemented this method for checking held item.