How do I find matching text within string values of two instance of single "Sprite"

0 favourites
  • 5 posts
From the Asset Store
OpenAI TTS
$9 USD
10% off
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • I have 2 instances of sprite "dot" in the layout. "dot" has a string variable "num".

    first instance's variable value is "1,2,4,7" and second instance's variable value is "3,7,8,9".

    Now in the event sheet How can I find matching number of both instance. Like in above two values 7 is matching.

    I know it can be done using tokenat expression but how to compare two instance of same image.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could set the first instance variable to a global or local variable and compare that against the other instance.

  • If only two dots, it shouldn't be hard. You can improvise in many ways.

    For example:

    Pick first one (you can pick it by Top of layer), then send its "num" to a Function.

    That function will Pick the second dot (Bottom of layer), and compare its "num" with the parameters sent (of the other dot).

    So that function will help you pick the other, and also return the matching number.

  • in above example only 2 dots but in actual game there are more than 2. sometime 5 and sometime it could be 10 etc.

    See image. when a line is overlapping with dots then I want to get their uid in each other dot's instance variable. for example If line is overlapping with dot1 and dot2 then I want to get dots2 uid in dot1's variable and dot1's uid in dot2's variable.

    for that reason I stored all overlapping line's uid in dot's variable so by matching that uid number in variable I could get both dot's uid in each other.

    Do you have any short way?

    btw I'm trying to make this game

  • For the long way (i.e. searching between multiple numbers against numbers to find the match) I suggest using Arrays to store the numbers, instead of strings. Then looping through brute force method. It will consume a lot of CPU, so this searching should be through a function, as a trigger when a new line has been placed.

    But for the shorter way, I do believe there could be. Imagine if each Dot can find out how many lines are touching? then you don't need to do anything else. Each dot will display a text, that's all you need for the game right.

    How can each dot know how many lines are touching? I have no idea! or I must be missing something. Perhaps dop2000 may be able to help here.

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