How do I set a variable with array data?

From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • I'm looking to set a description on a card from data in an array that contains a variable, something like 'Deal card.damage damage'. Does anyone know a decent way of creating this where the variable appears in the middle of the text?

    I know of a way where I can set it on the card itself of course, like set description to "Deal"&variable&"damage" but I'd like to use one event for all cards where I can pull data from an array that includes the variables, if anyone has any ideas...

  • I usually do this by inserting tags into text. For example:

    "Hello, %playername%! You have %coins% gold."

    Then replace these tags before displaying the text:

    Set t to replace(t, "%playername%", Player.name)

    Set t to replace(t, "%coins%", NumberOfCoins)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Nice idea but I think it only works for text and I'm looking to replace with a number to do some calculations, point of this is to use a value which can be altered any time during gameplay such as a damage amount. Do you know if something similar is possible with numbers?

    edit: I guess I can do calculations then use replace with str(variable), bit fiddly but it may work

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