Re: Presenting: Lunadll for Lua!
Posted: 08 Mar 2015, 23:31
Ah. I had tried declaring the string as a variable first, but I hadn't realized that onEvent runs the way it does.
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.
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
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
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.
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.
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.
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?
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.
... 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.
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?
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?
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?
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
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
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.
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
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
Here: http://engine.wohlnet.ru/pgewiki/Player_%28class%29S1eth wrote: Where would I look to find things like these?
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).