Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local shell = require("shell")
- local model = require("model")
- local args = shell.parse(...)
- if #args ~= 1 then
- io.write("Usage: print3d-holo FILE\n")
- os.exit(0)
- end
- local data, reason = model.Model.load(args[1])
- if not data then
- io.stderr:write("Failed loading model: " .. reason .. "\n")
- os.exit(1)
- end
- if data.label then
- print("Label: " .. data.label)
- end
- if data.tooltip then
- print("Tooltip: " .. data.tooltip)
- end
- if data.lightLevel then -- as of OC 1.5.7
- print("Light Level: " .. data.lightLevel)
- end
- if data.emitRedstone then
- print("Redstone: " .. tostring(data.emitRedstone))
- end
- if data.buttonMode then
- print("Button mode: " .. tostring(data.buttonMode))
- end
- if data.collidable then
- print("Collidable (inactive): " .. tostring(not not data.collidable[1]))
- print("Collidable (active): " .. tostring(not not data.collidable[2]))
- end
- -- Preload texture mapping
- local txtdb = model.Textures.load()
- -- Compute a pallette
- local palette = {}
- local cpi = 1
- for voxel in data:voxels_rgb(txtdb) do
- if not palette[voxel.rgb] then
- palette[voxel.rgb] = cpi
- component.hologram.setPaletteColor(cpi, voxel.rgb)
- cpi = cpi + 1
- end
- end
- if #palette > 3 then
- io.stderr:write("Warning: More than 3 colors.\n")
- end
- component.hologram.clear()
- -- 3D Printer is low inclusive, high exclusive, 0-16 (fenced)
- -- Hologram is both inclusive, 1-16 (indexed)
- for voxel in data:voxels_rgb(txtdb) do
- if not voxel.state then
- local c = palette[voxel.rgb]
- component.hologram.set(voxel[1]+16, voxel[2]+8, voxel[3]+16, c)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement