Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args={...}
- file=args[1]
- if args[2]==nil then
- size=1
- else
- print(args[2])
- size=tonumber(args[2])
- end
- ni=peripheral.wrap("back")
- if file=="clear" then
- ni.canvas3d().clear()
- end
- color={}
- color[" "]=0x0000FFFF
- color["0"]=0xF0F0F0FF
- color["1"]=0xF2B233FF
- color["2"]=0xE57FD8FF
- color["3"]=0x99B2F2FF
- color["4"]=0xDEDE6CFF
- color["5"]=0x7FCC19FF
- color["6"]=0xF2B2CCFF
- color["7"]=0x4C4C4CFF
- color["8"]=0x999999FF
- color["9"]=0x4C99B2FF
- color["a"]=0xB266E5FF
- color["b"]=0x3366CCFF
- color["c"]=0x7F664CFF
- color["d"]=0x57A64EFF
- color["e"]=0xCC4C4CFF
- color["f"]=0x191919FF
- 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
- chars={}
- 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]))
- y=1
- ni.canvas3d().clear()
- cvsBase=ni.canvas3d()
- cvs=cvsBase.create()
- for x=1,maxX do
- for z=1,maxY do
- block=cvs.addBox(x*size,y,z*size)
- block.setSize(size,size,size)
- block.setColor(color[string.sub(img[z],x,x)])
- end
- end
Add Comment
Please, Sign In to add comment