--[[
Hard Commander
Manipulation of Hardware
Redstone , Peripherals , RP2 Bundle Cable
By Big Shiny Toys
Notes:
65536
]]--
-- vars
ver = 0.1
local tSides = redstone.getSides()
local tColors = {
white = 1,orange = 2,magenta = 4,lightBlue = 8,
yellow = 16,lime = 32,pink = 64,gray = 128,
lightGray = 256,cyan = 512,purple = 1024,blue = 2048,
brown = 4096,green = 8192,red = 16384,black = 32768}
local tNumber = {
white,orange,magenta,lightBlue,
yellow,lime,pink,gray,
lightGray,cyan,purple,blue,
brown,green,red,black}
local curX,curY = 1,1
-- end vars
local function expand(iInput)
local tOutput = {}
local check = 32768
for i = 1,16 do
if iInput >= check then
tOutput[i] = 1
iInput = iInput - check
else
tOutput[i] = 0
end
check = check/2
end
return tOutput
end
local function compact(tInput)
local iOutput = 0
local check = 1
for i = 16,1,-1 do
if tInput[i] == 1 then
iOutput = iOutput + check
end
check = check*2
end
return iOutput
end
--[[
local this = expand()
for i = 1,16 do
write(this[i])
end
print("")
]]--
while true do
local e,e1,e2,e3,e4,e5,e6 = os.pullEvent()
term.clear()
term.setCursorPos(1,1)
if e == "key" then
if e1 == 200 then -- up key
curY = curY -1
end
if e1 == 208 then -- down key
curY = curY +1
end
if e1 == 203 then -- left key
curX = curX -1
end
if e1 == 205 then -- right key
curX = curX +1
end
if curY > 6 then curY = 1 end
if curY < 1 then curY = 6 end
if curX > 16 then curX = 1 end
if curX < 1 then curX = 16 end
if e1 == 28 then
local total = expand(rs.getBundledOutput(tSides[curY]))
if total[curX] == 1 then
total[curX] = 0
else
total[curX] = 1
end
rs.setBundledOutput(tSides[curY],compact(total))
end
end
term.setCursorPos(25+curX,(3+curY)*2)
write("^")
for i = 1,6 do
local a = rs.getBundledInput(tSides[i])
local val = expand(a)
term.setCursorPos(1,i*2+5)
for o = 1, 16 do
write(val[o])
end
write(" "..a)
a = rs.getBundledOutput(tSides[i])
val = expand(a)
term.setCursorPos(26,i*2+5)
for o = 1, 16 do
write(val[o])
end
write(" "..a)
end
end