From f55c30c4d3ec6209fbe913ddd2cd42e6448ca1ae Mon Sep 17 00:00:00 2001 From: Ivan Grachyov Date: Wed, 10 Nov 2021 19:21:48 +0500 Subject: [PATCH] Input system's seat link is now being updated on change --- koptilnya/input_system/main.txt | 8 ++++++++ koptilnya/input_system/sv_input.txt | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/koptilnya/input_system/main.txt b/koptilnya/input_system/main.txt index 8f7db81..319bd06 100644 --- a/koptilnya/input_system/main.txt +++ b/koptilnya/input_system/main.txt @@ -21,3 +21,11 @@ local input = Input:new(options) hook.add('tick', 'InputUpdate', function() input:update() end) + +if SERVER then + hook.add('input', 'wire_input_update', function(key, value) + if key == 'Seat' then + input:updateSeat() + end + end) +end diff --git a/koptilnya/input_system/sv_input.txt b/koptilnya/input_system/sv_input.txt index 8629dca..555e673 100644 --- a/koptilnya/input_system/sv_input.txt +++ b/koptilnya/input_system/sv_input.txt @@ -104,13 +104,18 @@ function Input:initialize(options) self:_setupAxles(axles) - self.seat = wire.ports.Seat + self:updateSeat() + self.driver = self:getDriver() -- in case chip was reset self:_syncDriver(self.driver) end +function Input:updateSeat() + self.seat = wire.ports.Seat or NULL_ENTITY +end + function Input:getDriver() if self.seat == nil or self.seat:isValid() == false then return NULL_ENTITY