controllables.Laser
- class controllables.Laser(port: Optional[int] = None)
Reference to a laser part.
If a laser is assigned to port
0
in the properties tab of the microcontroller, then that laser can be accessed withLaser(0)
.- turn_on()
Turns the laser on.
from controllables import Laser import time laser = Laser(0) laser.turn_on() time.sleep(1) laser.turn_off()
- turn_off()
Turns the laser off.
Note
This doesn’t prevent transmitters or properties from turning the laser on.
from controllables import Laser import time laser = Laser(0) laser.turn_on() time.sleep(1) laser.turn_off()
- property color: color.Color
The color of the Laser.
from controllables import Laser import time from color import Color laser = Laser(0) #assign color with a preset color name laser.color = "red" laser.turn_on() time.sleep(2) laser.turn_off() time.sleep(1) #assign color with Color object laser.color = Color(1,0,0) laser.turn_on() time.sleep(2) laser.turn_off() time.sleep(1) #assign color with hexcode string laser.color = "#ff0000" laser.turn_on()
- is_on() bool
Whether the laser is currently activated.
- name() str
Returns the user editable name of the controllable as found in the properties tab of the game.
from ports import PortReference print(PortReference(0).name())