SHOW:
|
|
- or go back to the newest paste.
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 | local scale | |
15 | ||
16 | local function validate(value, min, max, default) | |
17 | value = tonumber(value) or default | |
18 | if value < min or value > max then | |
19 | io.stderr:write("invalid y coordinate, must be in [" .. min .. ", " .. max .. "]\n") | |
20 | os.exit(1) | |
21 | end | |
22 | return value | |
23 | end | |
24 | ||
25 | do | |
26 | local args = {...} | |
27 | starty = validate(args[1], -32, 31, starty) | |
28 | stopy = validate(args[2], starty, starty + 32, math.min(starty + 32, 31)) | |
29 | scale = validate(args[3], 0.33, 3, 1) | |
30 | end | |
31 | ||
32 | component.hologram.clear() | |
33 | component.hologram.setScale(1) | |
34 | for x=ox,sx+ox do | |
35 | for z=oz,sz+oz do | |
36 | local hx, hz = 1 + x - ox, 1 + z - oz | |
37 | local column = component.geolyzer.scan(x, z, false) | |
38 | for y=1,1+stopy-starty do | |
39 | local color = 0 | |
40 | if column then | |
41 | local hardness = column[y + starty + 32] | |
42 | if hardness == 0 or not hardness then | |
43 | color = 0 | |
44 | elseif hardness < 3.4 && hardness > 2.6 then | |
45 | color = 2 | |
46 | else | |
47 | color = 0 | |
48 | end | |
49 | end | |
50 | if component.hologram.maxDepth() > 1 then | |
51 | component.hologram.set(hx, y, hz, color) | |
52 | else | |
53 | component.hologram.set(hx, y, hz, math.min(color, 1)) | |
54 | end | |
55 | end | |
56 | os.sleep(0) | |
57 | end | |
58 | end |