local M = {} function M.write3d(maze, width, height, depth, filename) local scale = 5 local inverted = true local out = io.open(filename, "w") out:write("// Generated by multimaze (lua)\n") out:write("// Hit the Render button (F6) to make the preview look better") out:write("// Uncomment to make the preview look transclucent") out:write("// color(\"red\", 0.25)\n"); if inverted then out:write("difference() {\n\tcube(size=["..scale*width..", "..scale*height..", "..scale*depth.."])") else out:write("union() {") end out:write("\n") for z = 0, depth - 1, 1 do for y = 0, height - 1, 1 do for x = 0, width - 1, 1 do if maze[z][y][x] == "#" then out:write("\ttranslate(["..x*scale..", "..y*scale..", "..z*scale.."]) cube(size = "..scale..");\n") end end end end out:write("}\n") out:close() end return M