Skip to content

SetGateState

Starts a gate towards open (passable) or closed.

A gate already at that end, or heading there, is refused ("is already open", "is already closing" …); a gate moving the other way turns round from where it is. The motion plays on every client from the server’s clock, and OnGateChange fires now ("opening" / "closing") and when it comes to rest. A gate of the kind "gate" is there at once: the seconds are 0 and OnGateChange fires "open" / "closed" straight away.

SetGateState(key, open)
Parameter Type
key string the gate’s level name
open boolean true towards open (a portcullis raised, a drawbridge lowered), false towards closed

boolean, string, number - accepted; the reason when not (worded after the gate’s name: "is already open", "has no opening animation", "is not a gate this server knows"; "" when accepted); the seconds the motion still has to run (0 when nothing moved)

-- the siege: the portcullis drops when the round starts
local ok, reason, seconds = SetGateState("suchdol_fortres_gate_bars3", false)
if ok then SendClientMessageToAll(COLOR_YELLOW, string.format("The gate is coming down - %.0f seconds!", seconds)) end
-- the Malesov courtyard gate has no motion: it is shut at once, and seconds is 0
SetGateState("malesov_courtyard_gate", false)

ToggleGate · GetGateInfo · OnGateChange · the Gates group of the index