How do I progress dialuge using the operator ?:

1 favourites
From the Asset Store
Progress\Loading Bar. Now Load you game like a Professional.
  • When talking to NPCs I want to click on them to bring up the next line of text. I have figured out a way that I like but it's only happening once.

    My code is-

    *Player_is overlapping_NPC ---> set text to- NPC.Variable=0?"blah,balh,blah":"nothing"&NPC.variable=1?"blah,blah,blah":"nothing"&NPC.variable =2?"blah,blah,blah":"nothing"&NPC.variable=3?"blah,blah,blah":"nothing"

    Subevent

    *on NPC clicked----> Add 1 to Variable

    When I click on the NPC it shows the 1st line of text, then when I click the second time it's shows the 2nd line. But if I try clicking anymore times it does nothing and stays the same.

    Does this mean i Cannot use the ?: indefinitely? Only twice?

  • You wouldn't use that operator in this scenario because for example when the variable is 2 you are trying to set the text but it will also run that 0 and 1 are false so set text to nothing, you are trying to set multiple texts at the same time. Just use a normal compare variable condition if variable=0 and if variable=1. Or to go one step further you could write all the dialogue as a string with a separator and use tokenat() expression where the index is the NPC variable.

  • You wouldn't use that operator in this scenario because for example when the variable is 2 you are trying to set the text but it will also run that 0 and 1 are false so set text to nothing, you are trying to set multiple texts at the same time. Just use a normal compare variable condition if variable=0 and if variable=1. Or to go one step further you could write all the dialogue as a string with a separator and use tokenat() expression where the index is the NPC variable.

    Thanks, Ya I was thinking that was what it was. I know how to do it that one other way but I was trying to look for another way that would save me room cause I'm writing a fairly long RPG story and that's alot to keep setting variable =1,2,3,4,5,6,7 etc and so on. When you said "that operator" do you mean to say there is another operator I can use or no there is no operator I can use at all?

    I have never used tokenat() before what's that do? May I see a screenshot example of the code your describing?

  • tokenat() will be helpful, it's maybe better explained. Keep the event where you add 1 to the variable on click to increase it. Have another string variable (here I refer to it as 'NPC.dialogue') on the NPC which is the entire dialogue they will have and write each message as one long bit of text with separators, such as "Hello_I am an NPC_Bye".

    Then with actions you set the text to tokenat(NPC.dialogue,NPC.variable,"_")

    This picks the source text so the string variable, the index which is the number and the separator which I used underscore. It allows you to move through one long string of text with each click, where the number variable is the position in the text.

    So when NPC.variable=0 it will show "Hello", when var is 1 it will show "I am an NPC" and when var is 2 it will show "Bye" etc.

    This is useful because you won't need any conditions to compare the variable and it will apply to all NPCs, very easy.

  • tokenat() will be helpful, it's maybe better explained. Keep the event where you add 1 to the variable on click to increase it. Have another string variable (here I refer to it as 'NPC.dialogue') on the NPC which is the entire dialogue they will have and write each message as one long bit of text with separators, such as "Hello_I am an NPC_Bye".

    Then with actions you set the text to tokenat(NPC.dialogue,NPC.variable,"_")

    This picks the source text so the string variable, the index which is the number and the separator which I used underscore. It allows you to move through one long string of text with each click, where the number variable is the position in the text.

    So when NPC.variable=0 it will show "Hello", when var is 1 it will show "I am an NPC" and when var is 2 it will show "Bye" etc.

    This is useful because you won't need any conditions to compare the variable and it will apply to all NPCs, very easy.

    Thank you so very much^^, this works wonderfully. I had to put the name of the object along with NPC.DIALUGE & .Variable for it to work but non the less it did.would you by any chance know how to restart it from the beginning when the player is done talking to em? The code I used before to do this now does not work.

    Condition

    NPC_DIALUGE > 4

    Action

    Set NPC_DIALUGE to 0

    Then when I go back to talk to them it'll say the same thing.

    And Do you know were I could also go to make "CHOICES" out of the Texts? I need to be able to choose which topic of descution to converse

  • You can check what the instance variable is doing in the debug view. Check if it goes above 4. What you are saying is there are 5 bits of dialogue and no 6th right? It should work really but you can share screenshot of that event if you are having trouble.

    For deciding between dialogue lines maybe you have to expand into an array to store complex dialogue. It really depends on the game. If you can happily choose between a few strings of dialogue you can still use this method by choosing between multiple string variables. So if topic A begins then choose NPC.dialogue1 and if topic is B then choose NPC.dialogue2. If it is to do with making choices and dialogue following on from options the player is selecting then that is more complex and maybe you need an array and a different approach.

  • You can check what the instance variable is doing in the debug view. Check if it goes above 4. What you are saying is there are 5 bits of dialogue and no 6th right? It should work really but you can share screenshot of that event if you are having trouble.

    For deciding between dialogue lines maybe you have to expand into an array to store complex dialogue. It really depends on the game. If you can happily choose between a few strings of dialogue you can still use this method by choosing between multiple string variables. So if topic A begins then choose NPC.dialogue1 and if topic is B then choose NPC.dialogue2. If it is to do with making choices and dialogue following on from options the player is selecting then that is more complex and maybe you need an array and a different approach.

    So sorry for late reply, just new years and job stuff I had to take care of. But ya the dialuge choice will be very simple, it's just for learning info for puzzles and story.i would like for example the choices to be- an Info "Topic A"(what land is this?), a Hint "Topic B" (where's the hidden key?), and a story "Topic C" (who are you?)

    Some Topics I'd like to loop back to the beginning dialuge when finished. And other Topics to close the conversation when finished.

    Would I be able to make the TEXT itself clickable with the "Touch" object? Otherwise how would I select em? Would a list object be easiest?

  • Yeah text object is clickable so you could use this. You'll have to build some kind of dialogue system. To return to the original text or close the dialogue you could even add that into the string of text as an identifier and compare.

  • Yeah text object is clickable so you could use this. You'll have to build some kind of dialogue system. To return to the original text or close the dialogue you could even add that into the string of text as an identifier and compare.

    How do I do that?

    Before I used to use an array but I ran into trouble with it.

    Then I tried the "choose" which had problems

    And then this way ya showed me seems the best and easiest. But if you know how to do choices with arrays that would be good. Or if ya know blogs I could look at. I can't do JSON though. I understand it but I keep messing up somewhere idk. I do everything it says and it just won't work lol.

  • With an array seems best so you can pull the choices from columns and the NPC would have an identifier for the row. I guess for simplicity you make it so that each choice clicked moves to same column for all NPCs. Then in each cell you can have the text string with separators as described above. There's a lot going on though if you have to select choices and then proceed through changing text. You would need to create the initial box with dialogue and choice maybe pulled from the first 4 columns of the array, then the text objects when clicked navigate to either 5,6 or 7.

    My approach to close the conversation or return to the base choices, you could in the string add something to the end so like "String1_String2_end" or "String1_String2_back" then as you proceed through the tokenat() you add another sub-condition if text=end then close the conversation, if text=back then return to that original text.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Actually I had some free time so I just made it, you can select the NPC to talk with then choices then keep clicking to progress the mini dialogue bit. Take some time to look at the file and understand it, so you know how to add more NPCs and edit it to fit your game. dropbox.com/s/ibut9p94tzj96mj/dialoguesys.c3p

  • Actually I had some free time so I just made it, you can select the NPC to talk with then choices then keep clicking to progress the mini dialogue bit. Take some time to look at the file and understand it, so you know how to add more NPCs and edit it to fit your game. dropbox.com/s/ibut9p94tzj96mj/dialoguesys.c3p

    Thank you very much it works beutifly it's exactlly what I needed. Though I may be stupid I'm sorry, I'm not sure how to mix it in with my current project. I was able to load it in with my project and "include event sheet", but when I ran it nothing happened.i put all the objects in as well. So I did try to just copy the code it in myself and the only issue is that the text isn't showing so idk what is wrong. Did I put in the code correctly? I named things differently but it shouldn't matter right? It may be because I have a dialuge layer. It's set to inicially visible as well as all text objects.

  • Does the touched NPC event have the sub events ? I would try and understand the file so you can suit it to your game. Copy and paste you will get lost later on if bugs occur.

  • Does the touched NPC event have the sub events ? I would try and understand the file so you can suit it to your game. Copy and paste you will get lost later on if bugs occur.

    Sub event? Mm, I didn't see any sub events anywere in the script. I think the script is running fine, it's just the text is staying invisible.

    But ya I'm confident now I can understand how to move forward with my dialuge system. Welp i dont wanna take up anymore of your time, I very much appreaciate your help. Thanks so much 😊 ^^

  • On the back and end conditions you are setting inchat to 0 twice, one of those should be a chatpos variable. That might cause it. Yes on my example open up the 'on touched NPC' event you will see it has sub events.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)