controllables.Decoupler

class controllables.Decoupler(port: Optional[int] = None)

Reference to a decoupler part.

The following example assumes a decoupler is assigned to port 0 of the microcontroller and that a TouchSensor is assigned to port 1.

from controllables import Decoupler
from sensors import TouchSensor

decoupler = Decoupler(0)
sensor = TouchSensor(1)

while not sensor.pressed():
    pass

decoupler.separate()
separate()

Detaches the two halves of the decoupler.

from controllables import Decoupler

decoupler = Decoupler(0)
decoupler.separate()
property ejection_force: float

The force in newtons applied between the two halves of the decoupler when it is activated.

from controllables import Decoupler

decoupler = Decoupler(0)
decoupler.ejection_force = 5
decoupler.separate()
from controllables import Decoupler

decoupler = Decoupler(0)
print(f'ejection force: {decoupler.ejection_force:0.1f}')
name() str

Returns the user editable name of the controllable as found in the properties tab of the game.

The following example assumes that any controllable or sensor is assigned to port 0 and prints out its name.

from ports import PortReference

print(PortReference(0).name())