1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Loop all items in player's inventory

Discussion in 'Requests' started by Rektb, Sep 10, 2017.

  1. R

    Rektb Member

    Joined:
    Jul 7, 2017
    Messages:
    5
    Likes Received:
    0
    Hi, I am trying to do a skript that loops items in player's inventory and then it adds it to a yml file. The problem is that when I reload my skript, an error appears saying "Can't understand this type of loop: "loop all items in player's inventory", etc". First I did something like this and I made a test using different items (incluiding potions)
    Code (Skript):
    1.                     loop 36 times:
    2.                         set {_call} to slot {_count} of player's inventory
    3.                         if {_call} is not air:
    4.                             add "%{_call}%" to skutil yaml list "items" from file "{@file}"
    5.                         add 1 to {_count}
    but when I see the yaml file...
    Code (Skript):
    1.  
    2. items:
    3. - diamond_sword of Mending 1
    4. - grass_block
    5. - enchanted_book
    6. - spawn_egg
    7. - '145'
    8. - bottle_o'_enchanting
    9. - water_bottle # This is the potion, it appears as a water bottle
    10.  
    When I used a command to get these items, I got a water bottle but not a potion
    Skript Version: Skript 2.2 (dev31) [Latest]
    Skript Author: Dzikoysk
    Minecraft Version: 1.12.1 [Running with latest spigot build]ç

    After that I tried to do the same thing but with a loop. And I wrote this:
    Code (Skript):
    1.  
    2. command /invtest:
    3.     trigger:
    4.         loop all items in player's inventory:
    5.             loop-item is not air
    6.             add "%loop-item%" to skutil yaml list "test" from file "/plugins/KITS/sostupid.yml"
    7.  
    So, I need a way to make the loop or to fix the potion error.
     
  2. Best Answer:
    Post #2 by ShaneBee, Sep 10, 2017
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,058
    Likes Received:
    144
    Solution: Don't use YAML.

    Skript variables can hold a million values, so I don't know why would you want to use YAML.

    When trying to parse an item as text, you'll get the type of the item and the quantity, but no NBT values. So, you just CAN'T use anything else than skript variables for this.
     
    • Like Like x 1
Loading...