Skip to content

Tab Complete

Shane Bee edited this page Sep 21, 2020 · 6 revisions

SkBee is now introducing some helpful tab complete syntaxes.
We have an event, as well as some expressions to help make your tab completion dreams come true.

Event

The tab complete event is called when a player types out a command, and hits tab. After that a list of completions will be sent to the player, which gives them different options for command arguments.

The syntax is simple:

[skbee] tab complete [(of|for) %strings%]

Let's break it down. First and foremost the [skbee] is optional, the help prevent clashing with other addons that may have a tab complete event.
[(of|for) %strings%] is also optional. This allows you to choose for which command will be handled in this event.

Let's see an example:

on tab complete of "/mycommand":

Easy right?

Event-Values

event-string = the command
event-player = the player that is currently tab completing

Completions

You can manipulate the completions in several ways.

Set

You can set the completions to a list of objects, most commonly strings/texts but you can also do players, etc.
Let's see the syntax:

[skbee] tab completions [(of|for) position %number%]

Pretty straight forward.
[(of|for) position %number%] this allows you to set which specific position in the command args you want the completions to show up for. Think of position like args in a command. Position 1 = arg-1, position 2 = arg-2. The position is optional and will default to position 1 when not present.
Let's see an example:

set tab completions for position 1 to "one", "two" and "three"

Now when tab completing you will see these 3 options, but only for position 1.

Add

You can also add to currently done completions. Add will only work if there is a current list of completions. If there isn't a list already (ie: in a custom command), you will need to set your own completions. Add does not support position.
Example:

on tab complete of "/ver":
    add "MyFakePlugin" to tab completions

This will show your current list of plugins along with your "fake plugin"

Remove

You can also remove from the current completions. Remove does not support position.
Example:

on tab complete of "/ver":
    remove "Skript" from tab completions

This would remove "Skript" from your current list of plugins in the tab complete.

Clear

If you want to clear a list, you can do that too.
Example:

on tab complete of "/ver":
    clear tab completions

Tab Arguments

Tab args are basically command args, at the position in the command.
These are used to differentiate which completions are sent when different args are typed.
Example:

on tab complete of "/breakfast":
	set tab completions for position 1 to "bacon", "eggs" and "toast"
	if tab arg-1 = "bacon":
		set tab completions for position 2 to "crispy" and "soft"
	else if tab arg-1 = "eggs":
		set tab completions for position 2 to "sunny_side_up", "scrambled", "soft_boiled" and "hard_boiled"
	else if tab arg-1 = "toast":
		set tab completions for position 2 to "light", "medium" and "dark"

In this case, position 1 would be "bacon", "eggs" and "toast", and depending if the player chooses bacon, eggs or toast in the first position, the 2nd position will change accordingly.

Let's see how that would look.

As you can see here, depending what I type in for arg-1, the arg-2/position 2 changes accordingly.

Examples

Let's see some more examples.

In this example we removed Skript related plugins from our list, and replaced with some made up plugins:

on tab complete:
	if event-string contains "/ver":
		remove "Skript", "SkBee" and "skript-reflect" from tab completions
		add "MyPlugin", "FakePlugin", "BestPlugin" to tab completions

In this example we just created a fake plugin list, haha player trying to figure out my plugins:

on tab complete:
	if event-string contains "/ver":
		set tab completions of position 1 to "Fake", "Plugin" and "List"