SHOW:
|
|
- or go back to the newest paste.
| 1 | term.setBackgroundColor(colors.black) | |
| 2 | term.setTextColor(colors.white) | |
| 3 | ||
| 4 | if not os.loadAPI("apis/lip")
| |
| 5 | or not lip then | |
| 6 | error("Cant find World Interface",0)
| |
| 7 | else | |
| 8 | wi = lip.WorldInterface | |
| 9 | end | |
| 10 | ||
| 11 | local x,y,z = gps.locate() | |
| 12 | ||
| 13 | x = math.floor(x) | |
| 14 | y = math.floor(y) | |
| 15 | z = math.floor(z) | |
| 16 | ||
| 17 | term.setCursorPos(1,1) | |
| 18 | term.clear() | |
| 19 | term.setCursorBlink(true) | |
| 20 | term.write("X=")
| |
| 21 | x = tonumber(read(nil,{tonumber(x)}))
| |
| 22 | sleep(.2) | |
| 23 | term.setCursorPos(1,2) | |
| 24 | term.write("Y=")
| |
| 25 | y = tonumber(read(nil,{tonumber(y)}))
| |
| 26 | sleep(.2) | |
| 27 | term.setCursorPos(1,3) | |
| 28 | term.write("Z=")
| |
| 29 | z = tonumber(read(nil,{tonumber(z)}))
| |
| 30 | sleep(.2) | |
| 31 | term.setCursorBlink(false) | |
| 32 | ||
| 33 | local function displayHelp() | |
| 34 | term.setBackgroundColor(colors.black) | |
| 35 | term.setTextColor(colors.white) | |
| 36 | term.setCursorPos(1,1) | |
| 37 | term.clear() | |
| 38 | print(string.format([[Controls: | |
| 39 | %s West (-x) [right] | |
| 40 | %s North (-z) [up] | |
| 41 | %s East (+x) [left] | |
| 42 | %s South (+z) [down] | |
| 43 | %s Down (-y) [pageDown] | |
| 44 | %s Up (+y) [pageUp] | |
| 45 | %s | |
| 46 | R Refresh | |
| 47 | H Help | |
| 48 | Q Quit]], | |
| 49 | string.char(27), | |
| 50 | string.char(24), | |
| 51 | string.char(26), | |
| 52 | string.char(25), | |
| 53 | string.char(31), | |
| 54 | string.char(30), | |
| 55 | string.rep(string.char(140),25))) | |
| 56 | sleep(.5) | |
| 57 | os.pullEvent("key")
| |
| 58 | sleep(.2) | |
| 59 | end | |
| 60 | ||
| 61 | local function pos() | |
| 62 | term.setCursorPos(1,1) | |
| 63 | term.clearLine() | |
| 64 | term.write(string.format([[X:%s, Y:%s, Z:%s]],tostring(x),tostring(y),tostring(z))) | |
| 65 | term.setCursorPos(1,2) | |
| 66 | end | |
| 67 | local getDatatags = false | |
| 68 | while true do | |
| 69 | term.setBackgroundColor(colors.black) | |
| 70 | term.setTextColor(colors.white) | |
| 71 | term.clear() | |
| 72 | pos() | |
| 73 | local o = getDatatags and wi.getBlockDatatags(x,y,z) or wi.getBlockInfos(x,y,z) | |
| 74 | textutils.pagedPrint(textutils.serialise(o)) | |
| 75 | if getDatatags then | |
| 76 | print(string.rep(string.char(140),25)) | |
| 77 | sleep(.5) | |
| 78 | os.pullEvent("key")
| |
| 79 | sleep(.3) | |
| 80 | term.clear() | |
| 81 | pos() | |
| 82 | getDatatags = false | |
| 83 | end | |
| 84 | while true do | |
| 85 | sleep(.1) | |
| 86 | local e,p = os.pullEvent("key")
| |
| 87 | --refresh | |
| 88 | if p==keys.r or p==keys.enter then | |
| 89 | break | |
| 90 | elseif p==keys.up then | |
| 91 | z = z-1 | |
| 92 | pos() | |
| 93 | elseif p==keys.down then | |
| 94 | z = z+1 | |
| 95 | pos() | |
| 96 | elseif p==keys.right then | |
| 97 | x = x+1 | |
| 98 | pos() | |
| 99 | elseif p==keys.left then | |
| 100 | x = x-1 | |
| 101 | pos() | |
| 102 | elseif p==keys.pageDown then | |
| 103 | y = math.max(1,y-1) | |
| 104 | pos() | |
| 105 | elseif p==keys.pageUp then | |
| 106 | y = y+1 | |
| 107 | pos() | |
| 108 | elseif p==keys.numPadAdd then | |
| 109 | getDatatags = true | |
| 110 | break | |
| 111 | elseif p==keys.h then | |
| 112 | displayHelp() | |
| 113 | break | |
| 114 | elseif p==keys.q then | |
| 115 | sleep(.3) | |
| 116 | error("Terminated",0)
| |
| 117 | return | |
| 118 | end | |
| 119 | end | |
| 120 | end |