Skip to content

Commit 71ec251

Browse files
feat(gates): add curtime gate
1 parent 2d95357 commit 71ec251

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lua/wire/gates/time.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,29 @@ GateActions["monostable"] = {
317317
end
318318
}
319319

320+
321+
GateActions["curtime"] = {
322+
name = "CurTime",
323+
description = "Outputs CurTime() when Clk is non-zero, otherwise holds last value.",
324+
inputs = { "Clk" },
325+
timed = true,
326+
327+
output = function(gate, Clk)
328+
if Clk ~= 0 then
329+
gate.Last = CurTime()
330+
end
331+
332+
return gate.Last or 0
333+
end,
334+
335+
reset = function(gate)
336+
gate.Last = 0
337+
end,
338+
339+
label = function(Out, Clk)
340+
return "Clk:" .. Clk .. " = " .. Out
341+
end
342+
}
343+
344+
320345
GateActions()

0 commit comments

Comments
 (0)