"Sputnik" help  
Sputnik Help
NbtListExGetAt(<nbtListEx>, <index>)

Description

Returns the value of the NBT tag at the specified index in the NBT list, converted into the appropriate Sputnik variable.

Parameters

<nbtList> The NBT list from which to retrieve the value.
<index> The index of the tag to retrieve the value from.

Return Value

Success: Returns the value of the NBT tag at the specified index, converted into the appropriate variable..
Failure: Returns null.

Remarks

The NbtListGetAt function allows you to retrieve the value of the NBT tag at a specific index within an NBT list. The function converts the value into the appropriate variable based on the tag's type. If the provided nbtList parameter is not a valid NBT list or if the index is out of range, the function returns null.

Related

NbtListExGetTagAt

Example

Example of usage:

my $nbt = NbtNew(@NbtListEx);
NbtListExAppendTag($nbt, Nbt("Hello"));
NbtListExAppendTag($nbt, Nbt("Cat"));
NbtListExAppendTag($nbt, Nbt("Dog"));

say $nbt;

say NbtListExGetAt($nbt, 0);
say NbtListExGetAt($nbt, 1);
say NbtListExGetAt($nbt, 2);

// PRINTS
// {NBTTag;ListEx:3 entries}
// Hello
// Cat
// Dog

You can use the [] and ![] array bracket like so:

my $nbt = NbtNew(@NbtListEx);
$nbt[] = "Hello";
$nbt[] = "Cat";
$nbt[] = "Dog";
$nbt![] = "Fox";

say $nbt;

say $nbt[0];
say $nbt[1];
say $nbt[2];
say $nbt[3];

// PRINTS
// {NBTTag;ListEx:4 entries}
// Fox
// Hello
// Cat
// Dog

You can also set via the .= and ..= like so:

my $nbt = NbtNew(@NbtListEx);
$nbt .= "Hello";
$nbt .= "Cat";
$nbt .= "Dog";
$nbt ..= "Fox";

$nbt[0] = "Rabbit";
$nbt[^1] = "Squid";

say $nbt;

say $nbt[0];
say $nbt[1];
say $nbt[2];
say $nbt[3];

// PRINTS
// {NBTTag;ListEx:4 entries}
// Rabbit
// Hello
// Cat
// Squid

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org