Tutorial by: joskript111


Hello,
In this tutorial we will go over the basics of tab completions using Skbee.

Lets start by making a simple command:

command /spawn:
    trigger:
        if {spawn} is set:
            teleport player to {spawn}
        else:
            send "&c&lSorry but spawn has not been set yet!" to player

Now we have a simple command where we can teleport to spawn with. For this command we cant do tab completions yet. We will need arguments for this, to do this we make a command with a few arguments:

command /example <text> [<text>]:      #Add the [ ] to make an argument optional
    trigger:
        if arg-1 is "apple":
            give player 1 of apple
        else if arg-1 is "hello":
            send "hello" to player
        else if arg-1 is "uuid":
            if arg-2 is set:
                set {_p} to arg-2 parsed as player
                send uuid of {_p} to player
            else:
                send uuid of player to player

Now we can add tab completions!
Tab completions are not that hard to understand. The event required to make tab completions is on tab complete of "<command>":. To set the tab completions within the event we will need set tab completions for position %number% to %list%. Lets do it now:

on tab complete of "/example":
    set tab completions for position 1 to "apple", "hello", "uuid"  #Sets the suggestions for the first argument to apple, hello and uuid
    if tab arg 1 is "uuid":                                                 #Checks if the first argument is uuid
        set tab completions for position 2 to all players    #If that is the case then set the suggestions to the names of all online players

So now we have the completed /example command with tab completions!

command /example <text> [<text>]:
  trigger:
    if arg-1 is "apple":
      give player 1 of apple
    else if arg-1 is "hello":
      send "hello" to player
    else if arg-1 is "uuid":
      if arg-2 is set:
        set {_p} to arg-2 parsed as player
        send uuid of {_p} to player
      else:
        send uuid of player to player

on tab complete of "/example":
  set tab completions for position 1 to "apple", "hello", "uuid"
  if tab arg 1 is "uuid":
    set tab completions for position 2 to all players

That was it, the very basics of tab completions, i will still give one practical example of tab completions with a /warp command.

command /warp <text> [<text>]:
    usage: /warp <warpname>
    trigger:
        if arg-1 is "set": 
            if player has permission "warps.mod":
                if arg-2 is set:
                    if {warp::%arg-2%} is not set:
                        set {warp::%arg-2%} to player's location
                        send "&aSuccesfully set warp %arg-2% at %player's location%" to player
                        add arg-2 to {warps::*}
                    else:
                        send "&4Warp %arg-2% already exsists" to player
                else:
                    send "&4&lYou need to specify a name of the set warp" to player
            else:
                send "&4&lYou dont have permission to use this command!" to player
        else if arg-1 is "remove":
            if player has permission "warps.mod":
                if arg-2 is set:
                    if arg-2 is "all":
                        delete {warp::*}
                        send "&aSuccesfuly removed all warps: &d%{warp::*}%"
                        set {warp::*} to " "
                        set {warps::*} to " "

                    else if {warp::%arg-2%} is set:
                        delete {warp::%arg-2%}
                        delete {warps::*}

                        send "&aSuccesfully removed warp &r&d%arg-2%"

                    else:
                        send "&4Warp %arg-2% does not exist, so cant be removed" to player

                if arg-2 is "all":
                    delete {warp::*}
                    delete {warps::*}
                else:
                    send "&4You have to specify a warp to remove" to player
            else:
                send "&4&lYou dont have permission to use this command!" to player
        else if {warp::%arg-1%} is set:
            teleport player to {warp::%arg-1%}
            send "&aSuccesfully teleported you to warp &d%arg-1%"


on tab complete of "/warp":
    if player has permission "warps.mod":
        set tab completions for position 1 to "set", "remove" and {warps::*}
        if tab arg 1 is "remove":
            set tab completions for position 2 to {warps::*}
    else:
        set tab completions for position 1 to {warps::*}

Did you find joskript111's tutorial helpful?


You must be logged in to comment