Skript: Clicked inventory not working within on inventory click

Created on 1 Sep 2019  路  7Comments  路  Source: SkriptLang/Skript

Description

I tried to make a gui, but when i came to the inventory part, nothing happend, so i did a lil debugging and nothing worked, it all showed up as in the on inventory click, the function fillinventory was working fine

Steps to Reproduce

command /shop:
    trigger:
        openShop(player)
        play sound "ui.button.click"


function openShop(P: player, s: string = "MM"):

    if {_s} = "MM":
        open chest inventory with 6 rows named "Shop" to {_P}
        fillinventory({_P})


function fillinventory(P: player):
    set {_S} to rows of {_P}'s current inventory
    loop {_S}*9 times:
        set slot loop-value -1 of {_P}'s current inventory to light gray stained glass pane named " &a "


on inventory click:
    broadcast "hi"
    set {_S} to clicked inventory
    set {_B} to player's current inventory
    if {_S} = "Shop":
        broadcast "1"
    if name of {_S} = "Shop":
        broadcast "2"
    if {_B} = "Shop":
        broadcast "3"
    if name of {_B} = "Shop":
        broadcast "4"
    if name of clicked inventory = "Shop":
        broadcast "5"
    if name of player's current inventory = "Shop":
        broadcast "6"

Expected Behavior

I expected a 4 messages: "2", "4", "5", "6" when i click the gui

Errors / Screenshots

Takes you to Gyazo.com

Server Information

  • Server version/platform: 1.14.4 paper build 176
  • Skript version: Skript 2.4 beta 5
needs-testing

Most helpful comment

@ShaneBeee why are you describing it like it is a Skript bug

In 1.14, inventories don't have a name, but inventory views of players have a title. Currently Skript doesn't support inventory view stuff.

The reason I worded it the way I did is because a few things:
1) The average Skripter doesn't know the difference between inventory and inventory view
2) Using expressions like name of inventory fo player should return the name of the player's current inventory view, but they don't.

Whether or not you want to classify this as a skript bug or not is basically semantics.
Its something that doesnt work in Skript, its something thats been reported, and its something that is planning on being fixed. Id say that falls under the realms of a "bug"

All 7 comments

Server Information

  • Server version/platform:
  • Skript version:

^^^^^
This missing info is kind of important here.

not missing anything

thank you for editing.
Anyways inventory names are not working in 1.14+, this has already been reported, it's a known bug.

@ShaneBeee why are you describing it like it is a Skript bug

In 1.14, inventories don't have a name, but inventory views of players have a title. Currently Skript doesn't support inventory view stuff.

I would recommend you to use TuSKe GUIs so you won't have to deal with that and make GUIs much more easier.
Wiki: https://github.com/Tuke-Nuke/TuSKe/wiki/GUI-Manager
Download: https://github.com/Pikachu920/TuSKe/releases

However here are some simple skript-mirror (addon) custom syntaxes that you can use.

expression inventory view title:
    return type: string
    get:
        return event.getView().getTitle()

players property (current|open|top) inventory view title:
    return type: string
    get:
        return expr-1.getOpenInventory().getTitle()

Then you can use inventory view title to get the view title in an inventory event, player's current inventory view title to get the title of a player's currently open inventory view.
You should put this code into a file like !custom.sk so it will be loaded before others.

you wrote players so it should be exprs-1

@ShaneBeee why are you describing it like it is a Skript bug

In 1.14, inventories don't have a name, but inventory views of players have a title. Currently Skript doesn't support inventory view stuff.

The reason I worded it the way I did is because a few things:
1) The average Skripter doesn't know the difference between inventory and inventory view
2) Using expressions like name of inventory fo player should return the name of the player's current inventory view, but they don't.

Whether or not you want to classify this as a skript bug or not is basically semantics.
Its something that doesnt work in Skript, its something thats been reported, and its something that is planning on being fixed. Id say that falls under the realms of a "bug"

@ShaneBeee btw

  1. They will know it
  2. No because inventories don't have a name

Literally not a Skript problem. Also see my idea on Discord:
image
Note: There is no any way for Skript to make all of the old codes work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Misio12320 picture Misio12320  路  3Comments

Coolfire02 picture Coolfire02  路  3Comments

DeagoTheDoggo picture DeagoTheDoggo  路  3Comments

Eryk1983S picture Eryk1983S  路  3Comments

MrScopes picture MrScopes  路  3Comments