Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------
- -- Программа для контроллера с красной платой --
- -- Бинарные часы для мода OpenComputers --
- -- проект http://computercraft.ru --
- -- 2017, © Asior --
- ------------------------------------------------
- rs = component.proxy(component.list("redstone")())
- mod = component.proxy(component.list("modem")())
- cor = 3 --коррекция времени
- side = 2 --сторона куда подключен многожильный провод
- ---------------------------------
- local function binarySystem(t)
- local a, s = {}, ''
- while t ~= 0 do
- a[#a+1] = math.fmod(t, 2)
- t = math.floor(t/2)
- end
- for i = 8, 1, -1 do
- if not a[i] then a[i]=0 end
- s = s..a[i]
- end
- return s
- end
- local function redSet(time)
- for i = 0, 15 do
- if string.sub(time, i+1, i+1) == '0' then
- rs.setBundledOutput(side, i, 0)
- else
- rs.setBundledOutput(side, i, 255)
- end
- end
- end
- ---------------------------------
- mod.open(1)
- while true do
- local b = {computer.pullSignal(5)}
- if b[1] == 'modem_message' then
- redSet(binarySystem(b[6]+cor)..binarySystem(b[7]))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement