Need help with lua? - LunaLua General Help

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?
HeroLinik
Larry Koopa
Larry Koopa
Posts: 3464
Joined: Fri Dec 20, 2013 1:28 pm
Contact:

Re: Need help with lua? - LunaLua General Help

Postby HeroLinik » Sat Mar 18, 2017 11:05 am

Devan2002 wrote:
HeroLinik wrote:
Devan2002 wrote:Can someone use lua to replace a Super Metroid sound effect with the sound from Lttp (when a closed door opens because all of the enemies are defeated)?
You don't need LunaLua. Provided you have 2.0, all you can do is make a sounds.ini file and replace the sound effect through there.
I'm using 1.3.0.1. Btw, is it possible to change sound effects on 1.3.0.1?
No, it's not.

Devan2002
Chain Chomp
Chain Chomp
Posts: 304
Joined: Sun Oct 02, 2016 9:46 am

Re: Need help with lua? - LunaLua General Help

Postby Devan2002 » Sat Mar 18, 2017 7:27 pm

HeroLinik wrote:
Devan2002 wrote:
HeroLinik wrote: You don't need LunaLua. Provided you have 2.0, all you can do is make a sounds.ini file and replace the sound effect through there.
I'm using 1.3.0.1. Btw, is it possible to change sound effects on 1.3.0.1?
No, it's not.
I don't know how even when replacing the sound effect and renaming it to what the replaced sound was, it's still the same sound effect...

underFlo
Wart
Wart
Posts: 4456
Joined: Mon Jul 14, 2014 10:44 am
Flair: sup im lesbiab
Pronouns: They/She
Contact:

Re: Need help with lua? - LunaLua General Help

Postby underFlo » Sat Mar 18, 2017 8:23 pm

He literally just said it doesn't work with the version you're using so what exactly are you trying to say?

Devan2002
Chain Chomp
Chain Chomp
Posts: 304
Joined: Sun Oct 02, 2016 9:46 am

Re: Need help with lua? - LunaLua General Help

Postby Devan2002 » Sat Mar 18, 2017 8:43 pm

Spinda wrote:He literally just said it doesn't work with the version you're using so what exactly are you trying to say?
I'm trying to say, that if you replaced a sound effect with a different one, and renamed the different one to the one you just replaced, it will still play the original sound.

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Mar 19, 2017 7:09 am

Devan2002 wrote:
Spinda wrote:He literally just said it doesn't work with the version you're using so what exactly are you trying to say?
I'm trying to say, that if you replaced a sound effect with a different one, and renamed the different one to the one you just replaced, it will still play the original sound.
Where are you putting these new files?

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Sun Mar 19, 2017 6:08 pm

I think that what Devan2002 is saying is that replacing the game's sound files should work. It does work, but doing that replaces the sound in every level. HeroLinik means that in 1.3 you can't replace the sound on a per-level or per-episode basis.

mariogeek2
Rocky Wrench
Rocky Wrench
Posts: 697
Joined: Tue Jan 28, 2014 5:46 pm

Re: Need help with lua? - LunaLua General Help

Postby mariogeek2 » Fri Mar 24, 2017 10:46 am

So, just curious, is it possible to adjust the player's hitbox using LunaLua? If so, how would you do that?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9890
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Need help with lua? - LunaLua General Help

Postby Emral » Fri Mar 24, 2017 10:51 am

mariogeek2 wrote:So, just curious, is it possible to adjust the player's hitbox using LunaLua? If so, how would you do that?
Use the PGE Player calibrator tool.

TDK
Phanto
Phanto
Posts: 1440
Joined: Wed Nov 11, 2015 12:26 pm
Flair: Retired

Re: Need help with lua? - LunaLua General Help

Postby TDK » Tue Mar 28, 2017 11:42 am

Quick question, how to temporarily speed up music?

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Wed Mar 29, 2017 4:10 pm

I don't think there's currently a way to do that.

TDK
Phanto
Phanto
Posts: 1440
Joined: Wed Nov 11, 2015 12:26 pm
Flair: Retired

