1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Skript On Tab Completer

Discussion in 'Tutorials' started by Slaim36, Jul 24, 2020.

  1. Slaim36

    Slaim36 New Member

    Joined:
    Apr 9, 2020
    Messages:
    8
    Likes Received:
    1
    Tab completer is the command's argument completer, in a manner of speaking, obviously.
    Here is an example:
    [​IMG]

    In this case we can complete the /gamemode arguments using the TAB key
    [​IMG]

    To use the tab completer in skript, we need a script with our command, this is the mine:
    Code (Text):
    1. command /gm <gamemode>:
    2.     trigger:
    3.         set player's gamemode to arg-1
    4.         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 (Text):
    1. on tab completer for "/gm":
    2. #In this line we need to put the command.
    3.     set {_completers::*} to "adventure", "creative", "spectator" and "survival"
    4.     #In this line we need to put the arguments to complete.
    5.     loop {_completers::*}:
    6.         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.
    [​IMG]
    Here more examples:
    Command script:
    Code (Text):
    1. command /sethome <string>:
    2.     trigger:
    3.         if {homes::%player%::*} is set:
    4.             set {home::%player%::%arg-1%} to player's position
    5.             add "%arg-1%" to {homes::%player%::*} #set {homes::%player%::*} to "%{homes::%player%::*}%" and "%arg-1%"
    6.             send "&aYour house %arg-1% was set"
    7.         else:
    8.             set {home::%player%::%arg-1%} to player's position
    9.             set {homes::%player%::*} to "%arg-1%"
    10.             send "&aYour house %arg-1% was set"
    11.        
    12. command /home <string>:
    13.     trigger:
    14.         if {home::%player%::%arg-1%} is set:
    15.             teleport player to {home::%player%::%arg-1%}
    16.             send "&aYou was teleported to %arg-1%"
    17.         else:
    18.             send "&4Invalid house name"
    19.            
    20. command /homes:
    21.     trigger:
    22.         send "&aYour houses: %{homes::%player%::*}%" to player
    23.        
    24. command /delhome <string>:
    25.     trigger:
    26.         if {home::%player%::%arg-1%} is set:
    27.             delete {home::%player%::%arg-1%}
    28.             remove "%arg-1%" from {homes::%player%::*}
    29.             send "&aYour house was deleted"
    30.         else:
    31.             send "&4Invalid house name"
    Completer script:
    Code (Text):
    1. on tab completer for "/home":
    2.     set {_completers::*} to {homes::%player%::*} #We can use variables
    3.     loop {_completers::*}:
    4.         add loop-value to completions
    Screenshot:
    [​IMG]
     
    • Like Like x 1
  2. Danic

    Danic Member

    Joined:
    Jul 23, 2020
    Messages:
    42
    Likes Received:
    0
    Hi, skript of jenius.
    I tried it to follow you.
    But it doesn't work and I faced a error.

    Code (Text):
    1. a tab completer cannot be assigned before the command is defined (t.sk, line 6: on tab completer for "/gm":)
    Can you help me?
     
  3. Slaim36

    Slaim36 New Member

    Joined:
    Apr 9, 2020
    Messages:
    8
    Likes Received:
    1
    You created other script for the TAB Completer??
     
  4. Danic

    Danic Member

    Joined:
    Jul 23, 2020
    Messages:
    42
    Likes Received:
    0
    No, That's my all code.
     
  5. Slaim36

    Slaim36 New Member

    Joined:
    Apr 9, 2020
    Messages:
    8
    Likes Received:
    1
    You need to create differents scripts for the completer and the command
     
  6. Danic

    Danic Member

    Joined:
    Jul 23, 2020
    Messages:
    42
    Likes Received:
    0
    Is this link contains that's answer?
     
  7. Slaim36

    Slaim36 New Member

    Joined:
    Apr 9, 2020
    Messages:
    8
    Likes Received:
    1
    I dont understand
    --- Double Post Merged, Aug 16, 2020, Original Post Date: Aug 16, 2020 ---
     
  8. Danic

    Danic Member

    Joined:
    Jul 23, 2020
    Messages:
    42
    Likes Received:
    0
    Oh.. Sorry. I can't understand completely about this site.
    Umm... Yes...
     
  9. croxywastaken

    croxywastaken Member

    Joined:
    Nov 20, 2020
    Messages:
    2
    Likes Received:
    0
    What can we do if command has arguments more than 1?
     
  10. cuddlytrap

    cuddlytrap Member

    Joined:
    Dec 18, 2020
    Messages:
    26
    Likes Received:
    0
    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
     
  11. TobyMinceraft

    TobyMinceraft Member

    Joined:
    Jul 21, 2019
    Messages:
    13
    Likes Received:
    1
    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.
     

Share This Page

Loading...