ecco7777

CC ChiselBits Pixelart Plethora Player Controller and Supplier

May 24th, 2022 (edited)
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.29 KB | None | 0 0
  1. ni=peripheral.wrap("back")
  2. if ni.listModules~=nil then --NeuralInterface Script
  3. --Modul Abfrage
  4. if ni.hasModule("plethora:kinetic")==false then print("please add kinetic module") end
  5. if ni.hasModule("plethora:introspection")==false then print("please add introspection module") end
  6. if peripheral.getType("front")~="modem" then print("please add modem on front side") end
  7.  
  8. launchStrength=0.05723
  9. --connect
  10. rednet.open("front")
  11. ni.look(90,0)
  12. while true do
  13.     resp={os.pullEvent("modem_message")}--rednet Event Abfrage
  14.     mes=resp[5].message
  15.     if mes=="north" then ni.launch(180,0,launchStrength) end
  16.     if mes=="south" then ni.launch(0,0,launchStrength) end
  17.     if mes=="east" then ni.launch(270,0,launchStrength) end
  18.     if mes=="west" then ni.launch(90,0,launchStrength) end
  19.     if mes=="up" then ni.look(180,-90) end
  20. end
  21. --if ni.hasModule("plethora:sensor")==false then print("please add kinetic module") end
  22. end
  23.  
  24. --Computer
  25. if ni.listModules==nil then
  26.     if peripheral.getType("right")~="appliedenergistics2:interface" then print("please add interface on right side") end
  27.     if peripheral.getType("top")~="manipulator" then print("please add manipulator on left side") end
  28.     if peripheral.getType("front")~="modem" then print("please add modem on back side") end
  29.     --peripherals
  30.     me=peripheral.wrap("right")
  31.     inv=peripheral.wrap("top")
  32.     rednet.open("back")
  33.     --variables
  34.     args={...}
  35.     file=args[1]
  36.     chestSide="west"
  37.     delay=0.4
  38.  
  39.     --sort blocks from me to colors
  40.     items=me.findItems(me.listAvailableItems()[1])
  41.     id={}
  42.     for i=1,#items do
  43.         name=items[i].getMetadata().displayName
  44.         if string.find(name,"Black")~=nil then id[" "]=items[i] end --Black
  45.         if string.find(name,"White")~=nil then id["0"]=items[i] end --White
  46.         if string.find(name,"Orange")~=nil then id["1"]=items[i] end --Orange
  47.         if string.find(name,"Magenta")~=nil then id["2"]=items[i] end --Magenta
  48.         if string.find(name,"Light Blue")~=nil then id["3"]=items[i] end --Light Blue
  49.         if string.find(name,"Yellow")~=nil then id["4"]=items[i] end --Yellow
  50.         if string.find(name,"Lime")~=nil then id["5"]=items[i] end --Lime
  51.         if string.find(name,"Pink")~=nil then id["6"]=items[i] end  --Pink
  52.         if string.find(name,"Gray")~=nil then id["7"]=items[i] end  --Gray
  53.         if string.find(name,"Light Gray")~=nil then id["8"]=items[i] end  --Light Gray
  54.         if string.find(name,"Cyan")~=nil then id["9"]=items[i] end  --Cyan
  55.         if string.find(name,"Purple")~=nil then id["a"]=items[i] end  --Purple
  56.         if string.find(name,"Blue")~=nil then id["b"]=items[i] end  --Blue
  57.         if string.find(name,"Brown")~=nil then id["c"]=items[i] end  --Brown
  58.         if string.find(name,"Green")~=nil then id["d"]=items[i] end  --Green
  59.         if string.find(name,"Red")~=nil then id["e"]=items[i] end  --Red
  60.         if string.find(name,"Black")~=nil then id["f"]=items[i] end  --Black
  61.     end
  62.  
  63.     function getCharCount(str,char)
  64.         charnum=0
  65.         for i=1, #str do
  66.             if string.sub(str,i,i)==char then
  67.                 charnum=charnum+1
  68.             end
  69.         end
  70.     return(charnum)
  71.     end
  72.      
  73.     function fileToTable(file)
  74.             if fs.exists(file)~=true then
  75.                 print("file"..file.." not found")
  76.                 return(false)
  77.             end
  78.         fp=fs.open(file,"r")
  79.         line={}
  80.         i=1
  81.         line[i]=fp.readLine()
  82.             if line[i]==nil then return(false) end
  83.             while line[i]~=nil do  
  84.             i=i+1
  85.             line[i]=fp.readLine()
  86.             end
  87.     return(line)
  88.     end
  89.      
  90.     img=fileToTable(file)
  91.     chars={}
  92.     i=1
  93.     i2=1
  94.     i3=1
  95.         while img[i]~=nil do
  96.             for i2=1, #img[i] do
  97.                 chars[i3]=string.sub(img[1],i2,i2)
  98.                 i3=i3+1
  99.             end
  100.         i=i+1
  101.         end
  102.      
  103.     onechar=""
  104.         for i=1, #img do
  105.             onechar=onechar..img[i]
  106.         end
  107.  
  108.     --Print Needed Colors
  109.     term.clear()
  110.     term.setCursorPos(1,1)
  111.     term.write("Slot1 weiß: "..tostring(getCharCount(onechar,"0")))term.setCursorPos(1,2)
  112.     term.write("Slot2 orange: "..tostring(getCharCount(onechar,"1")))term.setCursorPos(1,3)
  113.     term.write("Slot3 magenta: "..tostring(getCharCount(onechar,"2")))term.setCursorPos(1,4)
  114.     term.write("Slot4 hellblau: "..tostring(getCharCount(onechar,"3")))term.setCursorPos(1,5)
  115.     term.write("Slot5 gelb: "..tostring(getCharCount(onechar,"4")))term.setCursorPos(1,6)
  116.     term.write("Slot6 hellgrün: "..tostring(getCharCount(onechar,"5")))term.setCursorPos(1,7)
  117.     term.write("Slot7 pink: "..tostring(getCharCount(onechar,"6")))term.setCursorPos(1,8)
  118.     term.write("Slot8 grau: "..tostring(getCharCount(onechar,"7")))term.setCursorPos(21,1)
  119.     term.write("Slot9 hellgrau: "..tostring(getCharCount(onechar,"8")))term.setCursorPos(21,2)
  120.     term.write("Slot10 cyan: "..tostring(getCharCount(onechar,"9")))term.setCursorPos(21,3)
  121.     term.write("Slot11 lila: "..tostring(getCharCount(onechar,"a")))term.setCursorPos(21,4)
  122.     term.write("Slot12 blau: "..tostring(getCharCount(onechar,"b")+getCharCount(onechar,"b")))term.setCursorPos(21,5)
  123.     term.write("Slot13 braun: "..tostring(getCharCount(onechar,"c")))term.setCursorPos(21,6)
  124.     term.write("Slot14 grün: "..tostring(getCharCount(onechar,"d")))term.setCursorPos(21,7)
  125.     term.write("Slot15 rot: "..tostring(getCharCount(onechar,"e")))term.setCursorPos(21,8)
  126.     term.write("Slot16 schwarz: "..tostring(getCharCount(onechar,"f")))term.setCursorPos(1,9)
  127.  
  128.     maxX=#img[1]
  129.     maxY=#img
  130.     print("Höhe: "..tostring(#img))
  131.     print("Breite: "..tostring(#img[1]))
  132.     as=io.read() --wait for interaction
  133.    
  134.     --not needed actually
  135.     blocks={}
  136.     for i1=1,#onechar do
  137.         table.insert(blocks,string.sub(onechar,i1,i1))
  138.     end
  139.  
  140.     --build/request Items
  141.     function pushBit(block)
  142.         while inv.getInventory().getItem(1)~=nil do
  143.             sleep(0.1)
  144.         end
  145.         block.export("up",1,1)
  146.         inv.getInventory().pullItems(chestSide,1,1,1)
  147.     end
  148.  
  149.     i=1
  150.     while i<#blocks do
  151.         for i2=1,maxX do
  152.             pushBit(id[blocks[i]])
  153.             print(i.."/"..#blocks)
  154.             i=i+1
  155.         end
  156.         rednet.broadcast("north")
  157.         sleep(delay)
  158.     end
  159. end
Add Comment
Please, Sign In to add comment