#Lists in data

1 messages · Page 1 of 1 (latest)

thorny aurora
#

So I have a list in an item, I can get it with /data which returns [1,2,3] how would I get a certain value in that list from a number

thorny aurora
#

as in how would I find the first thing in the list or the 3rd

modern sentinel
#

/data get … the_list[index]?

thorny aurora
#

Would I be able to use it in a macro

modern sentinel
#

so list[n] gives the (n+1)th thing in the list

modern sentinel
thorny aurora
#

so

#
$data get ... list[$(value)]
#

should work?

modern sentinel
#

Yep

thorny aurora
#

right and how would I find the length of a list

#

I can put it in storage and read from there but are there easier methods?

cloud crystal
# thorny aurora should work?

you also have the posibillity to use compounds as the entries, that way you can search for data directly without knowing the index.

thorny aurora
#

?

cloud crystal
#

Data: [{name:"steve",health:10},{name:"alex",health:20}]

data get ... list[{name:"alex"}].health returns 20

thorny aurora
#

oh thats cool

#

and very useful for what im trying to do

cloud crystal
thorny aurora
#

so yeah storage

#

I wish I could store the actual list

cloud crystal
#

what do you mean?

thorny aurora
#

well the options are byte int double etc

#

actually wait nvm

#

anyway thank you for the help

cloud crystal
#

why would you need anything else than int if you want to store the length?

thorny aurora
#

no I was thinking about what I wanted to do wrong

#

so yeah thanks for the help it will be very useful