SHOW:
|
|
- or go back to the newest paste.
| 1 | file="bild" | |
| 2 | me=peripheral.wrap("front")
| |
| 3 | r=peripheral.wrap("right")
| |
| 4 | r.link() | |
| 5 | slot={}
| |
| 6 | chars={}
| |
| 7 | slot[" "]=12 | |
| 8 | slot["0"]=1 | |
| 9 | slot["1"]=2 | |
| 10 | slot["2"]=3 | |
| 11 | slot["3"]=4 | |
| 12 | slot["4"]=5 | |
| 13 | slot["5"]=6 | |
| 14 | slot["6"]=7 | |
| 15 | slot["7"]=8 | |
| 16 | slot["8"]=9 | |
| 17 | slot["9"]=10 | |
| 18 | slot["a"]=11 | |
| 19 | slot["b"]=12 | |
| 20 | slot["c"]=13 | |
| 21 | slot["d"]=14 | |
| 22 | slot["e"]=15 | |
| 23 | slot["f"]=16 | |
| 24 | id={}
| |
| 25 | id[" "]=15*32768+3225 | |
| 26 | id["0"]=0*32768+3225 | |
| 27 | id["1"]=1*32768+3225 | |
| 28 | id["2"]=2*32768+3225 | |
| 29 | id["3"]=3*32768+3225 | |
| 30 | id["4"]=4*32768+3225 | |
| 31 | id["5"]=5*32768+3225 | |
| 32 | id["6"]=6*32768+3225 | |
| 33 | id["7"]=7*32768+3225 | |
| 34 | id["8"]=8*32768+3225 | |
| 35 | id["9"]=9*32768+3225 | |
| 36 | id["a"]=10*32768+3225 | |
| 37 | id["b"]=11*32768+3225 | |
| 38 | id["c"]=12*32768+3225 | |
| 39 | id["d"]=13*32768+3225 | |
| 40 | id["e"]=14*32768+3225 | |
| 41 | id["f"]=15*32768+3225 | |
| 42 | ||
| 43 | function getCharCount(str,char) | |
| 44 | charnum=0 | |
| 45 | for i=1, #str do | |
| 46 | if string.sub(str,i,i)==char then | |
| 47 | charnum=charnum+1 | |
| 48 | end | |
| 49 | end | |
| 50 | return(charnum) | |
| 51 | end | |
| 52 | ||
| 53 | function fileToTable(file) | |
| 54 | if fs.exists(file)~=true then | |
| 55 | print("file"..file.." not found")
| |
| 56 | return(false) | |
| 57 | end | |
| 58 | fp=fs.open(file,"r") | |
| 59 | line={}
| |
| 60 | i=1 | |
| 61 | line[i]=fp.readLine() | |
| 62 | if line[i]==nil then return(false) end | |
| 63 | while line[i]~=nil do | |
| 64 | i=i+1 | |
| 65 | line[i]=fp.readLine() | |
| 66 | end | |
| 67 | return(line) | |
| 68 | end | |
| 69 | ||
| 70 | img=fileToTable(file) | |
| 71 | ||
| 72 | i=1 | |
| 73 | i2=1 | |
| 74 | i3=1 | |
| 75 | while img[i]~=nil do | |
| 76 | for i2=1, #img[i] do | |
| 77 | chars[i3]=string.sub(img[1],i2,i2) | |
| 78 | i3=i3+1 | |
| 79 | end | |
| 80 | i=i+1 | |
| 81 | - | term.write("Slot12 blau: "..tostring(getCharCount(onechar," ")+getCharCount(onechar,"b")))term.setCursorPos(21,5)
|
| 81 | + | |
| 82 | ||
| 83 | onechar="" | |
| 84 | for i=1, #img do | |
| 85 | onechar=onechar..img[i] | |
| 86 | end | |
| 87 | term.clear() | |
| 88 | term.setCursorPos(1,1) | |
| 89 | term.write("Slot1 weiß: "..tostring(getCharCount(onechar,"0")))term.setCursorPos(1,2)
| |
| 90 | term.write("Slot2 orange: "..tostring(getCharCount(onechar,"1")))term.setCursorPos(1,3)
| |
| 91 | term.write("Slot3 magenta: "..tostring(getCharCount(onechar,"2")))term.setCursorPos(1,4)
| |
| 92 | term.write("Slot4 hellblau: "..tostring(getCharCount(onechar,"3")))term.setCursorPos(1,5)
| |
| 93 | term.write("Slot5 gelb: "..tostring(getCharCount(onechar,"4")))term.setCursorPos(1,6)
| |
| 94 | term.write("Slot6 hellgrün: "..tostring(getCharCount(onechar,"5")))term.setCursorPos(1,7)
| |
| 95 | term.write("Slot7 pink: "..tostring(getCharCount(onechar,"6")))term.setCursorPos(1,8)
| |
| 96 | term.write("Slot8 grau: "..tostring(getCharCount(onechar,"7")))term.setCursorPos(21,1)
| |
| 97 | term.write("Slot9 hellgrau: "..tostring(getCharCount(onechar,"8")))term.setCursorPos(21,2)
| |
| 98 | term.write("Slot10 cyan: "..tostring(getCharCount(onechar,"9")))term.setCursorPos(21,3)
| |
| 99 | term.write("Slot11 lila: "..tostring(getCharCount(onechar,"a")))term.setCursorPos(21,4)
| |
| 100 | term.write("Slot12 blau: "..tostring(getCharCount(onechar,"b")+getCharCount(onechar,"b")))term.setCursorPos(21,5)
| |
| 101 | term.write("Slot13 braun: "..tostring(getCharCount(onechar,"c")))term.setCursorPos(21,6)
| |
| 102 | term.write("Slot14 grün: "..tostring(getCharCount(onechar,"d")))term.setCursorPos(21,7)
| |
| 103 | term.write("Slot15 rot: "..tostring(getCharCount(onechar,"e")))term.setCursorPos(21,8)
| |
| 104 | term.write("Slot16 schwarz: "..tostring(getCharCount(onechar,"f")))term.setCursorPos(1,9)
| |
| 105 | ||
| 106 | as=io.read() | |
| 107 | ||
| 108 | if as=="craft" then | |
| 109 | me.craft(id["0"],getCharCount(onechar,"0")) | |
| 110 | me.craft(id["1"],getCharCount(onechar,"1")) | |
| 111 | me.craft(id["2"],getCharCount(onechar,"2")) | |
| 112 | me.craft(id["3"],getCharCount(onechar,"3")) | |
| 113 | me.craft(id["4"],getCharCount(onechar,"4")) | |
| 114 | me.craft(id["5"],getCharCount(onechar,"5")) | |
| 115 | me.craft(id["6"],getCharCount(onechar,"6")) | |
| 116 | me.craft(id["7"],getCharCount(onechar,"7")) | |
| 117 | me.craft(id["8"],getCharCount(onechar,"8")) | |
| 118 | me.craft(id["9"],getCharCount(onechar,"9")) | |
| 119 | me.craft(id["a"],getCharCount(onechar,"a")) | |
| 120 | me.craft(id["b"],getCharCount(onechar,"b")) | |
| 121 | me.craft(id["c"],getCharCount(onechar,"c")) | |
| 122 | me.craft(id["d"],getCharCount(onechar,"d")) | |
| 123 | me.craft(id["e"],getCharCount(onechar,"e")) | |
| 124 | me.craft(id["f"],getCharCount(onechar,"f")) | |
| 125 | end | |
| 126 | ||
| 127 | if as=="request" then | |
| 128 | me.retrieve(id["0"],getCharCount(onechar,"0"),1) | |
| 129 | me.retrieve(id["1"],getCharCount(onechar,"1"),1) | |
| 130 | me.retrieve(id["2"],getCharCount(onechar,"2"),1) | |
| 131 | me.retrieve(id["3"],getCharCount(onechar,"3"),1) | |
| 132 | me.retrieve(id["4"],getCharCount(onechar,"4"),1) | |
| 133 | me.retrieve(id["5"],getCharCount(onechar,"5"),1) | |
| 134 | me.retrieve(id["6"],getCharCount(onechar,"6"),1) | |
| 135 | me.retrieve(id["7"],getCharCount(onechar,"7"),1) | |
| 136 | me.retrieve(id["8"],getCharCount(onechar,"8"),1) | |
| 137 | me.retrieve(id["9"],getCharCount(onechar,"9"),1) | |
| 138 | me.retrieve(id["a"],getCharCount(onechar,"a"),1) | |
| 139 | me.retrieve(id["b"],getCharCount(onechar,"b"),1) | |
| 140 | me.retrieve(id["c"],getCharCount(onechar,"c"),1) | |
| 141 | me.retrieve(id["d"],getCharCount(onechar,"d"),1) | |
| 142 | me.retrieve(id["e"],getCharCount(onechar,"e"),1) | |
| 143 | me.retrieve(id["f"],getCharCount(onechar,"f"),1) | |
| 144 | end | |
| 145 | ||
| 146 | print("Höhe: "..tostring(#img))
| |
| 147 | print("Breite: "..tostring(#img[1]))
| |
| 148 | e,key=os.pullEvent("key")
| |
| 149 | while key~=28 do | |
| 150 | e,key=os.pullEvent("key")
| |
| 151 | end | |
| 152 | ||
| 153 | for i=1, #chars do | |
| 154 | turtle.select(slot[string.sub(onechar,i,i)]) | |
| 155 | if turtle.getItemCount(slot[string.sub(onechar,i,i)])>1 then | |
| 156 | turtle.drop(1) | |
| 157 | else | |
| 158 | if r.resupply(slot[string.sub(onechar,i,i)])==false then term.write("Bitte Material nachfüllen und Taste drücken")
| |
| 159 | e,key=os.pullEvent("key")
| |
| 160 | while key~=28 do | |
| 161 | e,key=os.pullEvent("key")
| |
| 162 | end | |
| 163 | end | |
| 164 | turtle.drop(1) | |
| 165 | end | |
| 166 | end |