Posted 18 August 2012 - 04:00 PM
I wanted to write a program to encode-decode text for turtles, but then I thought that I get tired of updating the code, so that publish of the core of decoder.
http://www.computerc...adecimal-table/
------------------reader and decoder [begin]------------------
tabl={}
local function rea(x)
turtle.select(1) local a = turtle.compareDown() --check slot 1
turtle.select(2) local b = turtle.compareDown() --check slot 2
turtle.select(3) local c = turtle.compareDown() --check slot 3
turtle.select(4) local d = turtle.compareDown() --check slot 4
if a == true then tabl[x] = "0" end --if block is in the slot - write code block in table
if b == true then tabl[x] = "1" end --=||=
if c == true then tabl[x] = "2" end --=||=
if d == true then tabl[x] = "3" end --=||=
turtle.forward() --step forward
return tabl[x] --return the code block
end
-------------------------------------------------------------
local function dec()
-----------------
local b1=rea(1)--| read the one quaternary bit
local b2=rea(1)--| =||=
local b3=rea(1)--| =||=
local b4=rea(1)--| =||=
-----------------/
return hex.decodeHB(b3..b4,b1..b2) --decode bits in a symbol and return symbol
end
------------------reader and decoder [end]------------------
For decoding program uses my hex table.http://www.computerc...adecimal-table/