Re: Need help with lua? - LunaLua General Help

Postby TDK » Wed Mar 29, 2017 5:27 pm

Quantumenace wrote:I don't think there's currently a way to do that.
Oh, that's a shame.
At least I got a backup plan.

Also, how to make a mushroom have no effect?

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Wed Mar 29, 2017 6:30 pm

As in not do anything when the player touches it?

TDK
Phanto
Phanto
Posts: 1440
Joined: Wed Nov 11, 2015 12:26 pm
Flair: Retired

Re: Need help with lua? - LunaLua General Help

Postby TDK » Wed Mar 29, 2017 6:31 pm

PixelPest wrote:As in not do anything when the player touches it?
Yes.

Quantumenace
Chain Chomp
Chain Chomp
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Need help with lua? - LunaLua General Help

Postby Quantumenace » Thu Mar 30, 2017 5:36 pm

I guess that depends on what exactly you intend to do. Either set its "friendly" flag to true, or use the axe and make it look like a mushroom.

TDK
Phanto
Phanto
Posts: 1440
Joined: Wed Nov 11, 2015 12:26 pm
Flair: Retired

Re: Need help with lua? - LunaLua General Help

Postby TDK » Thu Mar 30, 2017 7:50 pm

I just want to change the effects of the mushroom.

FanofSMBX
Ludwig von Koopa
Ludwig von Koopa
Posts: 3878
Joined: Sun Dec 22, 2013 12:01 pm

Re: Need help with lua? - LunaLua General Help

Postby FanofSMBX » Thu Mar 30, 2017 10:23 pm

You can just use the ? mushroom if you're not in 2 player, because it swaps player positions but does nothing in 1 player mode.

PersonNamedUser
Reznor
Reznor
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: Need help with lua? - LunaLua General Help

Postby PersonNamedUser » Sat Apr 01, 2017 9:02 pm

Okay, i wrote a new code for the boost dash ability, but i have a few questions
1. NOW is it almost correct?
2. How do you fix this error? I tried putting ends down in certain places but to no avail.
Image
3. and pixelpest, don't be too blunt about me not know this

Code: Select all

local dashsound = Audio.playSFX("dash.wav")
local haveBoosted = false;
local haveBoostedDown = false;

function onLoop()
	if player:mem(0x146, FIELD_WORD) == 2 then
		HaveBoosted = false;
		HaveBoostedDown = false;
	end
end

function onStart()
   for i = 1, 7 do
      Level.loadPlayerHitboxes(4, i, "toad-"..tostring(i)..".ini");
	end
end

function OnLoop()
	if player.jumpKeyPressing == true then
	if (player:mem(0xF8, FIELD_WORD) == -1)then
	if player.rightKeyPressing == true then
	if haveBoosted == false then
		player.speedX = -5
		Audio.playSFX("dash.wav")
		do haveBoosted = true;
		end
	elseif player.leftKeyPressing == true then
	if haveBoosted == false then
		player.speedX = 5
		Audio.playSFX("dash.wav")
		do haveBoosted = true;
		end
	elseif player.downKeyPressing == true then
	if haveBoostedDown == false then
		player.speedY = 5
		Audio.playSFX("dash.wav")
		do haveBoostedDown = true;
		do haveBoosted = true;
			end
		end
	end
end

PixelPest
Link
Link
Posts: 7111
Joined: Sun Jul 12, 2015 5:38 pm
Flair: Tamer of Boom Booms
Contact:

Re: Need help with lua? - LunaLua General Help

Postby PixelPest » Sun Apr 02, 2017 8:39 am

MosaicMario wrote:Okay, i wrote a new code for the boost dash ability, but i have a few questions
1. NOW is it almost correct?
2. How do you fix this error? I tried putting ends down in certain places but to no avail.
Image
3. and pixelpest, don't be too blunt about me not know this

Code: Select all

local dashsound = Audio.playSFX("dash.wav")
local haveBoosted = false;
local haveBoostedDown = false;

