You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/nextftc/commands/utilities.md
+81-25Lines changed: 81 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,25 +2,74 @@
2
2
3
3
NextFTC has a bunch of utility commands to help you simplify your code!
4
4
5
-
## `InstantCommand`
5
+
## Instant Commands
6
6
7
7
An `InstantCommand` runs a function and ends instantly.
8
+
The `instant` utility function can be used to create an `InstantCommand`.
8
9
9
10
:::tabs key:code
10
11
== Kotlin
11
12
12
13
```kotlin
13
-
InstantCommand {
14
+
instant("name") {
15
+
// code here
16
+
}
17
+
18
+
// or
19
+
20
+
instant {
14
21
// code here
15
22
}
16
23
```
17
24
18
25
== Java
19
26
20
27
```java
21
-
newInstantCommand(() -> {
28
+
instant("name", () -> {
22
29
// code here
23
30
})
31
+
32
+
// or
33
+
34
+
instant(() -> {
35
+
// code here
36
+
});
37
+
```
38
+
39
+
:::
40
+
41
+
## Run Commands
42
+
43
+
A run command is similar to an `InstantCommand`, but it runs continuously until it is interrupted.
44
+
There is no specific `RunCommand` class;
45
+
instead, the `run` utility function can be used to create a run command.
46
+
47
+
:::tabs key:code
48
+
49
+
== Kotlin
50
+
```kotlin
51
+
run("name") {
52
+
// code here
53
+
}
54
+
55
+
// or
56
+
57
+
run {
58
+
// code here
59
+
}
60
+
```
61
+
62
+
== Java
63
+
```java
64
+
run("name", () -> {
65
+
// code here
66
+
});
67
+
68
+
// or
69
+
70
+
run(() -> {
71
+
// code here
72
+
});
24
73
```
25
74
26
75
:::
@@ -44,75 +93,82 @@ new NullCommand(parameter1, parameter2)
44
93
45
94
:::
46
95
47
-
## `ForcedParallelCommand`
96
+
## `proxy`
48
97
49
-
A `ForcedParallelCommand` schedules another command and instantly ends. This can be useful in `SequentialGroups` where you want to start a command and move on.
98
+
A proxy command schedules another command and instantly ends.
99
+
This can be useful in `SequentialGroups` where you want to start a command and move on.
50
100
51
101
:::tabs key:code
52
102
== Kotlin
53
103
54
104
```kotlin
55
-
ForcedParallelCommand(command)
105
+
proxy(command)
56
106
```
57
107
58
108
== Java
59
109
60
110
```java
61
-
newForcedParallelCommand(command)
111
+
proxy(command)
62
112
```
63
113
64
114
:::
65
115
66
-
Alternatively, you can used the `.forcedParallel()` utility:
116
+
Alternatively, you can used the `.asProxy()` utility:
67
117
68
118
:::tabs key:code
69
119
70
120
== Kotlin
71
121
72
122
```kotlin
73
-
command.forcedParallel()
123
+
command.asProxy()
74
124
```
75
125
76
126
== Java
77
127
78
128
```java
79
-
command.forcedParallel()
129
+
command.asProxy()
80
130
```
81
131
82
132
:::
83
133
84
-
## `PerpetualCommand`
134
+
## `repeatedly`
85
135
86
-
A `PerpetualCommand` wraps another command and never finishes unless it is interrupted. It simply ignores the `isDone` condition on the command it wraps.
136
+
The `repeatedly` decorator can be used to create a command that runs until it is interrupted or stopped,
137
+
repeatedly executing a given block of code.
87
138
88
-
:::tabs key:code
89
-
== Kotlin
139
+
If `isDone` is true, the command will restart, causing `start` to be called again.
140
+
This will happen infinitely until the command is interrupted,
141
+
or stopped as part of a `ParallelRaceGroup` or `ParallelDeadlineGroup`.
142
+
143
+
::: tabs key:code
90
144
145
+
== Kotlin
91
146
```kotlin
92
-
PerpetualCommand(commandToWrap)
147
+
command.repeatedly()
93
148
```
94
149
95
150
== Java
96
-
97
151
```java
98
-
newPerpetualCommand(commandToWrap)
152
+
command.repeatedly();
99
153
```
100
154
101
-
:::
155
+
:::
102
156
103
-
Alternatively, you can use the `.perpetually()` utility:
157
+
## `until`
104
158
105
-
:::tabs key:code
106
-
== Kotlin
159
+
The `until` decorator can be used to create a command that runs until a given condition is true.
0 commit comments