Forum rules - please read before posting.

Check if string contains a specific word

Hi there,

Is it possible to check if a player's Entered Value includes, but not necessarily Equal To, a String?

For example, let's say I have an NPC that asks the player what their favourite colour is, and the player is able to give an input. Something ideal would be something like:

Variable:Check > Compare With: Entered Value > Includes (instead of Equal To), String: blue

That way, if the player inputs: "Blue", "My favourite colour is blue", "I like blue" etc., all will meet the conditions of the Variable:Check

If someone knows of an easy way to do this, much help would be appreciated!

Comments

  • I'm afraid you'll need to know a bit of scripting for this.  As the Enum that the Action makes use of is shared with other variables types (integer, for example), it wouldn't be possible to make a change like that without affecting all other uses of it.

    However, it would be very simple to write a custom Action that does this check for you.  This tutorial guides you through the steps needed to write a custom Action, however this particular Action will need to derive from ActionCheck, as that provides the two output sockets instead of one.

    Get up to speed with creating a custom Action, then create a new one that derives from ActionCheck (so public class MyActionName : ActionCheck), then write an overriding CheckCondition function that returns True/False based on your requirements.

    A very basic example is provided in the form of ActionPlayerCheck.cs, which is used to determine the current player prefab - you could open that up to see how it works.
  • As always, thank you for the fast and thorough reply. I am actually excited to dive into more scripting, so this will be a great exercise :)
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.