Page 1 of 1

How to do it?

Posted: Sun Feb 05, 2017 6:39 pm
by PersonNamedUser
How do you make an npc's dialogue change based on which character your playing as?

Re: How to do it?

Posted: Sun Feb 05, 2017 6:49 pm
by Emral
Link the dialogue to lua by making it some sort of code. I like to call them stuff like "goombaTalk" for if it's a Goomba, etc...
once you got the message in SMBX set to your code, you make an onMessageBox function:

Code: Select all

function onMessageBox(eventObj, msgStr)
	if msgStr == "goombaTalk" then
		eventObj.cancelled = true --cancels the message from displaying
		if player.character == 1 then
			Text.showMessageBox("Actual Message")
		elseif player.character == 2 then
			Text.showMessageBox("Other Message")
			Text.showMessageBox("he gets 2")
		end
	end
end

Re: How to do it?

Posted: Sun Feb 05, 2017 7:51 pm
by PersonNamedUser
Enjl wrote:Link the dialogue to lua by making it some sort of code. I like to call them stuff like "goombaTalk" for if it's a Goomba, etc...
once you got the message in SMBX set to your code, you make an onMessageBox function:

Code: Select all

function onMessageBox(eventObj, msgStr)
	if msgStr == "goombaTalk" then
		eventObj.cancelled = true --cancels the message from displaying
		if player.character == 1 then
			Text.showMessageBox("Actual Message")
		elseif player.character == 2 then
			Text.showMessageBox("Other Message")
			Text.showMessageBox("he gets 2")
		end
	end
end
It didn't work, are supposed to put in the name of the event somewhere?

Re: How to do it?

Posted: Mon Feb 06, 2017 12:56 am
by Emral
What event

Re: How to do it?

Posted: Mon Feb 06, 2017 1:25 am
by PersonNamedUser
Enjl wrote:What event
Do you insert a event in the code?

Re: How to do it?

Posted: Mon Feb 06, 2017 1:28 am
by Emral
No????? The "eventObj" is the action of displaying the text box after talking to the npc. onMessageBox is activated every time this happens in the game.

Re: How to do it?

Posted: Mon Feb 06, 2017 1:35 am
by PersonNamedUser
Enjl wrote:No????? The "eventObj" is the action of displaying the text box after talking to the npc. onMessageBox is activated every time this happens in the game.
But what does Msgstr mean? what do i insert instead of goomba talk for the text happen?

Re: How to do it?

Posted: Mon Feb 06, 2017 2:08 am
by Danny
"Msgstr" means "Message String" as far as I'm concerned.

Re: How to do it?

Posted: Mon Feb 06, 2017 5:56 am
by Emral
You don't insert anything there. Those variables are passed by lua when the function is called. It works just like stuff like onNPCKill(eventObj, killedNPC, killReason)

Re: How to do it?

Posted: Mon Feb 06, 2017 10:15 am
by PersonNamedUser
Okay, i guess i'll just show you this, this is code i'm trying to use:

Code: Select all

function onMessageBox(eventObj, msgStr)
   if msgStr == "ScubaTalk" then
      eventObj.cancelled = true
      if player.character == 1 then
         Text.showMessageBox("Scuba:Hi there MosaicMario! How have you been?")
		 Text.showMessageBox("MosaicMario:Hey Scuba, It's been awhile, but, i actually had a question.")
		 Text.showMessageBox("Scuba: Sure! I'll tell you anything!")
		 Text.showMessageBox("MosaicMario: Well, do you have any important info you can give me?")
		 Text.showMessageBox("Scuba: Yeah! I heard that in an area you could only reach if you rode a magic carpet, there's a vase with a keyhole, a secert exit!")
		 Text.showMessageBox("MosaicMario: Hey, Thanks for telling me! See you another time!")
		 Text.showMessageBox("Scuba: It's Okay! Don't mention it.")
      elseif player.character == 2 then
         Text.showMessageBox("Scuba:Hi there Rosy! How are you doing?")
         Text.showMessageBox("Rosy: Oh, i'd say pretty fine")
		 Text.showMessageBox("Scuba: Well, did you- wait, are you blushing?")
		 Text.showMessageBox("Rosy: No, umm... it's just blush, do you have any tips for me?")
		 Text.showMessageBox("Scuba: Well... Okay, i do. I heard that in the subcon skies, there's a place with a vase that can only be reached with a magic carpet")
		 Text.showMessageBox("Rosy: Oh, thank you for telling me that... sweetie.")
		 Text.showMessageBox("Scuba: What?")
		 Text.showMessageBox("Rosy: Um, nothing.")
		 Text.showMessageBox("Scuba: Okay, see you another time i guess.")
	  elseif player.character == 3 then
		 Text.showMessageBox("Scuba: O-Oh h-hey there B-Berry.")
		 Text.showMessageBox("Berry: Yoshi!(Hi Scuba!)")
		 Text.showMessageBox("Scuba: U-Uh did you have a-a question?.")
		 Text.showMessageBox("Berry: Yoshi!(Yeah, do you know any important information about Subcon Valley?)")
		 Text.showMessageBox("Scuba: Y-Yeah, i-i know that y-you can find a-a keyhole somewhere i-in the sk-sk-sky.")
		 Text.showMessageBox("Berry: Yoshi!(Okay, thanks for telling me! See you later!(Why was he hesisting so much?)")
		 Text.showMessageBox("Scuba: O-Ok S-S-See you u-um, n-never.")
	  elseif player.character == 4 then
	     Text.showMessageBox("Scuba: Hey there Hoops! What have you been up too?")
		 Text.showMessageBox("Hoops: Um? Saving the world?)")
		 Text.showMessageBox("Scuba: Oh, that's pretty serious i guess, what brings you here?")
		 Text.showMessageBox("Hoops: Tell me, are you hiding something important?)")
		 Text.showMessageBox("Scuba: No, why would i hide anything? Infact, let me tell you something, I know that somewhere in the skies in subcon, you can find a vase that could on be reached with a magic carpet, even with a flight wing or such you couldn't reach it!")
		 Text.showMessageBox("Hoops: Wow, that's good to know, but now if you excuse me, i need to skitdaddle to save the world in time!")
		 Text.showMessageBox("Scuba: Alright, see you another day!")
	  elseif player.character == 5 then
	     Text.showMessageBox("Scuba: Umm, who are you? Did you need something?")
		 Text.showMessageBox("MosaicLink: Someone told me someone named Scuba would give me some valueable information, i just wasn't expecting you to be a fish.")
		 Text.showMessageBox("Scuba: Okay, let me give you that information. You may be able to find a vase somewhere in skies that you could only reach with a magic carpet that contains a keyhole.")
		 Text.showMessageBox("MosaicLink: Well, okay then, bye i guess.")
		 Text.showMessageBox("Scuba: Okay, bye stranger?")
      end
   end
end
Do you know what i'm doing wrong in this code?

Re: How to do it?

Posted: Mon Feb 06, 2017 12:18 pm
by Emral
Show me the text that the NPC has in-game.

Re: How to do it?

Posted: Mon Feb 06, 2017 8:36 pm
by PersonNamedUser
Image

Literally that's all that comes up, do you know what i'm doing wrong?

Re: How to do it?

Posted: Tue Feb 07, 2017 12:56 am
by Emral
It should be "ScubaTalk" like I said in my first post in this topic.

Re: How to do it?

Posted: Tue Feb 07, 2017 1:34 am
by PersonNamedUser
Thanks! It's working now!