How do I use string to update dialogues?
In this article, we'll see how to use strings to update dialogues! It seems not to very useful at first side because the you can can create up to 32767 text boxes but I wrote this as an introduction to strings for newbies.
Strings combined with tags[edit]
Typing the text between parenthesis directly[edit]
First choose a string number to use. In this example it will be 6. Then go under custom.exe and pick up a free text box. (In this example it will be text box 17). Write in it :
$={s6}
To update dialogues, we'll use tags. It will be named tag:quest1 (Why this name? Well because Npcs dialogues have to be updated most of the time when a quest ends.
Edit the .hsi file and then go under windows without leaving custom.exe (if possible). Now, you can open your hss file and include the following script
global variable (dialogue update) #-------------------------------------------------------------------------------- plotscript, dialogue using strings, begin suspend player suspend npcs $6="Hello! How are you?" set tag (tag: quest1, on) if (check tag (tag: quest1)==on) then, begin $6= "No; I haven't seen him" end# end for the tag show text box (17) wait for text box resume player resume npcs end #end of the script #--------------------------------------------------------------------------------
Compile the .hss file and import it. Edit one of the npc on the testing map and make him/her run "dialogue using strings" (it's the bottom one). Then save your game datas and test
the whole thing! The first time you'll see "How are you?" and the second time (because the tag have been turned on, you'll see "No; I haven't seen him"
You can now see the interest of using string! It save up tags. Let's compare with the example above.
#-------------------------------------------------------------------------------- plotscript, dialogue using many textboxes, begin if (check tag (tag: quest1)==on) then, begin show text box (18) #contains "No; I haven't seen him" wait for text box set tag (tag: quest1, on) end, else, begin show text box (17) #contains "Hello! How are you?" wait for text box end #end for the if check tag end #end of the script #--------------------------------------------------------------------------------
As you can see we have saved a text box. In the first script on we use one. The code keeps showing the same textbox but the player doesn't notice it because the dialogue had been updated through string. Typing directly is not the only way to do this. We can also use plotscripting.
The plotscript command : textbox line[edit]
In our situation we could also use textboxline. Go under custom.exe edit the textbox menu, pick-up a free one. On the first line write
Hello! How are you?
and on the second one
No, I haven't seen him.
The command count line from zero. In your text box, you see
As you can see with the notes in read the command counts differently. So let's adapt the script
#-------------------------------------------------------------------------------- plotscript, dialogue using strings, begin suspend player suspend npcs textbox line (6, 29, 0) # corresponds to the line "Hello! How are you?" set tag (tag: quest1, on) if (check tag (tag: quest1)==on) then, begin textbox line (6, 29, 1) # corresponds to the line "No; I haven't seen him" end# end for the tag show text box (17) wait for text box resume player resume npcs end #end of the script #--------------------------------------------------------------------------------
With this method we get the same result. We can keep on displaying the same text box over and over on
both cases but we have also a "hidden text" box, text 29. Even if we used in reality, 2 text boxes,
we can still save up text boxes in the long run, because without string, we would need to use a free
text box each time, a NPC as a line of text to say. In the next section we're going to see a much more
powerful method involving global variable
Strings combined with a global variable[edit]
Just like in the previous section, you can choose to use to type the text directly into parenthesis or to use the command textbox line. It's the method to check that the text had been displayed which changes. Here we are going to use the powerfull switch command.
Typing the text between parenthesis directly[edit]
First choose a string number to use. In this example it will be 6. Then go under custom.exe and pick up a free text box. (In this example it will be text box 17). Write in it.
$={s6}
To update dialogues, we'll use a global variable. It will be named dialogue update (Why this name? Well because Npcs dialogues have to be updated all along the game. Edit the .hsi file and then go under windows without leaving custom.exe (if possible). Now, you can open your hss file and include the following script
global variable (25, dialogue update) #------------------------------------------------ plotscript, dialogue using strings NPC1, begin suspend player suspend npcs switch (dialogue update), do begin case (0) do, begin $6= "Hello! How are you?" wait (2) show text box (17) wait for text box end #end for the case case (1) do, begin $6= "No; I haven't seen him" wait (2) show text box (17) wait for text box end# end for the case end #end for the switch resume player resume npcs end #end of the script #------------------------------------------------------
Compile the .hss file and import it. Edit one of the npc on the testing map and make him/her run "dialogue using strings NPC1" (it's the bottom one). Then save your game datas and test the whole thing! The first time you'll see "How are you?" and the second time (because the value has changed, you'll see
"No; I haven't seen him"
How do you change the value you may ask. Well, you need to include the following line :
dialogue update:=1
When the player will get the information that he needs to search for someone who has not been seen by this NPC. Note that when the game starts all the global variable has 0 as a value.
Why did I say that the switch command is powerful? Well because a global variable can take a lot of different values, which means you'll save a lot of tags. By noting carefully (on a side text file maybe?) which event correspond to which number, you can save up all your tags used only one time to update dialogues for whole of the npcs of the game. Incredible isn't it!
Just like with the tag method, we can save a lot of textboxes by using strings.
Compare this script with the one above
global variable (25, dialogue update) #----------------------------------------------------------- plotscript, dialogue using many textboxes, begin suspend player suspend npcs switch (dialogue update), do begin case (0) do, begin show text box (17) wait for text box end #end for the case case (1) do, begin show text box (18) wait for text box end# end for the case end #end for the switch resume player resume npcs end #end of the script #----------------------------------------------
As you can see we have saved a text box. In the first script on we use one. The code keeps repeating itself but the player doesn't notice it because the dialogue had been updated through string. Now let's see what happens with the plotscript command : textline
The plotscript command : textbox line[edit]
Global variables also works with textboxline. As always, go under custom.exe edit the textbox menu, pick-up a free one. On the first line write
Hello! How are you?
and on the second one
No, I haven't seen him.
The command count line from zero. In your text box, you see
As you can see with the notes in read the command counts differently.
So let's adapt the script
global variable (25, dialogue update) #----------------------------------------------------------- plotscript, dialogue using strings, begin suspend player suspend npcs switch (dialogue update), do begin case (0) do, begin textbox line (6, 29, 0) show text box (17) wait for text box end #end for the case case (1) do, begin textbox line (6, 29, 0) show text box (17) wait for text box end# end for the case end #end for the switch resume player resume npcs end #end of the script #-----------------------------------------------------------------------
With this method we get the same result. We can keep on displaying the same text box over and over on
both cases but we have also a "hidden text" box, text 29. Even if we used in reality, 2 text boxes,
we can still save up text boxes in the long run, because without string, we would need to use a free
text box each time, a NPC as a line of text to say.
Conclusion[edit]
If your dialogues have many lines, you may want to switch from textbox line to textbox text
This article has not covered dialogues in foreign languages/ and or with special characters. The principal is the same except that we need to use "append ASCII" on top of the commands seen in the article. By a foreign language, I mean the one which uses the roman alphabet. Sadly the font size does not allow to display, kanji or arabic letters with the edit box system. Feel free to consult the links above for more details.
You can also update without using strings. As it was not the subject of this article, we only mention the most basic alternatives: using several text boxes edited under custom and the command show text box.
See Also[edit]
- How to use NPCs and Tags
- How do I make an NPC say something different later?
- How do I make a battle start after talking to an NPC?
- Using the special letters of foreign languages
- How do I make dialogues with letter that has accents or in a foreign language?
- Will you ever support TTF fonts?
- How do I make fonts?