Forum rules - please read before posting.

Compare String Variable with PopUp

Hi!

Is it possible to check if a popup variable contains a string that is the same as a string variable? I am aware the the PopUp Variable is a list of ints, but maybe there is a way to access the labels as strings?

In my game the player can type in a word in a text input box, and I have a list of words I want to go through to see if the players word matches any. I managed to turn the input box value into a global string variable, but I have trouble checking if it matches my list of words in an efficient way, instead of one by one.

Comments

  • It can be done through scripting, if necessary. A variable's PopUpValue property with return its value as a string.

    To try before, though: create a new Global string variable to act as a temporary storage for the PopUp. Use the Variable: Set Action and set it using the [var:X] token, where "X" is the ID of the PopUp variable.

    That will set its value to the readable label, not the index, allowing you to compare your two string variables with Variable: Check.

  • Thank you, this makes sense. But I suppose this only check the current value of the PopUp variable. The thing I am missing then is the possibility to automatically look through all possible values of the PopUp to see if any of them matches the string variable.

    What I am looking for is like an array of strings where I can store these words, and the ability to search through the whole array quickly. If that is not possible with the popup, is there another way you can recommend to store a list of words?

  • I managed to do it with a very simple script, and it seems to work now! I ll put it here in case anyone wants to do something similiar and is struggling:

    I got an array of the popup variable like this:

    myArray=myPopUpVariable.popUps;

    Then I got the global variable I use to store the word the player typed:

    SearchWord=myGlobalVariable.TextValue;

    Then I checked if the searchword the player typed is in there:

    if (myArray.Contains (SearchWord)){
    }

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.