Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file="bild"
- 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
- 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
- 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("S1 weiß: "..tostring(getCharCount(onechar,"0")))term.setCursorPos(1,2)
- term.write("S2 orange: "..tostring(getCharCount(onechar,"1")))term.setCursorPos(1,3)
- term.write("S3 magenta: "..tostring(getCharCount(onechar,"2")))term.setCursorPos(1,4)
- term.write("S4 hellblau: "..tostring(getCharCount(onechar,"3")))term.setCursorPos(1,5)
- term.write("S5 gelb: "..tostring(getCharCount(onechar,"4")))term.setCursorPos(1,6)
- term.write("S6 hellgrün: "..tostring(getCharCount(onechar,"5")))term.setCursorPos(1,7)
- term.write("S7 pink: "..tostring(getCharCount(onechar,"6")))term.setCursorPos(1,8)
- term.write("S8 grau: "..tostring(getCharCount(onechar,"7")))term.setCursorPos(21,1)
- term.write("S9 hellgrau: "..tostring(getCharCount(onechar,"8")))term.setCursorPos(21,2)
- term.write("S10 cyan: "..tostring(getCharCount(onechar,"9")))term.setCursorPos(21,3)
- term.write("S11 lila: "..tostring(getCharCount(onechar,"a")))term.setCursorPos(21,4)
- term.write("S12 blau: "..tostring(getCharCount(onechar," ")+getCharCount(onechar,"b")))term.setCursorPos(21,5)
- term.write("S13 braun: "..tostring(getCharCount(onechar,"c")))term.setCursorPos(21,6)
- term.write("S14 grün: "..tostring(getCharCount(onechar,"d")))term.setCursorPos(21,7)
- term.write("S15 rot: "..tostring(getCharCount(onechar,"e")))term.setCursorPos(21,8)
- term.write("S16 schwarz: "..tostring(getCharCount(onechar,"f")))term.setCursorPos(1,9)
- 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)])>0 then
- turtle.drop(1)
- else
- term.write("Bitte Material nachfüllen und Taste drücken")
- e,key=os.pullEvent("key")
- while key~=28 do
- e,key=os.pullEvent("key")
- end
- term.write(" ")
- turtle.drop(1)
- end
- end
Add Comment
Please, Sign In to add comment