function onEvent(eventname)
if(eventname == "NPC4") then
playSFXSDL("rimshot.ogg");
end
end
(Don't replace eventname with the name of your event!)
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Wed May 20, 2015 4:50 pm
by Aperrentis
Okay, using that code, it's not returning an error!
But the sound effect still won't play. It's an .ogg file, so I'm not entirely sure why it won't play.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Wed May 20, 2015 5:02 pm
by HenryRichard
Aperrentis wrote:Okay, using that code, it's not returning an error!
But the sound effect still won't play. It's an .ogg file, so I'm not entirely sure why it won't play.
Is it in the level's folder? If so, is it resampled to 44100 Hz (I think that's what it needs to be)?
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Thu May 21, 2015 6:20 pm
by Aperrentis
Few more sound effect questions, basically just wondering how to:
play a sound effect when a player dies;
restrict a sound effect to play when a player jumps while crouching as opposed to jumping regularly; and
restrict a sound effect to play when a player throws a fireball when having the fire flower power-up.
I tried to use filters for the last two (didn't seem to work), and I don't even know where to start with the first.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Sat May 23, 2015 6:55 pm
by HenryRichard
Is there a way to change the maximum run speeds of characters? I didn't see how to on the PGE wiki, but it seems like it should be possible seeing as it's different for some characters. These are the values I got by reading speedX:
Mario - 6
Luigi - 6
Peach - 5.5800000429153
Toad - 6.4200003147125
Link - 6
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Sat May 23, 2015 7:05 pm
by Kevsoft
There are a lot of diffrent values. I do know where they are but I am not sure what they refere to. At the moment there is no way to change the maximum speed of the characters.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
function onEvent(event)
if (event == "GoDown") then
earthquake(10)
end
end
Always use parenthesiseses with if statements.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Sun May 24, 2015 7:44 pm
by Onule
Turns out the issue is with the current version of lunalua.
If the symptom you're seeing is that OnEvent only gets called once per tick, that's a known issue as of the last LunaDLL release, and a fix is already in place for the next release
Using onEventDirect worked, but hopefully if the next release is within a few days, will change it back to onEvent.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Wed May 27, 2015 12:40 am
by SlyAsACooper
I made an account just to post this question because I don't really know where else to go for help :/ I've fiddled with trying to get the test code you provide in LunaLua on the first page to work in a custom level so I can start using it to start changing jump mechanics (double jump and the like) for hours, but nothing seems to work. I've scoured the Internet and help topics on this trying different things, but nothing seems to get it to work. So, I downloaded everything via the link you provided and when I start the game it has the whole LunaLua v0.6.1.1 Beta thing on it, so I know that part is fine. The part that I think I'm stumbling on is the whole .lua thing you make in the folder with your level. I have a folder for my level (which right now is just a flat line of blocks, Mario, and a background just to test it) and I downloaded notepad++ since I heard that was easier to code with. I created a .lua file with it and copy-pasted the code you provided and even tried some other test code out, but when I tested my level out no text shows up and no changes occur to the level. I've never coded before in my life and I have no idea if there's just something I'm completely missing here or not. I can give you screenshots if you need them to figure out what's wrong, any help would be greatly appreciated. I've never really made a SMBX level before, but have wanted to for a long time and a contest from this group I'm a part of is getting me to jump into it.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Wed May 27, 2015 2:05 am
by Kevsoft
Ah, welcome!
When SMBX with LunaLua runs, then you're already on the good rail.
You lua file must be called "lunadll.lua" and has to be in the custom folder of your level file.
Here the directory hierarchy:
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Wed May 27, 2015 3:58 pm
by SlyAsACooper
Holy crap, it worked! Thanks a ton! I never would have thought all I needed to do was create another folder next to my level and THEN put the .lua in it. Time to experiment! I'll be sure to come back if I have any more questions!
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Wed May 27, 2015 11:20 pm
by SlyAsACooper
Ok, so I've been trying to mess around with Mario's jumping and I'm struggling a bit, mainly due to a lack of knowledge of commands and what not. I want to give Mario another jump when he releases a grabbed object. I found a video where someone is able to give Mario a double jump and I've been messing with the commands that person had in hopes of at least accomplishing the grab release jump, but I haven't had much luck. I feel bad just asking others for so much help on this, but I'm just really stuck right now. Also, how do you make specific NPC's grabbable? I feel kind of dumb for asking that, but I honestly don't know how to do that. Also, sorry if this isn't the proper place to ask this! I can delete this if needed. Here's the video I've used for reference code when trying to give Mario that jump:
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Thu May 28, 2015 4:17 am
by Kevsoft
To make NPC grabable you need to use NPC Codes. (grabside=1)
Then you would like to extend the exsisting code like that
canJump = false --holds if mario can double jump. Avoids an "ahippinandahoppin"-like behavior.
hasHoldingJumpingItem = false
function onJump()
if(player.holdingNPC)then
canJump = true
hasHoldingJumpingItem = true
end
end
function onKeyDown(keycode)
if (keycode == KEY_JUMP) then --if the player hits JUMP while
if (canJump and hasHoldingJumpingItem and not player.holdingNPC) then --double jump is allowed
player.speedY = -10 --make him jump.
playSFX(1) --play jump sound effect.
canJump = false --now Mario can't jump
hasHoldingJumpingItem = false
end
end
end
function onJumpEnd() --if you step in the ground
canJump = false --obviously you can't double jump directly from the ground.
hasHoldingJumpingItem = false
end
Warning, I did not test the code
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Thu May 28, 2015 11:58 am
by SlyAsACooper
Dang Kevsoft, you know your code man. It works perfectly. Exactly what I need! Thanks a lot!
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Thu May 28, 2015 1:49 pm
by Kevsoft
Oh, thanks! Hope to see some neat stuff
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Fri Jun 05, 2015 11:57 am
by Nicholas-Link
Awhile back I asked something similar to this, but is there a way to have two "Links" but they look different. That is, by using Luna.lua. I'll try to put it into more detail, so here I go...
So let's say that I have Link. I want him in my game, however, I want to add another character that uses Link's sprite sheet. However, I want to switch between them whenever I want. I know that you can only use one Link sheet at a time in regular smbx. Can I somehow change that in Luna.lua? If I could, that would be great! If I can't then I may be in sort of a jam... Thanks in advance.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Fri Jun 05, 2015 12:21 pm
by FanofSMBX
Will it ever be possible to change how fast the player falls in water, when they're not swimming? I think in SMBX it is harder to go down than up when swimming.
Re: LunaLua - Lunadll with lua [Streaming Question Poll]
Posted: Sat Jun 06, 2015 1:45 pm
by Kevsoft
FanofSMBX wrote:Will it ever be possible to change how fast the player falls in water, when they're not swimming? I think in SMBX it is harder to go down than up when swimming.
Maybe in the future. Generally all the speed fields has not been revealed yet.
Okay, so LunaLua v0.7 is finally out.
Coming with a whole bunch of changes:
* First of all a huge thank to Rednaxela for the OpenGL renderer! This should improve the overall speed of SMBX.
* Added Layer functions :show :hide :toggle
* Added new Event onInputUpdate + player control fields (in player class)
* Added new Event onLevelExit
* Added new Warp class
* Added new BGO class
* A lot of functions has been moved to namespaces. This doesn't mean that the old functions don't work anymore. It just recommended to use the new ones, as they have been improved.
* Some minior performance improvement and bug fixes in SMBX.