SHOW:
|
|
- or go back to the newest paste.
| 1 | local arg= {...}
| |
| 2 | - | arg1=arg[1] |
| 2 | + | argData=arg[1] |
| 3 | ||
| 4 | - | if arg1==nil then |
| 4 | + | if argData==nil then |
| 5 | ||
| 6 | data="0000000000000000" | |
| 7 | ||
| 8 | - | elseif #arg1>16 then |
| 8 | + | elseif #argData>16 then |
| 9 | ||
| 10 | print("votre donee doit pas contenir plus de 16 bits")
| |
| 11 | do return end | |
| 12 | - | elseif #arg1<16 then |
| 12 | + | |
| 13 | else | |
| 14 | - | for i=1,16-#arg1 do |
| 14 | + | |
| 15 | if #argData<16 then | |
| 16 | - | arg1="0"..arg1 |
| 16 | + | |
| 17 | for i=1,16-#argData do | |
| 18 | ||
| 19 | argData="0"..argData | |
| 20 | ||
| 21 | end | |
| 22 | - | for i=1,#arg1 do |
| 22 | + | |
| 23 | end | |
| 24 | - | ascii=string.byte(arg1,i) |
| 24 | + | |
| 25 | for i=1,#argData do | |
| 26 | ||
| 27 | ascii=string.byte(argData,i) | |
| 28 | ||
| 29 | if ascii<48 or ascii>49 then | |
| 30 | ||
| 31 | print("la donnee doit etre un nombre binaire")
| |
| 32 | do return end | |
| 33 | ||
| 34 | end | |
| 35 | - | data=string.reverse(arg1) |
| 35 | + | |
| 36 | end | |
| 37 | ||
| 38 | data=string.reverse(argData) | |
| 39 | - | arg2=arg[2] |
| 39 | + | |
| 40 | end | |
| 41 | - | if arg2==nil then |
| 41 | + | |
| 42 | argTick=arg[2] | |
| 43 | ||
| 44 | if argTick==nil then | |
| 45 | ||
| 46 | tick=4 | |
| 47 | - | for i=1,#arg2 do |
| 47 | + | |
| 48 | else | |
| 49 | - | ascii=string.byte(arg2,i) |
| 49 | + | |
| 50 | for i=1,#argTick do | |
| 51 | ||
| 52 | ascii=string.byte(argTick,i) | |
| 53 | ||
| 54 | if ascii<48 or ascii>57 then | |
| 55 | ||
| 56 | print("cette donnee doit etre un nombre")
| |
| 57 | do return end | |
| 58 | ||
| 59 | end | |
| 60 | ||
| 61 | tick=(ascii-48)*10^(i-1) | |
| 62 | ||
| 63 | end | |
| 64 | - | arg3=arg[3] |
| 64 | + | |
| 65 | - | arg4=arg[4] |
| 65 | + | |
| 66 | ||
| 67 | - | if arg3==nil or arg4==nil then |
| 67 | + | argSideClk=arg[3] |
| 68 | argSideDat=arg[4] | |
| 69 | ||
| 70 | if argSideClk==nil or argSideDat==nil then | |
| 71 | ||
| 72 | - | elseif (arg4~="right" and arg4~="left" and arg4~="top" and arg4~="bottom" and arg4~="front" and arg4~="back") or (arg3~="right" and arg3~="left" and arg3~="top" and arg3~="bottom" and arg3~="front" and arg3~="back") then |
| 72 | + | |
| 73 | sidedat="back" | |
| 74 | ||
| 75 | 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 | |
| 76 | ||
| 77 | - | elseif arg4==arg3 then |
| 77 | + | |
| 78 | do return end | |
| 79 | ||
| 80 | elseif argSideDat==argSideClk then | |
| 81 | ||
| 82 | - | elseif peripheral.getType(arg4)~="factoryredstonecable" or peripheral.getType(arg3)~="factoryredstonecable" then |
| 82 | + | |
| 83 | do return end | |
| 84 | ||
| 85 | elseif peripheral.getType(argSideDat)~="factoryredstonecable" or peripheral.getType(argSideClk)~="factoryredstonecable" then | |
| 86 | ||
| 87 | 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")
| |
| 88 | do return end | |
| 89 | - | sideclk=arg3 |
| 89 | + | |
| 90 | - | sidedat=arg4 |
| 90 | + | |
| 91 | ||
| 92 | sideclk=argSideClk | |
| 93 | sidedat=argSideDat | |
| 94 | ||
| 95 | end | |
| 96 | ||
| 97 | for i=1,#data do | |
| 98 | ||
| 99 | bit=string.sub(data,i,i) | |
| 100 | redstone.setOutput(sideclk,true) | |
| 101 | os.sleep(tick*0.05) | |
| 102 | redstone.setOutput(sideclk,false) | |
| 103 | ||
| 104 | if bit=="1" then | |
| 105 | ||
| 106 | redstone.setOutput(sidedat,true) | |
| 107 | os.sleep(tick*0.05) | |
| 108 | ||
| 109 | else | |
| 110 | ||
| 111 | redstone.setOutput(sidedat,false) | |
| 112 | os.sleep(tick*0.05) | |
| 113 | ||
| 114 | end | |
| 115 | ||
| 116 | end |