Solved Loop all items in player's inventory

  • 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!

Rektb

New Member
Jul 7, 2017
5
0
0
27
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_language.skript:
                    loop 36 times:
                        set {_call} to slot {_count} of player's inventory
                        if {_call} is not air:
                            add "%{_call}%" to skutil yaml list "items" from file "{@file}"
                        add 1 to {_count}
but when I see the yaml file...
code_language.skript:
items:
- diamond_sword of Mending 1
- grass_block
- enchanted_book
- spawn_egg
- '145'
- bottle_o'_enchanting
- water_bottle # This is the potion, it appears as a water bottle
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_language.skript:
command /invtest:
    trigger:
        loop all items in player's inventory:
            loop-item is not air
            add "%loop-item%" to skutil yaml list "test" from file "/plugins/KITS/sostupid.yml"
So, I need a way to make the loop or to fix the potion error.
 
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
Reactions: Rektb
He means like detect a item in his inventory, if we find the item, it says like "There was 16 wheat in your inventory!"