How do I get a specific **string** among the others

0 favourites
  • 4 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • Is it possible to get a specific letter or number in a string type value?

    Example:

    Retrieve LayoutName (Which is 1ABCDx2) and get x2, or AB, or 1, etc.

    It's easy for numbers but for string I don't even know if it's possible.

  • This page is your very best friend (and mine too - any time a question about manipulating some values pops up there's a good chance the answer is there): https://www.scirra.com/manual/126/system-expressions

  • If you wanna check for that string in the name you can use:

    find(LayoutName, string)

    ex: find("1ABCDx2", "x2") would return 5.

    If you wanna get the string from the name you can use one of the expressions below:

    left(LayoutName, count)

    right(LayoutName, count)

    mid(LayoutName, index, count)

    ex:

    left("1ABCDx2", 1) would return "1".

    right("1ABCDx2", 2) would return "x2".

    mid("1ABCDx2", 1, 2) would return "AB".

    And you could even use both together:

    mid("1ABCDx2", find("1ABCDx2", "A"), 2) would return "AB".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you wanna check for that string in the name you can use:

    find(LayoutName, string)

    ex: find("1ABCDx2", "x2") would return 5.

    If you wanna get the string from the name you can use one of the expressions below:

    left(LayoutName, count)

    right(LayoutName, count)

    mid(LayoutName, index, count)

    ex:

    left("1ABCDx2", 1) would return "1".

    right("1ABCDx2", 2) would return "x2".

    mid("1ABCDx2", 1, 2) would return "AB".

    And you could even use both together:

    mid("1ABCDx2", find("1ABCDx2", "A"), 2) would return "AB".

    Thank you, brunopalermo.

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