diff --git a/Applications/Robot/VRScanComputer.lua b/Applications/Robot/VRScanComputer.lua index 9a12bc87..9773d50b 100644 --- a/Applications/Robot/VRScanComputer.lua +++ b/Applications/Robot/VRScanComputer.lua @@ -1,6 +1,8 @@ local component = require("component") local GUI = require("GUI") +local color = require("color") +local computer = require("computer") local filesystem = require("filesystem") local MineOSPaths = require("MineOSPaths") @@ -11,7 +13,7 @@ local modem = component.modem local port = 512 -config = { +local config = { glassesX = 0, glassesY = 0, glassesZ = 0, @@ -101,7 +103,7 @@ end layout:addChild(GUI.button(1, 1, width, 3, 0xC3C3C3, 0xFFFFFF, 0x969696, 0xFFFFFF, "Scan")).onTouch = function() saveConfig() - + broadcast("scan", table.toString({ width = config.width, height = config.height, @@ -125,7 +127,12 @@ layout.eventHandler = function(mainContainer, layout, e1, e2, e3, e4, e5, e6, e7 for i = 1, #result.blocks[x][y][z] do local cube = glasses.addCube3D() cube.setVisibleThroughObjects(true) - cube.setColor(0, 0.6, 1) + + local maxHue = 240 + local hue = (1 - result.blocks[x][y][z][i] / config.maxDensity) * maxHue + local r, g, b = color.HSBToRGB(hue, 1, 1) + + cube.setColor(r / 255, g / 255, b / 255) cube.setAlpha(0.5) cube.set3DPos( config.robotX - config.glassesX + result.x + x, @@ -133,6 +140,8 @@ layout.eventHandler = function(mainContainer, layout, e1, e2, e3, e4, e5, e6, e7 config.robotZ - config.glassesZ + result.z + z ) end + + computer.pullSignal(0) end end end diff --git a/Applications/Robot/fisherEEPROM.lua b/Applications/Robot/fisherEEPROM.lua new file mode 100644 index 00000000..4bde7ede --- /dev/null +++ b/Applications/Robot/fisherEEPROM.lua @@ -0,0 +1,51 @@ + +local robot = component.proxy(component.list("robot")()) +local redstone = component.proxy(component.list("redstone")()) +local gpu = component.proxy(component.list("gpu")()) + +local width, height = gpu.getResolution() +local tryCatchTime = 30 +local startSleepTime = 3 +local catchSleepTime = 3 +local side = 0 +local useTime = 1 + +local function print(text) + gpu.copy(1, 1, width, height, 0, -1) + gpu.set(1, height, text) +end + +local function sleep(timeout) + local deadline = computer.uptime() + (timeout or 0) + while computer.uptime() < deadline do + computer.pullSignal(deadline - computer.uptime()) + end +end + +local function pushRod() + print("Pushing rod...") + robot.use(side, true, useTime) + sleep(startSleepTime) +end + +local function pullRod() + print("Pulling rod...") + robot.use(side, true, useTime) + sleep(catchSleepTime) +end + +pushRod() + +while true do + local e = {computer.pullSignal(tryCatchTime)} + if e[1] == "redstone_changed" then + if e[5] == 0 then + pullRod() + pushRod() + end + elseif not e[1] then + pullRod() + pushRod() + end +end + diff --git a/Applications/Stargate/Main.lua b/Applications/Stargate/Main.lua index eacb3edb..73bef9a5 100755 --- a/Applications/Stargate/Main.lua +++ b/Applications/Stargate/Main.lua @@ -130,10 +130,12 @@ local function newThing(x, y, width, height) end local function dial(address) - local success = stargate.dial(address) + local success, reason = stargate.dial(address) if success then mainContainer.fuelProgressBar.value = math.ceil(stargate.energyToDial(address) / stargate.energyAvailable() * 100) mainContainer:drawOnScreen() + else + GUI.alert("Failed to dial: " .. tostring(reason)) end end