Apparently there is no STRING.IndexOf() Action in the Ecosystem?
I tried writing one. I finally got all errors resolved, but its not returning the found index.
What I'm doing, is scraping the data from a webpage. I use wwwObject action to store it all as a string, but now I need to find specific data within that giant string. Once I located a word I know is in the data only once, I can start to trim the data. But, I need to know what index it is at first.
using UnityEngine;
using System;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.String)]
[Tooltip("Gets index of substring inside a string")]
public class StringGetIndexOf : FsmStateAction
{
[UIHint(UIHint.Variable)]
[Tooltip("String to search.")]
public FsmString stringToSearch;
[UIHint(UIHint.Variable)]
[Tooltip("String to find.")]
public FsmString stringToFind;
[UIHint(UIHint.Variable)]
[Tooltip("Index of found string.")]
public FsmInt stringIndex;
// Code that runs on entering the state.
public override void Reset()
{
stringToSearch = null;
stringToFind = null;
stringIndex = 0;
}
public override void OnEnter()
{
int stringIndex = (stringToSearch.Value).IndexOf(stringToFind.Value);
Finish();
}
}
}