How do I include an expression into a dictionary value?

0 favourites
  • 3 posts
From the Asset Store
Add this awesome sound effects to make your visual novel come to life!
  • Hello everyone!

    I want to make a tutorial in my game, but it needs to work with customized controls.

    My tutorial texts are in the localization file and I need to add the key names there, but they are variables that player can change when setting up the controls, so I need to insert them as a variable name.

    Is there any way to write an expression inside a dictionary value?

  • No. Dictionaries only save text/numbers. You will have to do a string substituion here. An extra expression was added just recently to easily do this! It's in the recent beta release.

    Value stored in Dictionary: "Press {0} to jump"

    StringSub(Dictionary.Get("tutorialJump"), "J")

    Result: "Press J to jump"

    You can replace J with whatever expression you like. You can also add as many substitutions as you need like

    "Press {0}, {1}, {2}, {3} to move"

    StringSub(Dictionary.Get("tutorialMove"), "W", "S", "A", "D")

    Result: "Press W, S, A, D to move"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much for help!

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