Guest User

Untitled

a guest
Jun 26th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. local component = require("component")
  2. if not component.isAvailable("geolyzer") then
  3. io.stderr:write("This program requires a Geolyzer to run.\n")
  4. return
  5. end
  6. if not component.isAvailable("hologram") then
  7. io.stderr:write("This program requires a Hologram Projector to run.\n")
  8. return
  9. end
  10.  
  11. local sx, sz = 48, 48
  12. local ox, oz = -24, -24
  13. local starty, stopy = -5
  14.  
  15. local function validateY(value, min, max, default)
  16. value = tonumber(value) or default
  17. if value < min or value > max then
  18. io.stderr:write("invalid y coordinate, must be in [" .. min .. ", " .. max .. "]\n")
  19. os.exit(1)
  20. end
  21. return value
  22. end
  23.  
  24. do
  25. local args = {...}
  26. starty = validateY(args[1], -32, 31, starty)
  27. stopy = validateY(args[2], starty, starty + 32, math.min(starty + 32, 31))
  28. end
  29.  
  30. component.hologram.clear()
  31. for x=ox,sx+ox do
  32. for z=oz,sz+oz do
  33. local hx, hz = 1 + x - ox, 1 + z - oz
  34. local column = component.geolyzer.scan(x, z, false)
  35. for y=1,1+stopy-starty do
  36. local color = 0
  37. if column then
  38. local hardness = column[y + starty + 32]
  39. if hardness == 0 or not hardness then
  40. color = 0
  41. elseif hardness < 3 then
  42. color = 2
  43. elseif hardness < 100 then
  44. color = 1
  45. else
  46. color = 3
  47. end
  48. end
  49. if component.hologram.maxDepth() > 1 then
  50. component.hologram.set(hx, y, hz, color)
  51. else
  52. component.hologram.set(hx, y, hz, math.min(color, 1))
  53. end
  54. end
  55. os.sleep(0)
  56. end
  57. end
Add Comment
Please, Sign In to add comment