From 18e2b473a1999ad74f47a7bbdde12befdfd51e6e Mon Sep 17 00:00:00 2001 From: Lysdal Date: Sat, 28 Feb 2026 21:55:22 +0100 Subject: [PATCH 1/6] FPGA now renders compact_input gates with variable amount of input --- lua/wire/client/node_editor/nodeeditor.lua | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lua/wire/client/node_editor/nodeeditor.lua b/lua/wire/client/node_editor/nodeeditor.lua index 24429d9224..ea3ff3156b 100644 --- a/lua/wire/client/node_editor/nodeeditor.lua +++ b/lua/wire/client/node_editor/nodeeditor.lua @@ -692,6 +692,21 @@ function Editor:DrawCircle(x, y, radius, segments) surface.DrawPoly(circle) end +function getInputAmountForNode(node) + local gate = getGate(node) + local amountOfInputs = 0 + if gate.compact_inputs then + inputLimit = gate.compact_inputs + for inputIdx, _ in pairs(node.connections) do + inputLimit = math.max(inputLimit, inputIdx + 1) + end + amountOfInputs = math.min(#gate.inputs, inputLimit) + else + amountOfInputs = #gate.inputs + end + return amountOfInputs +end + -------------------------------------------------------- --UNDO/REDO SYSTEM -------------------------------------------------------- @@ -842,7 +857,7 @@ function Editor:GetNodeAt(x, y) --gates local amountOfInputs = 0 if gate.inputs then - amountOfInputs = #gate.inputs + amountOfInputs = getInputAmountForNode(node) end local amountOfOutputs = 1 if gate.outputs then @@ -903,7 +918,7 @@ function Editor:GetNodeInputAt(x, y) if gy < node.y - self.GateSize / 2 then continue end if gy > node.y - self.GateSize / 2 + self.GateSize * #gate.inputs then continue end - for inputNum, _ in pairs(gate.inputs) do + for inputNum = 1, getInputAmountForNode(node) do local ix, iy = self:NodeInputPos(node, inputNum) if gx < ix - self.IOSize / 2 then continue end @@ -1187,7 +1202,7 @@ end function Editor:PaintGate(nodeId, node, gate) local amountOfInputs = 0 if gate.inputs then - amountOfInputs = #gate.inputs + amountOfInputs = getInputAmountForNode(node) end local amountOfOutputs = 1 if gate.outputs then @@ -1210,6 +1225,7 @@ function Editor:PaintGate(nodeId, node, gate) if gate.inputs then for inputNum, inputName in pairs(gate.inputs) do + if inputNum > amountOfInputs then break end local nx = x - size / 2 - ioSize local ny = y - ioSize / 2 + (inputNum-1) * size From a66103c54bdbb7b838cf7793991160bac1f3f6a5 Mon Sep 17 00:00:00 2001 From: Lysdal Date: Sat, 28 Feb 2026 22:36:52 +0100 Subject: [PATCH 2/6] Fixed multi drawing with variable input gates --- lua/wire/client/node_editor/nodeeditor.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/wire/client/node_editor/nodeeditor.lua b/lua/wire/client/node_editor/nodeeditor.lua index ea3ff3156b..7c9e974c17 100644 --- a/lua/wire/client/node_editor/nodeeditor.lua +++ b/lua/wire/client/node_editor/nodeeditor.lua @@ -1774,9 +1774,11 @@ function Editor:Paint() if self.DrawingConnectionAll then drawingConnectionFrom = {} local ports + local amountOfInputs = getInputAmountForNode(node) if self.DrawingFromInput then ports = gate.inputs elseif self.DrawingFromOutput then ports = gate.outputs or { "Out" } end for portNum, portName in pairs(ports) do + if self.DrawingFromInput and portNum > amountOfInputs then break end drawingConnectionFrom[portNum] = portNum end end @@ -2489,9 +2491,11 @@ function Editor:OnDrawConnectionFinished(x, y) if self.DrawingConnectionAll then drawingConnectionFrom = {} local ports + local amountOfInputs = getInputAmountForNode(fromNode) if self.DrawingFromInput then ports = fromGate.inputs elseif self.DrawingFromOutput then ports = fromGate.outputs or { "Out" } end for portNum, _ in pairs(ports) do + if self.DrawingFromInput and portNum > amountOfInputs then break end drawingConnectionFrom[portNum] = portNum end end From 582992483df3e7c6a706fffecfeafdabbb34f4ad Mon Sep 17 00:00:00 2001 From: Lysdal Date: Sat, 28 Feb 2026 23:11:44 +0100 Subject: [PATCH 3/6] Made FPGA node input detection more performant --- lua/wire/client/node_editor/nodeeditor.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/wire/client/node_editor/nodeeditor.lua b/lua/wire/client/node_editor/nodeeditor.lua index 7c9e974c17..c88130424e 100644 --- a/lua/wire/client/node_editor/nodeeditor.lua +++ b/lua/wire/client/node_editor/nodeeditor.lua @@ -913,12 +913,14 @@ function Editor:GetNodeInputAt(x, y) if not gate then continue end + local amountOfInputs = getInputAmountForNode(node) + if gx < node.x - self.GateSize / 2 - self.IOSize then continue end if gx > node.x + self.GateSize / 2 + self.IOSize then continue end if gy < node.y - self.GateSize / 2 then continue end - if gy > node.y - self.GateSize / 2 + self.GateSize * #gate.inputs then continue end + if gy > node.y - self.GateSize / 2 + self.GateSize * amountOfInputs then continue end - for inputNum = 1, getInputAmountForNode(node) do + for inputNum = 1, amountOfInputs do local ix, iy = self:NodeInputPos(node, inputNum) if gx < ix - self.IOSize / 2 then continue end From 7c53eb714ffa843ba7039f8deeb7977d4279e313 Mon Sep 17 00:00:00 2001 From: Lysdal Date: Sun, 1 Mar 2026 11:06:45 +0100 Subject: [PATCH 4/6] Made string concatenate gate use compact_inputs --- lua/wire/gates/string.lua | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/lua/wire/gates/string.lua b/lua/wire/gates/string.lua index 0ec5652757..fc5781c513 100644 --- a/lua/wire/gates/string.lua +++ b/lua/wire/gates/string.lua @@ -146,22 +146,16 @@ GateActions["string_concat"] = { name = "Concatenate", description = "Combines multiple strings together into one string.", inputs = { "A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" }, + compact_inputs = 2, inputtypes = { "STRING" , "STRING" , "STRING" , "STRING" , "STRING" , "STRING" , "STRING" , "STRING" }, outputtypes = { "STRING" }, - output = function(gate, A, B, C, D, E, F, G, H) - if (A and #A or 0) - + (B and #B or 0) - + (C and #C or 0) - + (D and #D or 0) - + (E and #E or 0) - + (F and #F or 0) - + (G and #G or 0) - + (H and #H or 0) > MAX_LEN - then - return false + output = function(gate, ...) + local result = "" + for k,v in ipairs({...}) do + if (v) then result = result..v end end - local T = {A,B,C,D,E,F,G,H} - return table.concat(T) + if #result > MAX_LEN then return false end + return result end, label = function(Out) return string.format ("concat = %q", Out) From 13e55c57bb6ea7d8b95907c32441198d237707d8 Mon Sep 17 00:00:00 2001 From: Lysdal Date: Sun, 1 Mar 2026 11:10:21 +0100 Subject: [PATCH 5/6] Removed unnecessary parenthesis in string gate file --- lua/wire/gates/string.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/wire/gates/string.lua b/lua/wire/gates/string.lua index fc5781c513..303fb8d83f 100644 --- a/lua/wire/gates/string.lua +++ b/lua/wire/gates/string.lua @@ -343,10 +343,10 @@ GateActions["string_to_memory"] = { if (Address == 0) then --Clk if (gate.stringChanged) then return 1 else return 0 end elseif (Address == 1) then --String length - return #(gate.currentString) + return #gate.currentString else --Return string bytes local index = Address - 1 - if (index > #(gate.currentString)) then -- Check whether requested address is outside the string + if (index > #gate.currentString) then -- Check whether requested address is outside the string return 0 else return string.byte(gate.currentString, index) From 9018fcb735dbcd554b6024845064cbfa1f4ce9b7 Mon Sep 17 00:00:00 2001 From: Lysdal Date: Sun, 1 Mar 2026 14:50:49 +0100 Subject: [PATCH 6/6] Made string concat gate less memory hungry --- lua/wire/gates/string.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/wire/gates/string.lua b/lua/wire/gates/string.lua index 303fb8d83f..e92afb325a 100644 --- a/lua/wire/gates/string.lua +++ b/lua/wire/gates/string.lua @@ -150,12 +150,12 @@ GateActions["string_concat"] = { inputtypes = { "STRING" , "STRING" , "STRING" , "STRING" , "STRING" , "STRING" , "STRING" , "STRING" }, outputtypes = { "STRING" }, output = function(gate, ...) - local result = "" - for k,v in ipairs({...}) do - if (v) then result = result..v end + local len = 0 + for _, v in ipairs({...}) do + if (v) then len = len + #v end end - if #result > MAX_LEN then return false end - return result + if len > MAX_LEN then return false end + return table.concat({...}) end, label = function(Out) return string.format ("concat = %q", Out)