Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args={...}
- file=args[1]
- me=peripheral.wrap("left")
- matID="chisel:antiblock"
- chars={}
- delay=0.1
- id={}
- id[" "]=0 --empty
- id["0"]=15
- id["1"]=14
- id["2"]=13
- id["3"]=12
- id["4"]=11
- id["5"]=10
- id["6"]=9
- id["7"]=8
- id["8"]=7
- id["9"]=6
- id["a"]=5
- id["b"]=4
- id["c"]=3
- id["d"]=2
- id["e"]=1
- id["f"]=0
- 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("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)
- maxX=#img[1]
- maxY=#img
- print("Höhe: "..tostring(#img))
- print("Breite: "..tostring(#img[1]))
- as=io.read()
- --dviding into chunks
- maxChunksY=math.ceil(maxY/16)
- maxChunksX=math.ceil(maxX/16)
- maxChunks=maxChunksX*maxChunksY
- chunks={}
- for icy=1, maxChunksY do --icy ichunksy
- ccyMax=16
- ccyMin=icy*16-16
- if maxChunksY>math.floor(maxY/16) and icx==math.floor(maxY/16) then
- ccyMax=math.mod(maxY/16)
- ccyMin=(icy-1)*16+1
- end
- for icx=1, maxChunksX do --icx ichunksx
- ccxMax=16
- ccxMin=icx*16-16
- if maxChunksX>math.floor(maxX/16) and icx==math.floor(maxX/16) then
- ccxMax=math.mod(maxX/16)
- ccxMin=(icx-1)*16+1
- end
- --addtochunks
- for iccx=1,ccxMax do
- for iccy=1,ccyMax do
- table.insert(chunks,id[string.sub(img[ccyMin+iccx],ccxMin+iccy,ccxMin+iccy)])
- end
- end
- end
- end
- for i=1,#chunks do
- fingerprint={damage=chunks[i],name=matID}
- me.findItem(fingerprint).export("up",1)
- sleep(delay)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement