Creating a conversation between the player and an NPC
cezimo
Member Posts: 4
Here's what I need to happen:
When the user presses the space bar, actor 1 displays text from a table cell. When they press the space bar again, actor 2 displays text from another table cell. When the space bar is pressed a third time, actor 1's text changes to another cell, and so on and so forth. (The NPC will also ask questions that the player can answer with different keys (a=yes, b=no) to branch the conversation in unique directions, but perhaps I shouldn't worry about that right now.)
I've been able to get it started, I just can't figure out how to use the same key to change an actor's text once the initial text is already displayed there.
I've examined multiple threads here and the websites and tutorials people posted as answers, but none of them were specific enough (I'm pretty new at this). Any help would be appreciated. Also, if anyone thinks there is a better way to do this, I am open to new ideas (I am drawn to using tables right now since I believe it will keep the game smaller and faster).
Thanks.
When the user presses the space bar, actor 1 displays text from a table cell. When they press the space bar again, actor 2 displays text from another table cell. When the space bar is pressed a third time, actor 1's text changes to another cell, and so on and so forth. (The NPC will also ask questions that the player can answer with different keys (a=yes, b=no) to branch the conversation in unique directions, but perhaps I shouldn't worry about that right now.)
I've been able to get it started, I just can't figure out how to use the same key to change an actor's text once the initial text is already displayed there.
I've examined multiple threads here and the websites and tutorials people posted as answers, but none of them were specific enough (I'm pretty new at this). Any help would be appreciated. Also, if anyone thinks there is a better way to do this, I am open to new ideas (I am drawn to using tables right now since I believe it will keep the game smaller and faster).
Thanks.
Best Answers
-
kinzua Posts: 554@cezimo it won't be any hassle to do such a thing with GS.
Have two tables.. HeroText and VillagerText.. then create an 3 Integer Attribute... for say 'dialog' & 'HeroDialogNum' & 'VillagerDialogNum'
Now when space is pressed change attribute dialog=((dialog+1)%2). By doing this function, you'll always have dialog as 0 or 1.
So when dialog=0, change 'HeroDialogNum' = 'HeroDialogNum' +1
and when dialog=1, change 'VillagerDialogNum' = 'VillagerDialogNum' +1
Now call your dialog from the tables,
when dialog =0, diaplayText from tableCellValue(HeroText, HeroDialogNum, 1)
when dialog =1, diaplayText from tableCellValue(VillagerText, VillagerDialogNum, 1)
Hope this helps. -
tatiang Posts: 11,949Okay, here's my first attempt. I think it's pretty good but it may be hard to follow. I've added notes to the actors to try and make it more understandable but I would recommend starting with the table or included CSV file in order to see how the dialog progresses and "branches." Row 1 of the table/CSV is the NPC's text while row 2 is the Player's text. Click anywhere in the scene to advance the dialog.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
Also, in order to have multiple paths of the conversation, would I use the "otherwise" part of the rule to change keys (as in A pressed directs the convo to the yes thread and B pressed directs the convo to the no thread)? I think this may be achieved with multiple columns in my table (a yes column and a no column), but my brain is still grasping.
Thank you so much for your help.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Let me see what I can do...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Greenleaf Games --> http://greenleafgames.wordpress.com/
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User