This is the place for discussion and support for LunaLua and related modifications and libraries.
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?
|
|
|
|
-
PersonNamedUser
- Birdo
- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Sun Feb 05, 2017 6:39 pm
How do you make an npc's dialogue change based on which character your playing as?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Sun Feb 05, 2017 6:49 pm
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
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Birdo
- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Sun Feb 05, 2017 7:51 pm
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?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon Feb 06, 2017 12:56 am
What event
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Birdo
- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Mon Feb 06, 2017 1:25 am
Enjl wrote:What event
Do you insert a event in the code?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon Feb 06, 2017 1:28 am
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.
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Birdo
- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Mon Feb 06, 2017 1:35 am
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?
|
|
|
|
|
|
|
|
|
-
Danny
- Reznor
- Posts: 4001
- Joined: Fri Dec 20, 2013 1:12 pm
- Pronouns: He/Him, They/Them
Postby Danny » Mon Feb 06, 2017 2:08 am
"Msgstr" means "Message String" as far as I'm concerned.
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon Feb 06, 2017 5:56 am
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)
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Birdo
- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Mon Feb 06, 2017 10:15 am
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?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Mon Feb 06, 2017 12:18 pm
Show me the text that the NPC has in-game.
|
|
|
|
|
|
|
|
|
-
PersonNamedUser
- Birdo
- Posts: 2882
- Joined: Fri Feb 27, 2015 8:07 pm
Postby PersonNamedUser » Mon Feb 06, 2017 8:36 pm
Literally that's all that comes up, do you know what i'm doing wrong?
|
|
|
|
|
|
|
|
|
-
Emral
- Cute Yoshi Egg
- Posts: 9722
- Joined: Mon Jan 20, 2014 12:58 pm
- Flair: Phoenix
Postby Emral » Tue Feb 07, 2017 12:56 am
It should be "ScubaTalk" like I said in my first post in this topic.
|
|
|
|
|
Return to “LunaLua”
Users browsing this forum: No registered users and 4 guests
|