function onLoop()
	if player:mem(0x146, FIELD_WORD) == 2 then
		HaveBoosted = false;
		HaveBoostedDown = false;
	end
end

function onStart()
   for i = 1, 7 do
      Level.loadPlayerHitboxes(4, i, "toad-"..tostring(i)..".ini");
	end
end

function OnLoop()
	if player.jumpKeyPressing == true then
	if (player:mem(0xF8, FIELD_WORD) == -1)then
	if player.rightKeyPressing == true then
	if haveBoosted == false then
		player.speedX = -5
		Audio.playSFX("dash.wav")
		do haveBoosted = true;
		end
	elseif player.leftKeyPressing == true then
	if haveBoosted == false then
		player.speedX = 5
		Audio.playSFX("dash.wav")
		do haveBoosted = true;
		end
	elseif player.downKeyPressing == true then
	if haveBoostedDown == false then
		player.speedY = 5
		Audio.playSFX("dash.wav")
		do haveBoostedDown = true;
		do haveBoosted = true;
			end
		end
	end
end
You're missing a lot of ends. You need one for each if, elseif, etc. even if they're consecutive. Also, instead of dong something like this:

Code: Select all

if a == 2 then
   if b then
      if c == "foo" then
      end
   end
end 
Do this instead:

Code: Select all

if (a == 2) and (b) and (c == "foo") then
end 
I've mentioned this before too and also told you to use onTick()

Devan2002
Chain Chomp
Chain Chomp
Posts: 304
Joined: Sun Oct 02, 2016 9:46 am

Re: Need help with lua? - LunaLua General Help

Postby Devan2002 » Sun Apr 02, 2017 11:06 am

How would I make it so that if I wanted enemies to have a change of dropping a bomb or a key when Link kills it, how would you it?

PersonNamedUser
Reznor
Reznor
Posts: 2882
Joined: Fri Feb 27, 2015 8:07 pm

Re: Need help with lua? - LunaLua General Help

Postby PersonNamedUser » Sun Apr 02, 2017 10:45 pm

Of course when i fix one problem i run into another one.

Basically, no error message comes up when i run the level, but the code literally isn't doing crap, do you
know why?
This is it by the way:

Code: Select all

local haveBoosted = false;
local haveBoostedDown = false;

function onTick()
	if player:mem(0x146, FIELD_WORD) == 2 then
		HaveBoosted = false;
		HaveBoostedDown = false;
	end
end

function onStart()
     Level.loadPlayerHitBoxes(4, 1, "toad-1.ini")
	 Level.loadPlayerHitBoxes(4, 2, "toad-2.ini")
	 Level.loadPlayerHitBoxes(4, 3, "toad-3.ini")
	 Level.loadPlayerHitBoxes(4, 4, "toad-4.ini")
	 Level.loadPlayerHitBoxes(4, 5, "toad-5.ini")
	 Level.loadPlayerHitBoxes(4, 6, "toad-6.ini")
     Level.loadPlayerHitBoxes(4, 7, "toad-7.ini")
end

function OnTick()
		if player:mem(0x146, FIELD_WORD == 0) and (player:mem(0xF4, FIELD_WORD) == true) and player.rightKeyPressing then 
		if haveBoosted == false then
		player.speedX = -5
		Audio.playSFX("dash.wav")
		do haveBoosted = true;
		end
		elseif player:mem(0x146, FIELD_WORD == 0) and (player:mem(0xF4, FIELD_WORD) == true) and player.leftKeyPressing then 
		if haveBoosted == false then
		player.speedX = 5
		Audio.playSFX("dash.wav")
		do haveBoosted = true;
		end
		elseif player:mem(0x146, FIELD_WORD == 0) and (player:mem(0xF4, FIELD_WORD) == true) and player.downKeyPressing then 
		if haveBoostedDown == false then
		player.speedY = 5
		Audio.playSFX("dash.wav")
		do haveBoostedDown = true;
		do haveBoosted = true;
						end
					end
				end
			end
		end
	end
end
btw, i know i changed back the hitbox code, but the other didn't work for me for some reason.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 4 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari