File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,29 @@ class MyOpMode : NextFTCOpMode() {
3535}
3636```
3737
38+ There is also an ` onInit ` function that can be used to create properties that depend on hardware.
39+ It runs before the main ` onInit ` function,
40+ so properties created with it can be used in the main ` onInit ` function.
41+
42+ Here is an example OpMode that uses ` onInit ` to create a property for a color sensor,
43+ since there is no NextFTC wrapper for color sensors.
44+
45+ ``` kotlin
46+ class MyOpMode : NextFTCOpMode () {
47+ val sensor by onInit { hardwareMap.get(NormalizedColorSensor ::class .java, " colorSensor" ) }
48+
49+ init {
50+ addComponents(/* vararg components */ )
51+ }
52+
53+ override fun onInit () { }
54+ override fun onWaitForStart () { }
55+ override fun onStartButtonPressed () { }
56+ override fun onUpdate () { }
57+ override fun onStop () { }
58+ }
59+ ```
60+
3861== Java
3962
4063``` java
You can’t perform that action at this time.
0 commit comments