How do I check several words do not exist in a string

0 favourites
  • 2 posts
From the Asset Store
Several elements of the game interface hidden objects
  • I'm creating a buffer for player input to trigger and prioritize moves. Each button and gamepad direction is assigned a letter which is pushed to the back of an array which is limited in size to (6,1). Every tick I set an instance variable called "Moves" in the array as follows:

    PlayerInput.At(0) & PlayerInput.At(1) & PlayerInput.At(2) & PlayerInput.At(3) & PlayerInput.At(4) & PlayerInput.At(5)

    I now want to check that this array does NOT contain a specific set of combo inputs (e.g. "ABXY", "XYABX") which may be 4, 5 or 6 letters long, so that I can trigger lower priority non-combo moves

    I have tried the following event using the "system compare two values" option:

    find(PlayerInput.Moves, "ABXY") = -1 AND find(PlayerInput.Moves, "XYABX") = -1

    But this doesn't seem to work. I assume the find expression returns -1 when the string is not found. Is there a better way to do this check? Any suggestions appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That condition is correct and it should work.

    You can add some debug output (for example Browser->Log PlayerInput.Moves & " " & PlayerInput.AsJSON) to see what's going on.

    Or run your game in Debug Mode and check the contents of the array and its instance variable.

    Also, there are a few plugins that you can use to detect combos, here is one from Rex:

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