Input system's seat link is now being updated on change

This commit is contained in:
Ivan Grachyov 2021-11-10 19:21:48 +05:00
parent 7cbdea15b4
commit f55c30c4d3
2 changed files with 14 additions and 1 deletions

View File

@ -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

View File

@ -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