Solved how to use arrayList?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

NB_SuL

New Member
Feb 15, 2017
6
0
0
22
Code:
set {_items} to new ArrayList()
loop all items in player's inventory:
    {_items}.add(loop-item)
loop ...{_items}:
    give loop-value to player
it is not able to give loop-value to player.
When I printed out the {_items}, the user inventory slot was printed. Is the add part wrong?


Just so you know, it's just for study.
So i hope you don't answer not to use ArrayList.
 
Last edited:
Just use {_items::*}
What you said has no relevance to the what he is asking. He is asking how to add loop-item to an ArrayList. he doesn't want to use Skript lists. He even stated this. Make sure to actually read the whole post before answering.
[doublepost=1572550292,1572549083][/doublepost]
Code:
set {_items} to new ArrayList()
loop all items in player's inventory:
    {_items}.add(loop-item)
loop ...{_items}:
    give loop-value to player
it is not able to give loop-value to player.
When I printed out the {_items}, the user inventory slot was printed. Is the add part wrong?


Just so you know, it's just for study.
So i hope you don't answer not to use ArrayList.
Try setting a local variable to loop-item first, and then add it:
code_language.skript:
set {_items} to new ArrayList()
loop all items in player's inventory:
    set {_i} to loop-item
    {_items}.add({_i})
loop ...{_items}:
    give loop-value to player
This should add an actual item to the ArrayList.
 
Last edited:
I resolved this problem by using loop-item.getItem().

Thank you all for answering!
 
Status
Not open for further replies.