mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
))
This commit is contained in:
parent
1a28f00c3e
commit
7c5313fbe9
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
local component = require("component")
|
local component = require("component")
|
||||||
local GUI = require("GUI")
|
local GUI = require("GUI")
|
||||||
|
local color = require("color")
|
||||||
|
local computer = require("computer")
|
||||||
local filesystem = require("filesystem")
|
local filesystem = require("filesystem")
|
||||||
local MineOSPaths = require("MineOSPaths")
|
local MineOSPaths = require("MineOSPaths")
|
||||||
|
|
||||||
@ -11,7 +13,7 @@ local modem = component.modem
|
|||||||
|
|
||||||
local port = 512
|
local port = 512
|
||||||
|
|
||||||
config = {
|
local config = {
|
||||||
glassesX = 0,
|
glassesX = 0,
|
||||||
glassesY = 0,
|
glassesY = 0,
|
||||||
glassesZ = 0,
|
glassesZ = 0,
|
||||||
@ -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
|
for i = 1, #result.blocks[x][y][z] do
|
||||||
local cube = glasses.addCube3D()
|
local cube = glasses.addCube3D()
|
||||||
cube.setVisibleThroughObjects(true)
|
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.setAlpha(0.5)
|
||||||
cube.set3DPos(
|
cube.set3DPos(
|
||||||
config.robotX - config.glassesX + result.x + x,
|
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
|
config.robotZ - config.glassesZ + result.z + z
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
computer.pullSignal(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
51
Applications/Robot/fisherEEPROM.lua
Normal file
51
Applications/Robot/fisherEEPROM.lua
Normal file
@ -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
|
||||||
|
|
||||||
@ -130,10 +130,12 @@ local function newThing(x, y, width, height)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function dial(address)
|
local function dial(address)
|
||||||
local success = stargate.dial(address)
|
local success, reason = stargate.dial(address)
|
||||||
if success then
|
if success then
|
||||||
mainContainer.fuelProgressBar.value = math.ceil(stargate.energyToDial(address) / stargate.energyAvailable() * 100)
|
mainContainer.fuelProgressBar.value = math.ceil(stargate.energyToDial(address) / stargate.energyAvailable() * 100)
|
||||||
mainContainer:drawOnScreen()
|
mainContainer:drawOnScreen()
|
||||||
|
else
|
||||||
|
GUI.alert("Failed to dial: " .. tostring(reason))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user