Guest User

23D_Printing

a guest
Mar 29th, 2020
193
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- (c) ProgramCrafter
  2. -- This program creates and prints 3D models of letters.
  3.  
  4. local c = require('component')
  5. local p = c.printer3d
  6. local g = c.gpu
  7.  
  8. local tx1 = 'hardened_clay_stained_blue'
  9. local tx2 = 'emerald_block'
  10. local args = {...}
  11. if args[1] then tx1 = args[1] end
  12. if args[2] then tx2 = args[2] end
  13.  
  14. p.reset()
  15. p.addShape(0,0,1, 16,16,16, tx1)
  16.  
  17. while true do
  18.     io.stdout:write('Next shape: ')
  19.    
  20.     local v = io.read()
  21.     if v == '0' or v:lower() == 'print' then -- start printing
  22.         io.stdout:write('Count: ')
  23.         local c = io.read() or 0
  24.         p.commit(tonumber(c))
  25.         while (p.status()) == 'busy' do os.sleep(0.05) end
  26.         break
  27.     elseif v and tonumber(v) then
  28.         v = tonumber(v)
  29.        
  30.         local lx = math.floor(v / 4096)
  31.         v = v - lx * 4096
  32.         local w = math.floor(v / 256)
  33.         v = v - w * 256
  34.         local by = math.floor(v / 16)
  35.         v = v - by * 16
  36.         local h = v
  37.        
  38.         p.addShape(lx,by,0, lx+w,by+h,1, tx2)
  39.     end
  40. end
RAW Paste Data