Advertisement
JachyHm

RelaySim

Feb 8th, 2021
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. RELAY = {
  2.     states = {},
  3.     koefs = {},
  4.     Do = function(self, id, state, time_delta)
  5.         _state = self.states[id]
  6.         if not _state then
  7.             _state = 0
  8.             self.koefs[id] = math.random()*3+3
  9.         end
  10.         if state and _state < 1 then
  11.             _state = _state + time_delta*self.koefs[id]
  12.             self.states[id] = _state
  13.         elseif not state and _state > 0 then
  14.             _state = _state - time_delta*self.koefs[id]
  15.             self.states[id] = _state
  16.         end
  17.         return _state > 0.75
  18.     end,
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement