Date: 2020/04/10 21:03:31 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# @ ███████████████████████████████████████████████████████████
# @ ██ Command Dependencies | Tab Completion
# % ██
# % ██ [ Usage ] tab-completes all online players by their name, filters as you type:
# - ██ [ # 1 ] - determine <proc[Online_Player_Tabcomplete]>
# % ██ [ ]
# % ██ [ ] tab completes all players online by their name for the SECOND arg
# - ██ [ # 2 ] - determine <proc[Online_Player_Tabcomplete].context[2]>
# % ██ [ ]
# % ██ [ ] tab completes all players online by their name for the first arg, blacklisting yourself
# - ██ [ # 3 ] - determine <proc[Online_Player_Tabcomplete].context[1|<player>]>
# % ██ [ ] tab completes all players online by their name for the first arg, blacklisting players flagged "Admin"
# % ██ [ ] the Blacklist must be escaped if it is a list of players
# - ██ [ # 4.1 ] - determine <proc[Online_Player_Tabcomplete].context[1|<server.list_players_flagged[Admin].escaped>]>
# % ██ [ ] OR you can inject the script directly as opposed to using the procedure tag:
# % ██ [ ] tab completes all players by their name for the first arg, blacklisting online players flagged "Admin"
# - ██ [ #4.2 ] - define blacklist <server.list_online_players_flagged[Admin]>
# - ██ [ ] - inject Online_Player_Tabcomplete
# % ██ [ ]
# % ██ [ ] tab completes all players by their name for the second arg, and blacklisting online players flagged "Admin"
# - ██ [ # 5 ] - define iArg 2
# - ██ [ ] - define blacklist <server.list_online_players_flagged[Admin]>
# - ██ [ ] - inject Online_Player_Tabcomplete
Online_Player_Tabcomplete:
type: procedure
debug: false
definitions: iArg|Blacklist
script:
- if !<[iArg].exists>:
- define iArg 1
- if <context.args.size> == <[iArg].sub[1]>:
- determine <server.list_online_players.exclude[<[Blacklist].unescaped||null>].parse[name]>
- else if <context.args.size> == <[iArg]> && !<context.raw_args.ends_with[<&sp>]>:
- determine <server.list_online_players.exclude[<[Blacklist].unescaped||null>].parse[name].filter[starts_with[<context.args.get[<[iArg]>]>]]>
# % ██ [ Usage ] tab-completes all players by their name, filters as you type:
# - ██ [ # 1 ] - determine <proc[All_Player_Tabcomplete]>
# % ██ [ ]
# % ██ [ ] tab completes all players by their name for the SECOND arg
# - ██ [ # 2 ] - determine <proc[All_Player_Tabcomplete].context[2]>
# % ██ [ ]
# % ██ [ ] tab completes all players by their name for the first arg, blacklisting yourself
# - ██ [ # 3 ] - determine <proc[All_Player_Tabcomplete].context[1|<player>]>
# % ██ [ ]
# % ██ [ ] tab completes all players by their name for the first arg, blacklisting players flagged "Admin"
# % ██ [ ] the Blacklist must be escaped if it is a list of players
# - ██ [ # 4.1 ] - determine <proc[All_Player_Tabcomplete].context[1|<server.list_players_flagged[Admin].escaped>]>
# % ██ [ ] OR you can inject the script directly as opposed to using the procedure tag:
# % ██ [ ] tab completes all players by their name for the first arg, blacklisting players flagged "Admin"
# - ██ [ #4.2 ] - define blacklist <server.list_players_flagged[Admin]>
# - ██ [ ] - inject All_Player_Tabcomplete
# % ██ [ ]
# % ██ [ ] tab completes all players by their name for the second arg, and blacklisting players flagged "Admin"
# - ██ [ # 5 ] - define iArg 2
# - ██ [ ] - define blacklist <server.list_players_flagged[Admin]>
# - ██ [ ] - inject All_Player_Tabcomplete
All_Player_Tabcomplete:
type: procedure
debug: false
definitions: iArg|Blacklist
script:
- if !<[iArg].exists>:
- define iArg 1
- if <context.args.size> == <[iArg].sub[1]>:
- determine <server.list_players.exclude[<[Blacklist].unescaped||null>].parse[name]>
- else if <context.args.size> == <[iArg]> && !<context.raw_args.ends_with[<&sp>]>:
- determine <server.list_players.exclude[<[Blacklist].unescaped||null>].parse[name].filter[starts_with[<context.args.get[<[iArg]>]>]]>
# % ██ [ Usage ] Tab-completes a list of a values from an escaped ListTag - List must be escaped
# - ██ [ #1 ] - determine <proc[OneArg_Command_Tabcomplete].context[1|<list[Option1|Option2|Option3].escaped>]>
# % ██ [ ]
# % ██ [ ] tab completes all players by their name for the SECOND arg
# - ██ [ #2 ] - determine <proc[OneArg_Command_Tabcomplete].context[2]>
# % ██ [ ]
# % ██ [ ] This can also be injected to avoid escaping the list:
# - ██ [ ] - define Arg <list[option1|option2|option3]>
# - ██ [ ] - inject OneArg_Command_Tabcomplete Instantly
OneArg_Command_Tabcomplete:
type: procedure
debug: false
definitions: iArg|Args
script:
- if !<[iArg].exists>:
- define iArg 1
- if <context.args.size||0> == <[iArg].sub[1]>:
- determine <[Args].unescaped>
- else if <context.args.size> == <[iArg]> && !<context.raw_args.ends_with[<&sp>]>:
- determine <[Args].unescaped.filter[starts_with[<context.args.get[<[iArg]>]>]]>
# % ██ [ Notes ] Tab-completes a list of options for a numbered list of args
# % ██ [ ] Note: definitions must be numbered "Arg1, Arg2, ..." - Skips if undefined
# % ██ [ ] Example usage for a command describing your pizza:
# - ██ [ Usage ] - define Arg1 <list[small|medium|large]>
# - ██ [ ] - define Arg2 <list[thin|handtossed|brooklyn]>
# - ██ [ ] - define Arg3 <list[redsauce|bbq|alfredo]>
# - ██ [ ] - define Arg4 <list[pepperonies|sausage|pineapples|none]>
# - ██ [ ] - inject MultiArg_Command_Tabcomplete Instantly
MultiArg_Command_Tabcomplete:
type: task
debug: false
script:
- if <context.args.size> == 0:
- determine <[Arg1]>
- foreach <context.args> as:Arg:
- if <[Loop_Index]> == <context.args.size>:
- if !<context.raw_args.ends_with[<&sp>]>:
- determine <[Arg<[Loop_Index]>].filter[starts_with[<context.args.get[<[Loop_Index]>]>]]>
- else if <[Arg<[Loop_Index].add[1]>].exists>:
- determine <[Arg<[Loop_Index].add[1]>]>
- else:
- foreach next
# % ██ [ Notes ] Tab-completes a list of options for any list of args, including sub-args
# % ██ [ ] First arg is required, every arg afterwards is optional, including deciding between args, or sub-args from the previous arg
# % ██ [ ] Sub-Args are defined as Arg#<ARGNAME>Args - where the # is the arg number and <ARGNAME> is the name from Arg# you want to have sub-args
# - ██ [ # 1 ] - define Arg1 <list[Option1|Option2]>
# - ██ [ # 1 ] - define Arg2Option1Args <list[Option3|Option4]>
# - ██ [ # 1 ] - define Arg2Option2Args <list[Option5|Option6]>
# % ██ [ ] Example usage for a command describing your pizza from a shop that restricts the toppings based on your pizza size,
# % ██ [ ] and only letting you add a secondary topping if you opted to get red-sauce:
# - ██ [ Usage ] - define Arg1 <list[small|medium|large]>
# - ██ [ ] - define Arg2SmallArgs <list[Peppernoies|Sausage]>
# - ██ [ ] - define Arg2MediumArgs <list[Pepperonies|Sausage|Ham|Chicken]>
# - ██ [ ] - define Arg2LargeArgs <list[Pepperonies|Sausage|Ham|Chicken|Pineapples|Bacon]>
# - ██ [ ] - define Arg3 <list[RedSauce|bbq|alfredo]>
# - ██ [ ] - define Arg4RedSauceArgs <list[Pepperonies|Sausage|Pineapples]>
# - ██ [ ] - inject MultiArg_With_MultiArgs_Command_Tabcomplete Instantly
# % ██ [ Notes ] Tab-completes a list of options for a numbered list of args with specific args per args
MultiArg_With_MultiArgs_Command_Tabcomplete:
type: task
debug: true
script:
- if <context.args.size> == 0:
- determine <[Arg1]>
- foreach <context.args> as:Arg:
- if <[Loop_Index]> == <context.args.size>:
- if !<context.raw_args.ends_with[<&sp>]>:
- if <[Arg<[Loop_Index]>].exists>:
- determine <[Arg<[Loop_Index]>].filter[starts_with[<context.args.get[<[Loop_Index]>]>]]>
- if <[Arg<[Loop_Index].sub[1]>].contains[<context.args.get[<[Loop_Index].sub[1]>]>]>:
- define Option <context.args.get[<[Loop_Index].sub[1]>]>:
- if <[Arg<[loop_index]><[Option]>Args].exists>:
- determine <[Arg<[Loop_Index]><[Option]>Args].filter[starts_with[<context.args.last>]]>
- else if <[Arg<[Loop_Index].add[1]>].exists>:
- determine <[Arg<[Loop_Index].add[1]>]>
- else if <[Arg<[Loop_Index]>].contains[<context.args.last>]>:
- if <[Arg<[Loop_Index].add[1]><context.args.last>Args].exists>:
- determine <[Arg<[Loop_Index].add[1]><context.args.last>Args]>
- else:
- foreach next