Skript: [1.14.2] amount of type of items

Created on 5 Jun 2019  路  8Comments  路  Source: SkriptLang/Skript

Description

        if block at loop-value is barrel:
            loop all items in inventory of block at loop-value:
                set {_locofbarrel} to inventory of block at loop-value-1
                set {_adet} to amount of type of loop-item in {_locofbarrel}
                set {_item} to type of loop-item

image
1- {_locofbarrel} Debug
2- {_locofbarrel} inventory debug
3- {_adet} debug
image
4- {_item} debug

Barrel inventory
image

amount of type of loop-item syntax problemly

Server Information

  • Server version/platform: Paper 1.14.2 #66
  • Skript version: Skript 2.4 alpha-3
enhancement lowest

All 8 comments

item amount of %object%

This is not the same as what you're suggestion @TheLimeGlass as that's for checking the amount in a single stack while @OverBrave seems to be requesting an expression for the amount of a single item type in an entire inventory (is that correct?)

If that's correct I can it being useful but it's arguably something user should implement themselves via a function if they need it. I'll label it as an enhancement but open to hearing thoughts from others.

Yeah, that's what I want.

wouldnt item amount of slot loop-index parsed as integer- 1 of player's current inventory work?
As he鈥檚 already using a loop and therefore no need to have an expression to get the item amount of every item? Also saving a list as all items in player's current inventory contains amount as well.

It does work, I don't know what Bento is on about, item amount is designed to handle itemstack amounts, and why Njol didn't add it to the amount syntax is a mystery.

You can also do size of all diamond in player's inventory but this also has been broken.

What you're saying doesn't work because you're misunderstanding the situation. The thing being asked for here is a simple expression to get the amount of the number of items in an inventory by type. The item amount expression operates on single stacks, or can return the number (size) of many stacks but that still doesn't achieve what's desired, as it gives a bunch of separate amounts not tied to items which looks like this:
image

You can also do size of all diamond in player's inventory but this also has been broken.

No, the way you would do what I think you're saying is number of diamonds in player's inventory, which does work currently. However, it doesn't work when passing a type because then the item must be an exact match for it to work, e.g. here where I have 54 diamonds with extra NBT and 16 plain diamonds:
image

So, as far as I can tell, this is a specific edge case which isn't common (hence lowest priority), but there isn't a way when iterating over items to identify the number of that item type in that inventory without requiring an exact match. If you know of an expression that works in that regard, I'll happily close this.

It's already an expression, I don't understand why this issue is still open. https://github.com/SkriptLang/Skript/blob/master/src/main/java/ch/njol/skript/expressions/ExprAmountOfItems.java

loop items in {_inventory}:
    if loop-item is a diamond:
        add 1 to {_diamonds}

If this issue is to continue to be open for some reason, make it a bug report, stating that the itemtypes of inventories doesn't return if it's value is not the same as described above!

@TheLimeGlass the guy is just asking for that expression to count all items regardless of their nbt, just taking into account their type. Which is an enhancement to the expression you linked, not a bug report.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Misio12320 picture Misio12320  路  3Comments

ghost picture ghost  路  3Comments

Snow-Pyon picture Snow-Pyon  路  4Comments

TheClassic36 picture TheClassic36  路  3Comments

GiraffeCubed picture GiraffeCubed  路  3Comments