Created
July 17, 2018 20:56
-
-
Save MEXAHOTABOP/598861656773523c04d03e2b0fd5bddc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local event = require("event") | |
| local comp = require("component") | |
| local serialization = require("serialization") | |
| local glasses = comp.glasses | |
| local lastX,lastZ,lastY | |
| local ore_widgets = {} | |
| glasses.removeAll() | |
| function msg_process(_,_,_,_,_, ...) | |
| local type, payload = ... | |
| if type == "ore_scan" then | |
| for i=1, #ore_widgets do | |
| ore_widgets[i].removeWidget() | |
| end | |
| ore_widgets = {} | |
| local ore_array = serialization.unserialize(payload) | |
| for x,arrz in pairs(ore_array) do | |
| for z,arry in pairs(arrz) do | |
| for y,_ in pairs(arry) do | |
| local new_widget = glasses.addCube3D() | |
| new_widget.addColor(0, 0, 1, 0.11) | |
| new_widget.addTranslation(lastX+x, lastY+y+1, lastZ+z) | |
| new_widget.setVisibleThroughObjects(true) | |
| new_widget.setVisible(true) | |
| new_widget.setViewDistance(24) | |
| table.insert(ore_widgets,new_widget) | |
| end | |
| end | |
| end | |
| end | |
| end | |
| function rmb_process(_, _, _, x, y, z, _, _, _, _) | |
| lastX,lastZ,lastY = math.floor(x), math.floor(z), math.floor(y) | |
| end | |
| function lmb_process(_, _, _, x, y, z, _, _, _, _) | |
| lastX,lastZ,lastY = math.floor(x), math.floor(z), math.floor(y) | |
| end | |
| event.listen("modem_message", msg_process) | |
| event.listen("interact_world_right", rmb_process) | |
| event.listen("interact_world_left", rmb_process) | |
| while true do event.pull() end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment