playMaker

Author Topic: Comparing Arrays For Matches  (Read 1284 times)

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Comparing Arrays For Matches
« on: May 28, 2018, 02:07:26 PM »
Hello!

I'm working on a kind of ChatterBot where the player may input some text and the FSM will read the words before choosing a response.

Right now I have the text input from the player being turned into an array using the String Split action. After that, I would like to check that string array against other string arrays that I create to find any matches but I'm not sure how to get a state to compare arrays like that.

The Array Contains action is close to what I'm after but that only searches the array for one string per action where as I would prefer having a few large arrays to compare with the player's input like a database of words.

Any help would be appreciated :)

acornbringer

  • Junior Playmaker
  • **
  • Posts: 75
    • Acornbringer.com
Re: Comparing Arrays For Matches
« Reply #1 on: May 30, 2018, 03:56:22 PM »
Hey again!

I tried a bunch of testing on how this might be done with the actions that come with PlayMaker as well as ArrayMaker but found there was no single action fix like I was thinking of. When I started using ArrayMaker, I thought the "Array List Contains" action would do the trick but unfortunately I can't use an Array variable as my data type. I get an error that looks like this in the action:

"Error editing field: Variable Unknown FsmArray Type: Use ArrayEditorAttribute to specify a VariableType."

Despite having an array option in that field, I guess it's not compatible with that script.

After that, I ended up doing what I was hoping to avoid and created a state machine that loops through the players input array and compares it against a array of strings before choosing a response.

This method is a bit cumbersome for my use case so if anyone knows of a simpler solution, I would love to hear it :)