Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file="bild"
- me=peripheral.wrap("front")
- r=peripheral.wrap("right")
- slot={}
- chars={}
- slot[" "]=12
- slot["0"]=1
- slot["1"]=2
- slot["2"]=3
- slot["3"]=4
- slot["4"]=5
- slot["5"]=6
- slot["6"]=7
- slot["7"]=8
- slot["8"]=9
- slot["9"]=10
- slot["a"]=11
- slot["b"]=12
- slot["c"]=13
- slot["d"]=14
- slot["e"]=15
- slot["f"]=16
- id={}
- id[" "]=15*32768+3225
- id["0"]=0*32768+3225
- id["1"]=1*32768+3225
- id["2"]=2*32768+3225
- id["3"]=3*32768+3225
- id["4"]=4*32768+3225
- id["5"]=5*32768+3225
- id["6"]=6*32768+3225
- id["7"]=7*32768+3225
- id["8"]=8*32768+3225
- id["9"]=9*32768+3225
- id["a"]=10*32768+3225
- id["b"]=11*32768+3225
- id["c"]=12*32768+3225
- id["d"]=13*32768+3225
- id["e"]=14*32768+3225
- id["f"]=15*32768+3225
- function getCharCount(str,char)
- charnum=0
- for i=1, #str do
- if string.sub(str,i,i)==char then
- charnum=charnum+1
- end
- end
- return(charnum)
- end
- function fileToTable(file)
- if fs.exists(file)~=true then
- print("file"..file.." not found")
- return(false)
- end
- fp=fs.open(file,"r")
- line={}
- i=1
- line[i]=fp.readLine()
- if line[i]==nil then return(false) end
- while line[i]~=nil do
- i=i+1
- line[i]=fp.readLine()
- end
- end
- return(line)
- end
- img=fileToTable(file)
- i=1
- i2=1
- i3=1
- while img[i]~=nil do
- for i2=1, #img[i] do
- chars[i3]=string.sub(img[1],i2,i2)
- i3=i3+1
- end
- i=i+1
- end
- onechar=""
- for i=1, #img do
- onechar=onechar..img[i]
- end
- term.clear()
- term.setCursorPos(1,1)
- term.write("Slot1 weiß: "..tostring(getCharCount(onechar,"0")))term.setCursorPos(1,2)
- term.write("Slot2 orange: "..tostring(getCharCount(onechar,"1")))term.setCursorPos(1,3)
- term.write("Slot3 magenta: "..tostring(getCharCount(onechar,"2")))term.setCursorPos(1,4)
- term.write("Slot4 hellblau: "..tostring(getCharCount(onechar,"3")))term.setCursorPos(1,5)
- term.write("Slot5 gelb: "..tostring(getCharCount(onechar,"4")))term.setCursorPos(1,6)
- term.write("Slot6 hellgrün: "..tostring(getCharCount(onechar,"5")))term.setCursorPos(1,7)
- term.write("Slot7 pink: "..tostring(getCharCount(onechar,"6")))term.setCursorPos(1,8)
- term.write("Slot8 grau: "..tostring(getCharCount(onechar,"7")))term.setCursorPos(21,1)
- term.write("Slot9 hellgrau: "..tostring(getCharCount(onechar,"8")))term.setCursorPos(21,2)
- term.write("Slot10 cyan: "..tostring(getCharCount(onechar,"9")))term.setCursorPos(21,3)
- term.write("Slot11 lila: "..tostring(getCharCount(onechar,"a")))term.setCursorPos(21,4)
- term.write("Slot12 blau: "..tostring(getCharCount(onechar,"b")+getCharCount(onechar,"b")))term.setCursorPos(21,5)
- term.write("Slot13 braun: "..tostring(getCharCount(onechar,"c")))term.setCursorPos(21,6)
- term.write("Slot14 grün: "..tostring(getCharCount(onechar,"d")))term.setCursorPos(21,7)
- term.write("Slot15 rot: "..tostring(getCharCount(onechar,"e")))term.setCursorPos(21,8)
- term.write("Slot16 schwarz: "..tostring(getCharCount(onechar,"f")))term.setCursorPos(1,9)
- as=io.read()
- if as=="craft" then
- me.craft(id["0"],getCharCount(onechar,"0"))
- me.craft(id["1"],getCharCount(onechar,"1"))
- me.craft(id["2"],getCharCount(onechar,"2"))
- me.craft(id["3"],getCharCount(onechar,"3"))
- me.craft(id["4"],getCharCount(onechar,"4"))
- me.craft(id["5"],getCharCount(onechar,"5"))
- me.craft(id["6"],getCharCount(onechar,"6"))
- me.craft(id["7"],getCharCount(onechar,"7"))
- me.craft(id["8"],getCharCount(onechar,"8"))
- me.craft(id["9"],getCharCount(onechar,"9"))
- me.craft(id["a"],getCharCount(onechar,"a"))
- me.craft(id["b"],getCharCount(onechar,"b"))
- me.craft(id["c"],getCharCount(onechar,"c"))
- me.craft(id["d"],getCharCount(onechar,"d"))
- me.craft(id["e"],getCharCount(onechar,"e"))
- me.craft(id["f"],getCharCount(onechar,"f"))
- end
- if as=="request" then
- me.retrieve(id["0"],getCharCount(onechar,"0"),1)
- me.retrieve(id["1"],getCharCount(onechar,"1"),1)
- me.retrieve(id["2"],getCharCount(onechar,"2"),1)
- me.retrieve(id["3"],getCharCount(onechar,"3"),1)
- me.retrieve(id["4"],getCharCount(onechar,"4"),1)
- me.retrieve(id["5"],getCharCount(onechar,"5"),1)
- me.retrieve(id["6"],getCharCount(onechar,"6"),1)
- me.retrieve(id["7"],getCharCount(onechar,"7"),1)
- me.retrieve(id["8"],getCharCount(onechar,"8"),1)
- me.retrieve(id["9"],getCharCount(onechar,"9"),1)
- me.retrieve(id["a"],getCharCount(onechar,"a"),1)
- me.retrieve(id["b"],getCharCount(onechar,"b"),1)
- me.retrieve(id["c"],getCharCount(onechar,"c"),1)
- me.retrieve(id["d"],getCharCount(onechar,"d"),1)
- me.retrieve(id["e"],getCharCount(onechar,"e"),1)
- me.retrieve(id["f"],getCharCount(onechar,"f"),1)
- end
- print("Höhe: "..tostring(#img))
- print("Breite: "..tostring(#img[1]))
- e,key=os.pullEvent("key")
- while key~=28 do
- e,key=os.pullEvent("key")
- end
- for i=1, #chars do
- turtle.select(slot[string.sub(onechar,i,i)])
- if turtle.getItemCount(slot[string.sub(onechar,i,i)])>1 then
- turtle.drop(1)
- else
- print("Bitte slot "..slot[string.sub(onechar,i,i)].." nachfüllen")
- io.read()
- end
- turtle.drop(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement