daily pastebin goal
76%
SHARE
TWEET

Redstone_Set

Asioron Jan 25th, 2017 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ------------------------------------------------
  2. -- Программа для контроллера с красной платой --
  3. --    Бинарные часы для мода OpenComputers    --
  4. --       проект http://computercraft.ru       --
  5. --                2017, © Asior               --
  6. ------------------------------------------------
  7.  
  8. rs = component.proxy(component.list("redstone")())
  9. mod = component.proxy(component.list("modem")())
  10. cor  = 3 --коррекция времени
  11. side = 2 --сторона куда подключен многожильный провод
  12.  
  13. ---------------------------------
  14. local function binarySystem(t)
  15.   local a, s = {}, ''
  16.   while t ~= 0 do
  17.     a[#a+1] = math.fmod(t, 2)
  18.     t = math.floor(t/2)
  19.   end
  20.   for i = 8, 1, -1 do
  21.     if not a[i] then a[i]=0 end
  22.     s = s..a[i]
  23.   end
  24.   return s
  25. end
  26.  
  27. local function redSet(time)
  28.   for i = 0, 15 do
  29.     if string.sub(time, i+1, i+1) == '0' then
  30.       rs.setBundledOutput(side, i, 0)
  31.     else
  32.       rs.setBundledOutput(side, i, 255)
  33.     end
  34.   end
  35. end
  36. ---------------------------------
  37. mod.open(1)
  38. while true do
  39.   local b = {computer.pullSignal(5)}
  40.   if b[1] == 'modem_message' then
  41.     redSet(binarySystem(b[6]+cor)..binarySystem(b[7]))
  42.   end
  43. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top