Does quest have something similar to the includes() function? For instance, if I want to do something like:


do you mean in terms of 'arrays' ??? (aka, does an array have this item?)

(lists === arrays, more or less)

then, yes:

example_stringlist_variable = Split ("red;blue;yellow", ";")

if (ListContains (example_stringlist_variable, "blue") {
  msg ("BLUE")
} else if (ListContains (example_stringlist_variable, "green") {
  msg ("GREEN")

and if you want to return the item's value:

also, I think the current version of quest, also now uses the normal index method of most programming languages:

I don't now what the exact syntax/Function/Script name it is, so this is jsut a conceptual example

returned_item_value = LIST (INDEX_POSITION)

(hopefully someone else can provide the actual Script/Function for you)

you can also check/get any nested Object (any level of Object within an Object):

there's also the 'Scope' Scripts/Functions too:

and a ton of more functionality too... (categorical order) (alphabetical order)

and a lot more...

Oh, thanks! I guess I should have been more specific.

I'm more interested in finding out what characters are in a string. For instance, if I were looking to see if a string contained "an", this could return true for "human", "ant", "plant", and so on.

ah okay, look at the 'string functions':

specifically some of them are:

// these can be used for find a specific sub-string within a string, as you want to do:

// ----- (this is probably the most powerful/useful of all of them)

and there's also the 'for', which can be used for strings too:

(the below is from the link above)

Generally, foreach offers a neater way of going through a list, but 'for' can be useful for iterating through a string. This example will print each character in the string, together with its position:

s = "Hello World!"
for (i, 1, LengthOf(s)) {
msg(i + ": " + Mid(s, i, 1))

You can use Instr, which will return 0 if "a" is not in the string

if (Instr(player.species, "a") > 0)

This topic is now closed. Topics are closed after 60 days of inactivity.