As an example, lets set up a warp command as so
Code: Select all
WarpTabComplete:
type: data
warps:
set: end
remove:
_warp: end
goto:
spawn: end
_warp: end
but what if you want more parameters that are dynamic and not just static names? You can define extra procedure scripts to be executed at that parameter.
For instance
Code: Select all
/warps goto (warp)
Code: Select all
WarpTabComplete:
type: data
warps:
set: end
remove:
_*warp: end
goto:
_*warp: end
WarpTabComplete_warp:
type: procedure
script:
- determine <server.flag[warps]>
The script will pass in all the previous arguments the player had typed in already as context to the procedure.
For instance for
Code: Select all
/warp remove (warp)
Code: Select all
WarpTabComplete_warp:
type: procedure
definitions: arg
script:
- define warps:|:<server.flag[warps]>
- if <[arg]> == remove:
- define warps:<-:spawn
- determine <[warps]>
Code: Select all
WarpTabComplete:
type: data
warps:
?warps.admin set: end
?warps.admin remove:
_*warp: end
goto:
_*warp: end
WarpTabComplete_warp:
type: procedure
script:
- determine <server.flag[warps]>
After you have set it up, all you need to type in your tab complete section is
Code: Select all
- determine <proc[TabComplete].context[<list[commandName|ConatinerName].include_single[<context.raw_args>]>]>
Code: Select all
warpcommand:
type: command
name: warps
description: warp to another location
usage: /warps
tab complete:
- determine <proc[TabComplete].context[<list[warps|WarpTabComplete].include_single[<context.raw_args>]>]>
script:
#my code
https://paste.denizenscript.com/View/83717
Note: as a reminder, this is all for tab completion and does not impact the actual script of the command script. You do still need to do that part yourself
edit 1: added permission locking of branches
edit 2: 4/21/2021 updated fallbacks to if_null and a few minor cleanups