How do I make a dialogue string show a string/variable?

0 favourites
From the Asset Store
A small template showing how to build a firebase ranking
  • Set variable1 to replace(...)

    Typewriter text variable1

    I'm just thinking that typewriter might get confused by the replace stuff, so do the replace before.

    It doesn't work.. Any ideas?

    PROJECT LINK:

    drive.google.com/file/d/16hFsSJuBEJtvFeasUdDucM5dgD17ZU9K/view

  • You need to watch/read some beginner tutorials, it's clear that you don't quite understand how events work in Construct.

    There is a function called FormatDialogue in your project. It prepares a line of dialogue before it's displayed by replacing some tags in the text. You can use this function to replace the tags you added. Just add another action to it (before "Set Return Value")

    For example:

    Set Line to replace(ReplaceString,"INTERACTNAME", interactNameVariable)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Any tutorials you'd recommend in specific?

  • I know I'm pretty dumb, and this is probably a simple fix, but-- could you explain what went wrong here?

  • Actually, this is a mistake made by the author of the game template. You need to use Set Line to replace(Line,...) in the second and all consecutive actions:

  • Thank you so much!

  • Good spot dop2000 - the rest of the examples in that course should be correct, but I obviously missed the copy/paste when I was building that. The tutorial project has now been updated too.

  • You can use regular expressions \{(\S+)\} to replace string variables.

    1. Save variable in dictionary

    2. Get the value in the dictionary by key in the string.

    	Hi, {name}. You Have {gold} gold!
    

    ---

    (need 'Dictionary' object types)

    {"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"variable","name":"REGEX_VARIABLE","type":"string","initialValue":"\\{(\\S+)\\}","comment":"{gold}","isStatic":true,"isConstant":true},{"functionName":"ParseFormat","functionDescription":"","functionCategory":"","functionReturnType":"string","functionIsAsync":false,"functionParameters":[{"name":"source","type":"string","initialValue":"","comment":""}],"eventType":"function-block","conditions":[],"actions":[],"children":[{"eventType":"variable","name":"parseText","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[{"id":"test-regex","objectClass":"System","parameters":{"string":"source","regex":"REGEX_VARIABLE","flags":"\"\""}}],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"parseText","value":"source"}}],"children":[{"eventType":"block","conditions":[{"id":"for","objectClass":"System","parameters":{"name":"\"\"","start-index":"0","end-index":"RegexMatchCount(source, REGEX_VARIABLE, \"g\") - 1"}}],"actions":[],"children":[{"eventType":"variable","name":"MatchKey","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"variable","name":"MatchValue","type":"string","initialValue":"","comment":"","isStatic":false,"isConstant":false},{"eventType":"block","conditions":[],"actions":[{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"MatchKey","value":"RegexMatchAt(source, REGEX_VARIABLE, \"g\", loopindex)"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"MatchValue","value":"Dictionary.Get(mid(MatchKey, 1, len(MatchKey)-2))"}},{"id":"set-eventvar-value","objectClass":"System","parameters":{"variable":"parseText","value":"RegexReplace(ParseText, REGEX_VARIABLE, \"\", MatchValue)"}}]}]},{"eventType":"block","conditions":[],"actions":[{"id":"set-function-return-value","objectClass":"Functions","parameters":{"value":"parseText"}}]}]},{"eventType":"block","conditions":[{"id":"else","objectClass":"System"}],"actions":[{"id":"set-function-return-value","objectClass":"Functions","parameters":{"value":"source"}}]}]}]}
    
  • This also helps with a lot of questions I had in my head. I'll be using the dictionary for my inventory system!! :D <3

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