LunaLua Offical Thread - SMBX Usermod Framework

This is the place for discussion and support for LunaLua and related modifications and libraries.

Moderator: Userbase Moderators

Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?

Shall I steam some LunaLua live development?

Yes
200
92%
No
17
8%
 
Total votes: 217
Aperrentis
Shy Guy
Shy Guy
Posts: 9
Joined: Sat Jun 07, 2014 1:56 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Aperrentis » Wed May 20, 2015 3:51 pm

Code: Select all

function onEvent(NPC4)
	local playSFXSDL(rimshot.ogg)
end
For some reason it's giving me a "syntax error near 'end' " message. Am I using onEvent correctly? ('~`)

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Wed May 20, 2015 3:53 pm

Aperrentis wrote:

Code: Select all

function onEvent(NPC4)
	local playSFXSDL(rimshot.ogg)
end
For some reason it's giving me a "syntax error near 'end' " message. Am I using onEvent correctly? ('~`)
I think you need to do this:

Code: Select all

function onEvent(eventname)
if(eventname == "NPC4") then
playSFXSDL("rimshot.ogg");
end
end
(Don't replace eventname with the name of your event!)

Aperrentis
Shy Guy
Shy Guy
Posts: 9
Joined: Sat Jun 07, 2014 1:56 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Aperrentis » Wed May 20, 2015 4:50 pm

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.

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Wed May 20, 2015 5:02 pm

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)?

Aperrentis
Shy Guy
Shy Guy
Posts: 9
Joined: Sat Jun 07, 2014 1:56 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Aperrentis » Thu May 21, 2015 6:20 pm

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.

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Sat May 23, 2015 6:55 pm

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:

Code: Select all

Mario - 6
Luigi - 6
Peach - 5.5800000429153
Toad - 6.4200003147125
Link - 6

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Sat May 23, 2015 7:05 pm

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.

Onule
Spiny
Spiny
Posts: 27
Joined: Tue Mar 18, 2014 11:54 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Onule » Sun May 24, 2015 11:54 am

I can't get onEvent to work.

This is the code

Code: Select all

function onEvent(event)
	if event == "GoDown" then
		earthquake(10)
	end
end
EDIT:
Seems that just having triggerEvent in onLoop makes onEvent not work. Anyway to fix this?

HenryRichard
Birdo
Birdo
Posts: 2843
Joined: Mon Dec 23, 2013 12:09 pm
Flair: Is this where I type my password?
Contact:

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby HenryRichard » Sun May 24, 2015 7:22 pm

Code: Select all

function onEvent(event)
	if (event == "GoDown") then
		earthquake(10)
	end
end
Always use parenthesiseses with if statements.

Onule
Spiny
Spiny
Posts: 27
Joined: Tue Mar 18, 2014 11:54 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Onule » Sun May 24, 2015 7:44 pm

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.

SlyAsACooper
Guest

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby SlyAsACooper » Wed May 27, 2015 12:40 am

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

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Wed May 27, 2015 2:05 am

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:

Code: Select all

+ {Episode-Folder}
   + your-level.lvl
   + your-level
      + lunadll.lua

SlyAsACooper
Guest

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby SlyAsACooper » Wed May 27, 2015 3:58 pm

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!

SlyAsACooper
Guest

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby SlyAsACooper » Wed May 27, 2015 11:20 pm

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:

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Thu May 28, 2015 4:17 am

To make NPC grabable you need to use NPC Codes. (grabside=1)

Then you would like to extend the exsisting code like that

Code: Select all

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

SlyAsACooper
Guest

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby SlyAsACooper » Thu May 28, 2015 11:58 am

Dang Kevsoft, you know your code man. It works perfectly. Exactly what I need! Thanks a lot! :D

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Thu May 28, 2015 1:49 pm

Oh, thanks! Hope to see some neat stuff ;)

Nicholas-Link
Dolphin
Dolphin
Posts: 94
Joined: Mon Feb 16, 2015 5:15 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Nicholas-Link » Fri Jun 05, 2015 11:57 am

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.
Last edited by Nicholas-Link on Sat Jun 06, 2015 4:24 pm, edited 1 time in total.

FanofSMBX
Mouser
Mouser
Posts: 3878
Joined: Sun Dec 22, 2013 12:01 pm

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby FanofSMBX » Fri Jun 05, 2015 12:21 pm

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.

Kevsoft
Flurry
Flurry
Posts: 375
Joined: Sun Jul 27, 2014 8:03 am

Re: LunaLua - Lunadll with lua [Streaming Question Poll]

Postby Kevsoft » Sat Jun 06, 2015 1:45 pm

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:
Spoiler: show
* 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.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari