Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local arg= {...}
- argData=arg[1]
- if argData==nil then
- data="0000000000000000"
- elseif #argData>16 then
- print("votre donee doit pas contenir plus de 16 bits")
- do return end
- else
- if #argData<16 then
- for i=1,16-#argData do
- argData="0"..argData
- end
- end
- for i=1,#argData do
- ascii=string.byte(argData,i)
- if ascii<48 or ascii>49 then
- print("la donnee doit etre un nombre binaire")
- do return end
- end
- end
- data=string.reverse(argData)
- end
- argTick=arg[2]
- if argTick==nil then
- tick=4
- else
- for i=1,#argTick do
- ascii=string.byte(argTick,i)
- if ascii<48 or ascii>57 then
- print("cette donnee doit etre un nombre")
- do return end
- end
- tick=(ascii-48)*10^(i-1)
- end
- end
- argSideClk=arg[3]
- argSideDat=arg[4]
- if argSideClk==nil or argSideDat==nil then
- sideclk="right"
- sidedat="back"
- elseif (argSideDat~="right" and argSideDat~="left" and argSideDat~="top" and argSideDat~="bottom" and argSideDat~="front" and argSideDat~="back") or (argSideClk~="right" and argSideClk~="left" and argSideClk~="top" and argSideClk~="bottom" and argSideClk~="front" and argSideClk~="back") then
- print("cote invalide les cote valides sont: front,back,top,bottom,right,left")
- do return end
- elseif argSideDat==argSideClk then
- print("vous ne pouvez pas envoyer la donnee et l'horloge sur le meme cable redstone")
- do return end
- elseif peripheral.getType(argSideDat)~="factoryredstonecable" or peripheral.getType(argSideClk)~="factoryredstonecable" then
- print("votre cable doit etre un rednet cable venant du mod Mine Factory Reloaded ces cable doivent etre connecte a un programable rednet controler qui effectuera la desserialisation")
- do return end
- else
- sideclk=argSideClk
- sidedat=argSideDat
- end
- 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
Advertisement
Add Comment
Please, Sign In to add comment