(shouting)

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
Lejes
Posts: 78
Joined: 10 years ago
https://lejes.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Lejes »

Ah. I had tried declaring the string as a variable first, but I hadn't realized that onEvent runs the way it does.
User avatar
Alice
Posts: 2367
Joined: 12 years ago
Pronouns: Girl person
Location: Wonderland

Re: Presenting: Lunadll for Lua!

Post by Alice »

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.
User avatar
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!

Post by romajiQuadhash »

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.
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.
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
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

romajiQuadhash wrote:
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.)
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.
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
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.
User avatar
Alice
Posts: 2367
Joined: 12 years ago
Pronouns: Girl person
Location: Wonderland

Re: Presenting: Lunadll for Lua!

Post by Alice »

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
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.

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?
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.
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?
User avatar
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!

Post by romajiQuadhash »

Alice wrote:
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
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.

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?
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.
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?
I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.
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
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

romajiQuadhash wrote: I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.
Or... just use the HUD setting on placeSprite.
Image
Image
Image
Image
Image
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

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?
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.
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 :)
Hoeloe wrote:
romajiQuadhash wrote:I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.
Or... just use the HUD setting on placeSprite.
Aye... Those options aren't very well documented right now (basically only here so far as I've seen), but they're rather handy.
User avatar
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!

Post by romajiQuadhash »

Hoeloe wrote:
romajiQuadhash wrote: I called it "hacky" because you need to move the sprites every loop to ensure they act as a hud.
Or... just use the HUD setting on placeSprite.
... didn't know that existed. someone need to add that to docs
This is a sig
User avatar
Alice
Posts: 2367
Joined: 12 years ago
Pronouns: Girl person
Location: Wonderland

Re: Presenting: Lunadll for Lua!

Post by Alice »

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?
User avatar
Hoeloe
A2XT person
Posts: 1016
Joined: 12 years ago
Pronouns: she/her
Location: Spaaace

Re: Presenting: Lunadll for Lua!

Post by Hoeloe »

Alice 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?
http://engine.wohlnet.ru/pgewiki/Category:LunaLua_API
Image
Image
Image
Image
Image
User avatar
Isocitration
Posts: 33
Joined: 13 years ago

Re: Presenting: Lunadll for Lua!

Post by Isocitration »

I feel like I might be missing something obvious here, but is there a simple way to completely disable the player's block collision?
User avatar
Rednaxela
Maker of Shenanigans
Posts: 897
Joined: 10 years ago
Pronouns: they/them
https://rednaxela.talkhaus.com

Re: Presenting: Lunadll for Lua!

Post by Rednaxela »

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 wish I knew one. It would have made one bit of trickery in my MaGL X2 level more flexible.

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.
User avatar
Alice
Posts: 2367
Joined: 12 years ago
Pronouns: Girl person
Location: Wonderland

Re: Presenting: Lunadll for Lua!

Post by Alice »

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?
User avatar
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!

Post by romajiQuadhash »

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?
Yep.
Or I can just send my working install
This is a sig
User avatar
Alice
Posts: 2367
Joined: 12 years ago
Pronouns: Girl person
Location: Wonderland

Re: Presenting: Lunadll for Lua!

Post by Alice »

romajiQuadhash wrote:Yep.
Or I can just send my working install
Hm, that's what I did but it doesn't seem to be working. I setup my test level and used this example code:

Code: Select all

myVar = 0;
 
function onLoop()
    MyFunction();
    printText(tostring(myVar),3,0,0);
end
 
function MyFunction()
    myVar = myVar + 1;
end
just 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.
User avatar
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!

Post by romajiQuadhash »

Alice wrote:
romajiQuadhash wrote:Yep.
Or I can just send my working install
Hm, that's what I did but it doesn't seem to be working. I setup my test level and used this example code:

Code: Select all

myVar = 0;
 
function onLoop()
    MyFunction();
    printText(tostring(myVar),3,0,0);
end
 
function MyFunction()
    myVar = myVar + 1;
end
just 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.
The files are in the right place.
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
User avatar
Alice
Posts: 2367
Joined: 12 years ago
Pronouns: Girl person
Location: Wonderland

Re: Presenting: Lunadll for Lua!

Post by Alice »

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.
User avatar
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!

Post by romajiQuadhash »

Alice 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.
Alright, I'll upload my set up toomorow later today
This is a sig
User avatar
Lejes
Posts: 78
Joined: 10 years ago
https://lejes.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Lejes »

There seems to be some kind of problem with this code.

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
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.
S1eth
Posts: 291
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by S1eth »

Lejes wrote:There seems to be some kind of problem with this code.

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
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.
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).
BTW, holdingNPC is not listed at http://engine.wohlnet.ru/docs/_PGE/struct_Player.txt
Where would I look to find things like these?
Image
User avatar
Kevsoft
LunaLua Master Developer
Posts: 83
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by Kevsoft »

S1eth wrote: Where would I look to find things like these?
Here: http://engine.wohlnet.ru/pgewiki/Player_%28class%29
User avatar
Lejes
Posts: 78
Joined: 10 years ago
https://lejes.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Lejes »

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).
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
Posts: 291
Joined: 9 years ago

Re: Presenting: Lunadll for Lua!

Post by S1eth »

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.
Image
User avatar
Lejes
Posts: 78
Joined: 10 years ago
https://lejes.talkhaus.com/

Re: Presenting: Lunadll for Lua!

Post by Lejes »

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.
Post Reply