How do I use instance variables in text from a project file?

0 favourites
  • 2 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Currently I am using an XML file to store dialog. However, I'm having trouble using that to call instance variables.

    An example:

    In the XML file there might be text like "Hello,", and when I print that, the text reads as '' instead of the 'name' value stored in the Player object. I'm wondering if there is a way around that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, it doesn't work like that.

    You need to insert player's name into the text using events.

    Change you text in the XML to something like this:

    "Hello %player%, you have %gold% coins."

    Before displaying the text on the screen you need to search for %player% and %gold% tags and replace them:

    message= Replace(message, "%player%", Player.Name)

    message= Replace(message, "%gold%", str(Player.GoldAmount))

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