ecco7777

CC Plethora Overlayglasses 3D Pixelart Projector

Jun 5th, 2022 (edited)
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.25 KB | None | 0 0
  1. args={...}
  2. file=args[1]
  3. if args[2]==nil then
  4. size=1
  5. else
  6.     print(args[2])
  7.     size=tonumber(args[2])
  8. end
  9. ni=peripheral.wrap("back")
  10.  
  11. if file=="clear" then
  12.     ni.canvas3d().clear()
  13. end
  14.  
  15. color={}
  16. color[" "]=0x0000FFFF
  17. color["0"]=0xF0F0F0FF
  18. color["1"]=0xF2B233FF
  19. color["2"]=0xE57FD8FF
  20. color["3"]=0x99B2F2FF
  21. color["4"]=0xDEDE6CFF
  22. color["5"]=0x7FCC19FF
  23. color["6"]=0xF2B2CCFF
  24. color["7"]=0x4C4C4CFF
  25. color["8"]=0x999999FF
  26. color["9"]=0x4C99B2FF
  27. color["a"]=0xB266E5FF
  28. color["b"]=0x3366CCFF
  29. color["c"]=0x7F664CFF
  30. color["d"]=0x57A64EFF
  31. color["e"]=0xCC4C4CFF
  32. color["f"]=0x191919FF
  33.  
  34. function getCharCount(str,char)
  35.     charnum=0
  36.     for i=1, #str do
  37.         if string.sub(str,i,i)==char then
  38.             charnum=charnum+1
  39.         end
  40.     end
  41. return(charnum)
  42. end
  43.  
  44. function fileToTable(file)
  45.         if fs.exists(file)~=true then
  46.             print("file"..file.." not found")
  47.             return(false)
  48.         end
  49.     fp=fs.open(file,"r")
  50.     line={}
  51.     i=1
  52.     line[i]=fp.readLine()
  53.         if line[i]==nil then return(false) end
  54.         while line[i]~=nil do  
  55.         i=i+1
  56.         line[i]=fp.readLine()
  57.         end
  58. return(line)
  59. end
  60.  
  61. img=fileToTable(file)
  62.  
  63. i=1
  64. i2=1
  65. i3=1
  66. chars={}
  67.     while img[i]~=nil do
  68.         for i2=1, #img[i] do
  69.             chars[i3]=string.sub(img[1],i2,i2)
  70.             i3=i3+1
  71.         end
  72.     i=i+1
  73.     end
  74.  
  75. onechar=""
  76.     for i=1, #img do
  77.         onechar=onechar..img[i]
  78.     end
  79. term.clear()
  80. term.setCursorPos(1,1)
  81. term.write("Slot1 weiß: "..tostring(getCharCount(onechar,"0")))term.setCursorPos(1,2)
  82. term.write("Slot2 orange: "..tostring(getCharCount(onechar,"1")))term.setCursorPos(1,3)
  83. term.write("Slot3 magenta: "..tostring(getCharCount(onechar,"2")))term.setCursorPos(1,4)
  84. term.write("Slot4 hellblau: "..tostring(getCharCount(onechar,"3")))term.setCursorPos(1,5)
  85. term.write("Slot5 gelb: "..tostring(getCharCount(onechar,"4")))term.setCursorPos(1,6)
  86. term.write("Slot6 hellgrün: "..tostring(getCharCount(onechar,"5")))term.setCursorPos(1,7)
  87. term.write("Slot7 pink: "..tostring(getCharCount(onechar,"6")))term.setCursorPos(1,8)
  88. term.write("Slot8 grau: "..tostring(getCharCount(onechar,"7")))term.setCursorPos(21,1)
  89. term.write("Slot9 hellgrau: "..tostring(getCharCount(onechar,"8")))term.setCursorPos(21,2)
  90. term.write("Slot10 cyan: "..tostring(getCharCount(onechar,"9")))term.setCursorPos(21,3)
  91. term.write("Slot11 lila: "..tostring(getCharCount(onechar,"a")))term.setCursorPos(21,4)
  92. term.write("Slot12 blau: "..tostring(getCharCount(onechar,"b")+getCharCount(onechar,"b")))term.setCursorPos(21,5)
  93. term.write("Slot13 braun: "..tostring(getCharCount(onechar,"c")))term.setCursorPos(21,6)
  94. term.write("Slot14 grün: "..tostring(getCharCount(onechar,"d")))term.setCursorPos(21,7)
  95. term.write("Slot15 rot: "..tostring(getCharCount(onechar,"e")))term.setCursorPos(21,8)
  96. term.write("Slot16 schwarz: "..tostring(getCharCount(onechar,"f")))term.setCursorPos(1,9)
  97.  
  98. maxX=#img[1]
  99. maxY=#img
  100. print("Höhe: "..tostring(#img))
  101. print("Breite: "..tostring(#img[1]))
  102.  
  103. y=1
  104. ni.canvas3d().clear()
  105. cvsBase=ni.canvas3d()
  106. cvs=cvsBase.create()
  107.  
  108. for x=1,maxX do
  109.     for z=1,maxY do
  110.         block=cvs.addBox(x*size,y,z*size)
  111.         block.setSize(size,size,size)
  112.         block.setColor(color[string.sub(img[z],x,x)])
  113.     end
  114. end
Add Comment
Please, Sign In to add comment