Skip to content

ToggleGate

Sends a gate the other way - from the end it rests at, or back from the way it is moving.

Heads away from whichever end the gate is at, reversing one already moving from where it has got to. What /gate does with no argument.

ToggleGate(key)
Parameter Type
key string the gate’s level name

boolean, boolean, string, number - accepted; true when the direction taken is open; the reason when refused ("" otherwise); the seconds the motion still has to run

function OnPlayerCommandText(pid, cmd, args)
if cmd == "lever" then
local key = GetNearestGate(GetPlayerPos(pid))
if not key then SendClientMessage(pid, COLOR_RED, "No gate here.") return true end
local ok, opening, reason = ToggleGate(key)
SendClientMessage(pid, COLOR_YELLOW, ok and (opening and "The gate rises." or "The gate drops.") or ("The gate " .. reason .. "."))
return true
end
end

SetGateState · GetNearestGate · the Gates group of the index