Gate
Level gates, shared by all players, including the drawbridge, portcullises and palisade gates of Trosky and Kuttenberg. The server owns each gate's state. Players' games move the gate there smoothly, and latecomers see it where it is. On gates with a bar, you can remove and replace the bar while the gate stays shut.
gate.all()
Gate.all(level)All gates, or those of one level.
gate.find()
Gate.find(key)The gate with this key or level GUID, with or without 0x, or null.
gate.getById()
Gate.getById(id)The gate with this id, or null.
gate.nearest()
Gate.nearest(position, radius)The gate nearest a point within `radius` metres, on the server's level, or null. Positions come from the level's data, so no player needs to be near. Throws a TypeError for an unusable position or radius.
gate.key
keyThe gate's key, which stays the same across server starts.
gate.level
levelThe gate's level: 'trosecko' or 'kutnohorsko'.
gate.guid
guidThe level's EntityGuid for the gate, as sixteen lower-case hex digits, the same on all machines. For a gate of moved leaves, it is the lowest of those shown. Gate.find accepts it. '' if the level gives none.
gate.position
positionThe gate's location in the level. For a gate of moved leaves, it is the middle of what it shows.
gate.id
idA number naming the gate while the server runs, which Gate.getById accepts. Across restarts, store `guid` or `key` instead.
gate.kind
kind'drawbridge', 'portcullis', or 'gate' for leaves moved between states.
gate.cycle
cycleIts place in the cycle: 'closed', 'opening', 'open' or 'closing'. Open means passable. A gate no script has set reads as closed.
gate.openingTime
openingTimeSeconds to open, or 0 for a gate with no open state.
gate.closingTime
closingTimeSeconds to close, or 0 for a gate with no closed state.
gate.states
statesThe names of the gate's states.
gate.state
stateThe current state, or null while it is as the level shows it.
gate.isOpen
isOpenWhether the gate is open.
gate.openness
opennessHow open it is now, from 0 shut to 1 open, while moving: the share of the way into an open state, or what remains of the way into a shut one.
gate.moving
movingWhether the gate is moving.
gate.hasBar
hasBarWhether the gate has a bar.
gate.barState
barStateThe state in which the gate is barred, or null with no bar.
gate.barred
barredWhether the bar is in place, or null with no bar.
gate.secondsTo()
secondsTo(state)How long moving to a state takes, or null if it has no such state.
gate.setState()
setState(state, options = {})Moves the gate to a named state.
gate.open()
open()Opens the gate, removing a bar first. Returns false if it has no open state, is open, or is moving.
gate.close()
close(options = {})Shuts the gate, and replaces a bar at the end. `bar: false` leaves the bar out.
gate.toggle()
toggle(options = {})Opens a shut gate or shuts an open one, as open() or close() would. Returns false while it moves or if it has no such state.
gate.removeBar()
removeBar()Takes the bar out, while the gate stays shut.
gate.placeBar()
placeBar()Puts the bar back.