Extending the JSON Dialogue System

9

Index

Attached Files

The following files have been attached to this tutorial:

.c3p

extendedjsondialogueexample.c3p

Download now 173.58 KB

Stats

6,009 visits, 11,866 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Using a Function to Format your Dialogue

This was touched on in the first tutorial, but I’m going to take it a bit further in this one. The example file included shows off a lot more of the BBCode tags you can use with the Text object, so the function does look a tad unwieldy! You might not need all of the tags, but it's good to show them working!

Essentially, each action runs through the current line of dialogue and replaces a specific value in the text to the correct BBCode tag. This is then set as the return value for the function which is then used to display the correctly formatted text.

You’ll need to make sure that you’re using the correct tags for your specific situation though. Spritefont objects and Text objects use different BBCode tags for formatting, and you can see which ones are usable on the manual pages for each object.

You may have noticed that at the end of this rather large function, there is a replace expression which has nothing to do with BBCode. You can also use this function to replace sections of the text with a variable! In this example, there’s a global variable called PlayerName, which can then be plugged into the replace expression so that whenever the term ‘PlayerName’ is used in the JSON file, it’s replaced by the value stored in the variable!

So, your text looks good, but what else can we do with dialogue? Well, how about calling functions?

Next Tutorial In Course

Branching Dialogue using JSON 08:09

Adding branching and 'event' dialogue to the JSON system.

  • 2 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Hello, I'm Giuseppe from Italy.

    I tried to use this method to my buttons in Construct 3, but it dosen't work, why?

    Here I put my example code:

    nCasuale: random number

    Questiti.At(nCasuale,1): bidimensional array of sentencies (X,Y), where I inserted the /br code

    Line: string variable

    + System: on functio CreaQuesito

    -> Sistema: set text to Quesiti.At(nCasuale,1)

    -> Tasto01: set text to replace(line,"/br",newline)

    -> Tasto01: [Set CSS style "font-size" to "18px"]

    I hope you can help me

    Giuseppe