Creating a conversation between the player and an NPC

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.

Best Answers

  • kinzuakinzua Posts: 554
    Accepted Answer
    @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.
  • tatiangtatiang Posts: 11,949
    Accepted Answer
    Okay, 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

  • cezimocezimo Member Posts: 4
    Thank you, @kinzua. This has been helpful. I'm really close. The dialogue plays in order like it should, but when actor 2 is displaying text, actor 1 is blank. When actor 1 continues with the next line, actor 2 is blank and so on. Basically, only one actor displays text at a time when (ideally) the actor would show his last line of text until it's new one appears. Is it possible to do this? I'm totally willing to cut my losses if this is as good as it will get.

    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.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Nothing you're wanting to do is particularly difficult with tables. It's all dependent on how you organize the tables. I might be able to make you a demo given some time (I'm quite busy) but you should check out Twin Swords (http://forums.gamesalad.com/discussion/54887/twin-swords-blade-of-the-phoenix-by-pom/p1) and maybe its creator @POM can lend some insights.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • cezimocezimo Member Posts: 4
    @tatiang, I totally understand. I'm pretty busy too (I'm a design major at the University of Texas in Austin, USA and I chose a pretty ambitious senior project for myself). If you do feel like making a demo, I'd greatly appreciate it. I'm in the frustrating part of learning a new program, which is the "learn by copying" phase. I'm getting better, but I still don't know how to use the program's tools to my advantage. Anyway, thanks for responding.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Wait, there's a phase after "learn by copying?" :P

    Let me see what I can do...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • cezimocezimo Member Posts: 4
    @tatiang Oh my gosh, this is amazing. Thank you so much. I'm going through and digesting all of it now. @kinzua, would you guys mind if I credit you in a "special thanks" section of my game to say thank you? You guys have been incredibly helpful and benevolent.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @cezimo You're welcome! And thank yous or credits are always a nice thing. :)

    Greenleaf Games --> http://greenleafgames.wordpress.com/

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.