FirstFreeInArray

From the Oblivion ConstructionSet Wiki
(Redirected from FirstInArray)
Jump to navigation Jump to search


A command for Pluggy

Syntax:

(Index: long) FirstInArray ArrayID:long Used:Short Start:long Stop:long
(Index: long) FirstFreeInArray ArrayID:long Used:Short Start:long Stop:long

Returns the index of the first Index containing either a value or no value.

  • To search for an index without a value, set Used to 0 or leave it unspecified.
    • To search for an index with a value, set Used to 1.
  • Set Start to begin the search from a certain index (inclusive). By default it is 0
    • Set Stop to end the search at a certain index (inclusive). By default it is the last index of the array
  • If the value is not in the array or the array does not exist, it returns -1.


Examples

With this array

Index Value
Index 0 3
Index 1 10
Index 2 (empty)
Index 3 8
Index 4 (empty)
Index 5 (empty)
Index 6 15
FirstInArray ArrayID

will return 2

FirstInArray ArrayID 1

will return 0

FirstInArray ArrayID 0 2

will return 2

FirstInArray ArrayID 0 3

will return 4

FirstInArray ArrayID 1 2

will return 3

FirstInArray ArrayID 0 4 5

will return 4

FirstInArray ArrayID 1 4 5

will return -1