Solved Detect clicktype in a GUI

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

    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.

Aralwen

Active Member
May 26, 2017
164
14
18
Hello, I'm trying to do something pretty simplistic, but I do not find.

I wish that when clicking on the object, it detects if it is a right click or left click.
In the place underlined in the image, I would like to replace that by a detection (is it a right or left click). I already tried right or left, it does not work


OlLMdF4.png



Here is my code below

code_language.skript:
command /gui:
    trigger:
        open virtual chest with 4 rows named "&8Settings" to player
        format gui slot 0 of player with gray dye named "&7Name &8- &e%{test}%" to run function Test(player, "left", "Villager")
            
            
            
            
function Test(p: Player, clicktype: String, role: text):
    if {_role} is "Villager":
        if {_clicktype} is "left":
            broadcast "&a+1"
            add 1 to {test}
            make {_p} execute command "/gui"
        if {_clicktype} is "right":
            broadcast "&c-1"
            remove 1 from {test}
            make {_p} execute command "/gui"



Thank you in advance,
Aralwen.
 
So looking at the syntax on the Tuske Wiki:
code_language.skript:
(format|create|make) [a] gui slot %integers% of %players% with %item stack% to [close then] (run|exe[cute]) %sender% command %string% [with permission %string%] [(using|with) %click action% [(button|click|action)]] [(using|with) cursor [item] %item stack%]
Here is an example:
code_language.skript:
format gui slot 1 of player with arrow to close with middle click:
    send "This will be sent after closing a gui"

Now naturally the examples, are always wrong :emoji_wink: haha, apparently you have to throw quotes around the click type, like
with "middle" click
Anyways, I tested it to give you some TRUE working examples:
code_language.skript:
format gui slot 0 of player with gray dye named "&7Name &8- &e%{test}%" to run using "left" click:
    Test(player, "left", "Villager")
format gui slot 0 of player with gray dye named "&7Name &8- &e%{test}%" to run using "right" click:
    Test(player, "right", "spider")
You can format the same slot twice, with different click types, it will show up as one item in your gui, but the left and right clicks will do 2 different things... neat hey?
 
So looking at the syntax on the Tuske Wiki:
code_language.skript:
(format|create|make) [a] gui slot %integers% of %players% with %item stack% to [close then] (run|exe[cute]) %sender% command %string% [with permission %string%] [(using|with) %click action% [(button|click|action)]] [(using|with) cursor [item] %item stack%]
Here is an example:
code_language.skript:
format gui slot 1 of player with arrow to close with middle click:
    send "This will be sent after closing a gui"

Now naturally the examples, are always wrong :emoji_wink: haha, apparently you have to throw quotes around the click type, like
with "middle" click
Anyways, I tested it to give you some TRUE working examples:
code_language.skript:
format gui slot 0 of player with gray dye named "&7Name &8- &e%{test}%" to run using "left" click:
    Test(player, "left", "Villager")
format gui slot 0 of player with gray dye named "&7Name &8- &e%{test}%" to run using "right" click:
    Test(player, "right", "spider")
You can format the same slot twice, with different click types, it will show up as one item in your gui, but the left and right clicks will do 2 different things... neat hey?
Thank you very much for these very clear explanations. :emoji_slight_smile:.

Problem solved
 
Thank you very much for these very clear explanations. :emoji_slight_smile:.

Problem solved
You're welcome. The wiki page for Tuske is kind of 50/50.... its got most of the basics but sometimes the examples are wrong.
 
Status
Not open for further replies.