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

Slaim36

New Member
Apr 9, 2020
9
1
3
17
Canary Islands, Spain
Tab completer is the command's argument completer, in a manner of speaking, obviously.
Here is an example:
620028b1f769dd4a68b43d82ffc80c18o.png

In this case we can complete the /gamemode arguments using the TAB key
img_5ba9fcbbcb694.png

To use the tab completer in skript, we need a script with our command, this is the mine:
Code:
command /gm <gamemode>:
    trigger:
        set player's gamemode to arg-1
        send "&aChanged your gamemode to %arg-1%"
Now, we need to create another script, with any name, it doesn't matter. Now, in the script we need to write the tab completer, this is the mine:
Code:
on tab completer for "/gm":
#In this line we need to put the command.
    set {_completers::*} to "adventure", "creative", "spectator" and "survival"
    #In this line we need to put the arguments to complete.
    loop {_completers::*}:
        add loop-value to completions
For this to work, first you have to reload / enable the command script and then the completion script.
Now, our command has the tab completions.
3c7df9ecc2910c429864833211ec20cao.png

Here more examples:
Command script:
Code:
command /sethome <string>:
    trigger:
        if {homes::%player%::*} is set:
            set {home::%player%::%arg-1%} to player's position
            add "%arg-1%" to {homes::%player%::*} #set {homes::%player%::*} to "%{homes::%player%::*}%" and "%arg-1%"
            send "&aYour house %arg-1% was set"
        else:
            set {home::%player%::%arg-1%} to player's position
            set {homes::%player%::*} to "%arg-1%"
            send "&aYour house %arg-1% was set"
        
command /home <string>:
    trigger:
        if {home::%player%::%arg-1%} is set:
            teleport player to {home::%player%::%arg-1%}
            send "&aYou was teleported to %arg-1%"
        else:
            send "&4Invalid house name"
            
command /homes:
    trigger:
        send "&aYour houses: %{homes::%player%::*}%" to player
        
command /delhome <string>:
    trigger:
        if {home::%player%::%arg-1%} is set:
            delete {home::%player%::%arg-1%}
            remove "%arg-1%" from {homes::%player%::*}
            send "&aYour house was deleted"
        else:
            send "&4Invalid house name"
Completer script:
Code:
on tab completer for "/home":
    set {_completers::*} to {homes::%player%::*} #We can use variables
    loop {_completers::*}:
        add loop-value to completions
Screenshot:
e66fbf08a68103a67ac6c1012b9b7e53o.png
 
  • Like
Reactions: Baezor
Tab completer is the command's argument completer, in a manner of speaking, obviously.
Here is an example:
620028b1f769dd4a68b43d82ffc80c18o.png

In this case we can complete the /gamemode arguments using the TAB key
img_5ba9fcbbcb694.png

To use the tab completer in skript, we need a script with our command, this is the mine:
Code:
command /gm <gamemode>:
    trigger:
        set player's gamemode to arg-1
        send "&aChanged your gamemode to %arg-1%"
Now, we need to create another script, with any name, it doesn't matter. Now, in the script we need to write the tab completer, this is the mine:
Code:
on tab completer for "/gm":
#In this line we need to put the command.
    set {_completers::*} to "adventure", "creative", "spectator" and "survival"
    #In this line we need to put the arguments to complete.
    loop {_completers::*}:
        add loop-value to completions
For this to work, first you have to reload / enable the command script and then the completion script.
Now, our command has the tab completions.
3c7df9ecc2910c429864833211ec20cao.png

Here more examples:
Command script:
Code:
command /sethome <string>:
    trigger:
        if {homes::%player%::*} is set:
            set {home::%player%::%arg-1%} to player's position
            add "%arg-1%" to {homes::%player%::*} #set {homes::%player%::*} to "%{homes::%player%::*}%" and "%arg-1%"
            send "&aYour house %arg-1% was set"
        else:
            set {home::%player%::%arg-1%} to player's position
            set {homes::%player%::*} to "%arg-1%"
            send "&aYour house %arg-1% was set"
       
command /home <string>:
    trigger:
        if {home::%player%::%arg-1%} is set:
            teleport player to {home::%player%::%arg-1%}
            send "&aYou was teleported to %arg-1%"
        else:
            send "&4Invalid house name"
           
command /homes:
    trigger:
        send "&aYour houses: %{homes::%player%::*}%" to player
       
command /delhome <string>:
    trigger:
        if {home::%player%::%arg-1%} is set:
            delete {home::%player%::%arg-1%}
            remove "%arg-1%" from {homes::%player%::*}
            send "&aYour house was deleted"
        else:
            send "&4Invalid house name"
Completer script:
Code:
on tab completer for "/home":
    set {_completers::*} to {homes::%player%::*} #We can use variables
    loop {_completers::*}:
        add loop-value to completions
Screenshot:
e66fbf08a68103a67ac6c1012b9b7e53o.png

Hi, skript of jenius.
I tried it to follow you.
But it doesn't work and I faced a error.

Code:
a tab completer cannot be assigned before the command is defined (t.sk, line 6: on tab completer for "/gm":)
Can you help me?
 
What can we do if command has arguments more than 1?
Hmmmmmmmmmmmmmm maybe something like this:


  1. on tab completer for "/gm":
  2. set {_completers::*} to "adventure", "creative", "spectator" and "survival"
  3. loop {_completers::*}:
  4. add loop-value to completion

    on tab completer for "/gm creative":
    set {_completers::*} to "true" and "false"
    loop {_completers:*}:
    add loop-value to completion
 
One thing to note about this: Skript loads scripts in alphabetical order. For instance, Apple will load before Banana, and in this case the "command.sk" will load before "tabcomplete.sk" or "complete.sk". Unsure if this is a bug or intended behavior, but it's currently how Skript works.

Another thing, more often than not the tab complete will fail as it is hard for Skript to determine if a command is by Skript or another plugin. I've had issues with the tab completer before, where it would give me the same error. Results may vary.
 
Well that's why. You are checking for a command that is /gm <gamemode>
What you should be doing is checking for the tab completer for JUST /gm
Then you can check if tab arg-1 is "adventure" or something and go from there.

Besides, it LITERALLY TELLS YOU WHAT TO CHECK FOR in the example provided by the thread author.
1694883040032.png
 
Are separate files required? That's what I'm gathering from `another script`, but it seems odd that I couldn't have them within the same file? Is this something to do with parse order?
 
I tried this and it doesn't seem to work... I'm doing exactly what he says :/
 
1712667379820.png

It's done.
I first loaded the script I wanted to use tab complete with and the main body of tab complete, then disabled only tab complete and then enabled it, and it was loaded correctly and I was able to use it!

There was one error, but it worked fine so it's okay
If you don't understand something, please ask!
 
"Why are you commenting on a nearly 7 month old post? If someone is struggling with tab completion they will make a skript help forum post about it, there is literally no reason to necro-post on this forum." :emoji_point_up::emoji_nerd:
I genuinely don't understand people who complain about this. I had trouble with this 'tab completer' stuff, and the 'necro-post' helped out a lot. Pointing out that it was a necro-post just makes the situation worse anyway. :emoji_skull: