Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local args = require("shell").parse(...)
- local hologram = component.hologram
- local colorPoint={}
- function parallelepipedPrint(x1,y1,z1,x2,y2,z2,col)
- for x = x1+1, x2 do
- for y = y1+1, y2 do
- for z = z1+1, z2 do
- hologram.set(z+16,y+16,x+16,col and col or math.random(1,3))
- end
- end
- end
- end
- function printModelToHologram(file,block)
- local file,reason = io.open(file)
- if not file then io.stderr:write("Failed opening file: " .. reason .. "\n") os.exit(0) end
- file,reason = load("return {"..file:read("*all").."}")
- if not file then io.stderr:write("Failed loading model: " .. reason .. "\n") os.exit(1) end
- file = file()[block]
- if file then
- print("Print to hologram: "..file.label)
- for j,v in pairs(file.shapes) do
- local color
- for i = 1, 3 do
- if colorPoint[i] == v.tint then
- color = i
- break
- else
- if not colorPoint[i] then
- hologram.setPaletteColor(i, v.tint)
- colorPoint[i] = v.tint
- color = i
- break
- end
- end
- end
- parallelepipedPrint(v[1],v[2],v[3],v[4],v[5],v[6],color)
- end
- else
- io.stderr:write("Block Not found \n") os.exit(2)
- end
- end
- hologram.clear()
- if args[1] then
- printModelToHologram(args[1],tonumber(args[2]) or 1)
- else
- print("Usage: holo <fileModel> <numberBlock>")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement