earwax.mapping.door module¶
Provides the Door class.
-
class
earwax.mapping.door.Door(open: bool = True, closed_sound: Optional[pathlib.Path] = None, open_sound: Optional[pathlib.Path] = None, close_sound: Optional[pathlib.Path] = None, close_after: Union[float, Tuple[float, float], None] = None, can_open: Optional[Callable[[], bool]] = None, can_close: Optional[Callable[[], bool]] = None)¶ Bases:
objectAn object that can be added to a box to optionally block travel.
Doors can currently either be open or closed. When opened, they can optionally close after a specified time:
Door() # Standard open door. Door(open=False) # Closed door. Door(close_after=5.0) # Will automatically close after 5 seconds. # A door that will automatically close between 5 and 10 seconds after # it has been opened: Door(close_after=(5.0, 10.0)
Variables: - open –
Whether or not this box can be walked on.
If this value is
False, then the player will hearclosed_soundwhen trying to walk on this box.If this value is
True, the player will be able to enter the box as normal. - closed_sound – The sound that will be heard if
openisFalse. - open_sound – The sound that will be heard when opening this door.
- close_sound – The sound that will be heard when closing this door.
- close_after –
When (if ever) to close the door after it has been opened.
This attribute supports 3 possible values:
None: The door will not close on its own.- A tuple of two positive floats
aandb: A random number - between
aandbwill be selected, and the door will automatically close after that time.
- A tuple of two positive floats
- A float: The exact time the door will automatically close after.
- can_open –
An optional method which will be used to decide whether or not this door can be opened at this time.
This method must return
TrueorFalse, and must handle any messages which should be sent to the player. - can_close –
An optional method which will be used to decide whether or not this door can be closed at this time.
This method must return
TrueorFalse, and must handle any messages which should be sent to the player.
- open –