Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dataIsSended= false
- function binToDec(bin) -- this function is used to convert a binary number into a decimal one
- for i=1,#bin do
- dec=(string.sub(bin,i,i)*2^i)+dec
- end
- return dec
- end
- function hexToDec(hex) -- this function is used to convert an hexadecimal number into a decimal one
- for i=1,#hex do
- if string.byte(hex,i)>64 then
- dec=((string.byte(string.sub(hex,i,i),i)-55)*16^i)+dec
- else
- dec=(string.sub(hex,i,i)*16^i)+dec
- end
- end
- return dec
- end
- function decTobin(dec) -- this function is used to convert a decimal number into a binary one
- local tab={}
- while dec>0 do
- rest=dec%2
- tab[#tab+1]=rest
- dec=(dec-rest)/2
- end
- return table.concat(tab)
- end
- function decToHex(dec) -- this function is used to convert a decimal number into an hexadecimal one
- local tab={}
- while dec>0 do
- rest=dec%16
- tab[#tab+1]=rest
- dec=(dec-rest)/16
- end
- for i=1,#tab do
- if tab[i]>9 then
- tab[i]=string.char(tab[i]+55)
- end
- end
- return table.concat(tab)
- end
- function sendPMR(data, tick, sideClk, sideDat) -- this function is used to send a serial signal to a programable rednet controler from MFR
- for i=1,#data do
- bit=string.sub(data,i,i)
- redstone.setOutput(sideClk,true)
- os.sleep(tick*0.05)
- redstone.setOutput(sideClk,false)
- if bit=="1" then
- redstone.setOutput(sideDat,true)
- os.sleep(tick*0.05)
- else
- redstone.setOutput(sideDat,false)
- os.sleep(tick*0.05)
- end
- end
- dataIsSended= true
- end
Advertisement
Add Comment
Please, Sign In to add comment