Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lua/wire/gates/time.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,29 @@ GateActions["monostable"] = {
end
}


GateActions["servertime"] = {
name = "Server time",
description = "Returns the uptime of the server in seconds when CLK is non-zero, otherwise it outputs the last saved value",
inputs = { "Clk" },
timed = true,

output = function(gate, Clk)
if Clk ~= 0 then
gate.Last = CurTime()
end

return gate.Last or 0
end,

reset = function(gate)
gate.Last = 0
end,

label = function(Out, Clk)
return "Clk:" .. Clk .. " = " .. Out
end
}


GateActions()