INDEXOF

INDEXOF(<array[]>,<#outvar>,<searchfor>,[casesensitiv])

Type: Action

Category: Variables

Permission: N/A

Since Minecraft Version: v1.4.6

Since Version: v0.9.7

Minor: 9

API: N/A

Patch: 7


Description

Gets the first index of <searchfor> in <array[]> and stores it in <#outvar>.

[casesensitiv] can be set to true which will cause the check to be case-sensitiv. (By default the search is case-insensitiv.)

Returns the found index.

Example
&array[] = "Looking"
&array[] = "for"
&array[] = "Hello"
&array[] = "World"

INDEXOF(&array[],#variant1,"Hello")
#variant2 = INDEXOF(&array[],,"Not here")

// Output 2 and -1 respectively
LOG(%#variant1%)
LOG(%#variant2%)

Changelog
  • Added em v0.9.7:
  • Updated em v0.9.10: New fourth parameter which will force a case-sensitive lookup