mirror of
https://github.com/S4mpsa/InfOS.git
synced 2025-09-17 11:15:07 -04:00
Formatting files
This commit is contained in:
parent
5d693800ca
commit
a3dd881119
@ -1,4 +1,7 @@
|
||||
comp = require("component"); screen = require("term"); computer = require("computer"); event = require("event")
|
||||
comp = require("component")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
event = require("event")
|
||||
|
||||
local AR = {}
|
||||
|
||||
@ -16,27 +19,36 @@ function AR.hexToRGB(hexcode)
|
||||
return r, g, b
|
||||
end
|
||||
function AR.cube(glasses, x, y, z, color, alpha, scale)
|
||||
scale = scale or 1; alpha = alpha or 1
|
||||
scale = scale or 1
|
||||
alpha = alpha or 1
|
||||
local cube = glasses.addCube3D()
|
||||
cube.set3DPos(x - terminal.x, y - terminal.y, z - terminal.z)
|
||||
cube.setColor(hexToRGB(color)); cube.setAlpha(alpha); cube.setScale(scale)
|
||||
cube.setColor(hexToRGB(color))
|
||||
cube.setAlpha(alpha)
|
||||
cube.setScale(scale)
|
||||
return cube
|
||||
end
|
||||
|
||||
function AR.line(glasses, source, dest, color, alpha, scale)
|
||||
scale = scale or 1; alpha = alpha or 1
|
||||
scale = scale or 1
|
||||
alpha = alpha or 1
|
||||
local line = glasses.addLine3D()
|
||||
line.setVertex(1, source.x - terminal.x + 0.5, source.y - terminal.y + 0.5, source.z - terminal.z + 0.5)
|
||||
line.setVertex(2, dest.x - terminal.x + 0.5, dest.y - terminal.y + 0.5, dest.z - terminal.z + 0.5)
|
||||
line.setColor(hexToRGB(color)); line.setAlpha(alpha); line.setScale(scale)
|
||||
line.setColor(hexToRGB(color))
|
||||
line.setAlpha(alpha)
|
||||
line.setScale(scale)
|
||||
return line
|
||||
end
|
||||
|
||||
function AR.worldText(glasses, name, x, y, z, color, alpha, scale)
|
||||
scale = scale or 0.04; alpha = alpha or 1
|
||||
scale = scale or 0.04
|
||||
alpha = alpha or 1
|
||||
local text = glasses.addFloatingText()
|
||||
text.set3DPos(x - terminal.x, y - terminal.y, z - terminal.z)
|
||||
text.setColor(hexToRGB(color)); text.setAlpha(alpha); text.setScale(scale)
|
||||
text.setColor(hexToRGB(color))
|
||||
text.setAlpha(alpha)
|
||||
text.setScale(scale)
|
||||
text.setText(name)
|
||||
return text
|
||||
end
|
||||
@ -44,24 +56,33 @@ end
|
||||
function AR.hudTriangle(glasses, a, b, c, color, alpha)
|
||||
alpha = alpha or 1.0
|
||||
local triangle = glasses.addTriangle()
|
||||
triangle.setColor(hexToRGB(color)); triangle.setAlpha(alpha);
|
||||
triangle.setVertex(1, a[1], a[2]); triangle.setVertex(2, b[1], b[2]); triangle.setVertex(3, c[1], c[2])
|
||||
triangle.setColor(hexToRGB(color))
|
||||
triangle.setAlpha(alpha)
|
||||
triangle.setVertex(1, a[1], a[2])
|
||||
triangle.setVertex(2, b[1], b[2])
|
||||
triangle.setVertex(3, c[1], c[2])
|
||||
return triangle
|
||||
end
|
||||
|
||||
function AR.hudQuad(glasses, a, b, c, d, color, alpha)
|
||||
alpha = alpha or 1.0
|
||||
local quad = glasses.addQuad()
|
||||
quad.setColor(hexToRGB(color)); quad.setAlpha(alpha)
|
||||
quad.setVertex(1, a[1], a[2]); quad.setVertex(2, b[1], b[2]); quad.setVertex(3, c[1], c[2]); quad.setVertex(4, d[1], d[2])
|
||||
quad.setColor(hexToRGB(color))
|
||||
quad.setAlpha(alpha)
|
||||
quad.setVertex(1, a[1], a[2])
|
||||
quad.setVertex(2, b[1], b[2])
|
||||
quad.setVertex(3, c[1], c[2])
|
||||
quad.setVertex(4, d[1], d[2])
|
||||
return quad
|
||||
end
|
||||
|
||||
function AR.hudRectangle(glasses, x, y, w, h, color, alpha)
|
||||
alpha = alpha or 1.0
|
||||
local rect = glasses.addRect()
|
||||
rect.setPosition(x, y); rect.setSize(h, w)
|
||||
rect.setColor(hexToRGB(color)); rect.setAlpha(alpha)
|
||||
rect.setPosition(x, y)
|
||||
rect.setSize(h, w)
|
||||
rect.setColor(hexToRGB(color))
|
||||
rect.setAlpha(alpha)
|
||||
return rect
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
comp=require("component");screen=require("term");computer=require("computer");event=require("event"); thread = require("thread")
|
||||
get=require("easy"); ARG=require("ARGraphics")
|
||||
comp = require("component")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
event = require("event")
|
||||
thread = require("thread")
|
||||
get = require("easy")
|
||||
ARG = require("ARGraphics")
|
||||
config = require("config")
|
||||
local ARWidgets = {}
|
||||
|
||||
@ -8,7 +13,9 @@ local euUpdateInterval = 120
|
||||
local readings = {}
|
||||
local function updateEU(LSC)
|
||||
batteryBuffer = batteryBuffer or false
|
||||
if counter == 1 then firstRead = computer.uptime() end
|
||||
if counter == 1 then
|
||||
firstRead = computer.uptime()
|
||||
end
|
||||
if counter < euUpdateInterval then
|
||||
readings[counter] = string.gsub(LSC.getSensorInformation()[2], "([^0-9]+)", "") + 0
|
||||
counter = counter + 1
|
||||
@ -32,13 +39,35 @@ function ARWidgets.powerDisplay(glasses, data, x, y, w, h)
|
||||
ARG.hudRectangle(glasses, x, y, w, h, hudColour)
|
||||
ARG.hudRectangle(glasses, x, y + h, w, 12, hudColour, 0.6)
|
||||
ARG.hudTriangle(glasses, {x + 2, y + 3}, {x + 2, y + 3 + h - 6}, {x + 2 + h - 6, y + 3 + h - 6}, hudColour)
|
||||
ARG.hudTriangle(glasses, {x+2+w-4, y+3}, {x+2+w-4-(h-6), y+3}, {x+2+w-4, y+3+h-6}, hudColour)
|
||||
ARG.hudTriangle(
|
||||
glasses,
|
||||
{x + 2 + w - 4, y + 3},
|
||||
{x + 2 + w - 4 - (h - 6), y + 3},
|
||||
{x + 2 + w - 4, y + 3 + h - 6},
|
||||
hudColour
|
||||
)
|
||||
ARG.hudRectangle(glasses, x, y + h, 25, 12, hudColour)
|
||||
ARG.hudTriangle(glasses, {x + 25, y + h}, {x + 25, y + h + 12}, {x + 37, y + h + 12}, hudColour)
|
||||
ARG.hudRectangle(glasses, x + w - 25, y + h, 25, 12, hudColour)
|
||||
ARG.hudTriangle(glasses, {x + w - 37, y + h}, {x + w - 25, y + h + 12}, {x + w - 25, y + h}, hudColour)
|
||||
powerFill = ARG.hudQuad(glasses, {x+2, y+3}, {x+2+h-6, y+3+h-6}, {math.min(x+2+w-5, (w-4)*percentage), y+3+(h-6)}, {math.min(x+2+w-5-(h-6), (w-4)*percentage-(h-6)), y+3}, workingColour)
|
||||
powerEmpty = ARG.hudQuad(glasses, {math.min(x+2+w-5-(h-6), (w-4)*percentage-(h-6)), y+3}, {math.min(x+2+w-5, (w-4)*percentage), y+3+(h-6)}, {x+2+w-5, y+3+h-6}, {x+2+w-5-(h-6), y+3}, machineBackground)
|
||||
powerFill =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x + 2, y + 3},
|
||||
{x + 2 + h - 6, y + 3 + h - 6},
|
||||
{math.min(x + 2 + w - 5, (w - 4) * percentage), y + 3 + (h - 6)},
|
||||
{math.min(x + 2 + w - 5 - (h - 6), (w - 4) * percentage - (h - 6)), y + 3},
|
||||
workingColour
|
||||
)
|
||||
powerEmpty =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{math.min(x + 2 + w - 5 - (h - 6), (w - 4) * percentage - (h - 6)), y + 3},
|
||||
{math.min(x + 2 + w - 5, (w - 4) * percentage), y + 3 + (h - 6)},
|
||||
{x + 2 + w - 5, y + 3 + h - 6},
|
||||
{x + 2 + w - 5 - (h - 6), y + 3},
|
||||
machineBackground
|
||||
)
|
||||
|
||||
maxEnergyObj = ARG.hudText(glasses, "", x + w - 88, y - 8, idleColour)
|
||||
currentEnergyObj = ARG.hudText(glasses, "", x + 2, y - 8, workingColour)
|
||||
@ -85,17 +114,17 @@ function ARWidgets.powerDisplay(glasses, data, x, y, w, h)
|
||||
end
|
||||
function ARWidgets.minimapOverlay(glasses)
|
||||
--Minimap Borders
|
||||
ARG.hudRectangle(glasses, 728, 10, 123, 3, hudColour);
|
||||
ARG.hudRectangle(glasses, 728, 130, 123, 3,hudColour);
|
||||
ARG.hudRectangle(glasses, 728, 10, 3, 123,hudColour);
|
||||
ARG.hudRectangle(glasses, 848, 10, 3, 123, hudColour);
|
||||
ARG.hudRectangle(glasses, 728, 10, 123, 3, hudColour)
|
||||
ARG.hudRectangle(glasses, 728, 130, 123, 3, hudColour)
|
||||
ARG.hudRectangle(glasses, 728, 10, 3, 123, hudColour)
|
||||
ARG.hudRectangle(glasses, 848, 10, 3, 123, hudColour)
|
||||
--Coordinate Borders
|
||||
ARG.hudTriangle(glasses, {743, 133}, {728, 133}, {743, 143}, hudColour)
|
||||
ARG.hudRectangle(glasses, 743, 133, 8, 10, hudColour);
|
||||
ARG.hudRectangle(glasses, 751, 140, 170, 3, hudColour);
|
||||
ARG.hudRectangle(glasses, 743, 133, 8, 10, hudColour)
|
||||
ARG.hudRectangle(glasses, 751, 140, 170, 3, hudColour)
|
||||
--Biome Borders
|
||||
ARG.hudTriangle(glasses, {768, 143}, {753, 143}, {768, 153}, hudColour)
|
||||
ARG.hudRectangle(glasses, 768, 150, 170, 3, hudColour);
|
||||
ARG.hudRectangle(glasses, 768, 150, 170, 3, hudColour)
|
||||
ARG.hudRectangle(glasses, 829, 133, 50, 7, 0, 0.8)
|
||||
ARG.hudRectangle(glasses, 811, 143, 50, 7, 0, 0.8)
|
||||
--FPS Borders
|
||||
@ -114,7 +143,8 @@ function ARWidgets.hudOverlayBase(glasses, x, y)
|
||||
local rightBorder = ARG.hudRectangle(glasses, x + 182, y - 5, 3, 30, hudColour)
|
||||
local armorBox = ARG.hudRectangle(glasses, x, y - 27, 90, 15, hudColour, 0.0)
|
||||
local hpBox = ARG.hudRectangle(glasses, x + 1, y - 15, 94, 10, hudColour, 0.7)
|
||||
local hpStopper = ARG.hudQuad(glasses, {x+88, y-16}, {x+77, y-5},{x+108, y-5}, {x+97, y-16}, hudColour)
|
||||
local hpStopper =
|
||||
ARG.hudQuad(glasses, {x + 88, y - 16}, {x + 77, y - 5}, {x + 108, y - 5}, {x + 97, y - 16}, hudColour)
|
||||
local topBorder = ARG.hudRectangle(glasses, x + 4, y - 18, 178, 3, hudColour)
|
||||
local topWedge = ARG.hudTriangle(glasses, {x + 4, y - 18}, {x - 1, y - 13}, {x + 4, y - 13}, hudColour)
|
||||
local connector = ARG.hudTriangle(glasses, {x + 182, y - 18}, {x + 182, y}, {x + 200, y}, hudColour)
|
||||
@ -129,7 +159,8 @@ function ARWidgets.hudOverlayBase(glasses, x, y)
|
||||
local itemBorder3 = ARG.hudRectangle(glasses, x + 88 + 185, y + 3, 1, 21, workingColour, 0.8)
|
||||
local itemBorder4 = ARG.hudRectangle(glasses, x + 28 + 185, y + 23, 61, 1, workingColour, 0.8)
|
||||
local cpuBase1 = ARG.hudRectangle(glasses, x + 89 + 185, y, 5, 24, hudColour)
|
||||
local connectorStrip = ARG.hudQuad(glasses, {x+182, y-17}, {x+182, y-16},{x+213, y+15}, {x+213, y+14}, workingColour)
|
||||
local connectorStrip =
|
||||
ARG.hudQuad(glasses, {x + 182, y - 17}, {x + 182, y - 16}, {x + 213, y + 15}, {x + 213, y + 14}, workingColour)
|
||||
end
|
||||
function popupText(glasses, text, x, y, color)
|
||||
local substringLength = 1
|
||||
@ -137,11 +168,28 @@ function popupText(glasses, text, x, y, color)
|
||||
local steps = math.ceil(#text / substringLength)
|
||||
local stepLength = substringLength * 5
|
||||
local i = 1
|
||||
local background = ARG.hudQuad(glasses, {x-5, y}, {x-5, y+9}, {x-5+1, y+9}, {x-5+1, y}, machineBackground, 0.5)
|
||||
local background =
|
||||
ARG.hudQuad(glasses, {x - 5, y}, {x - 5, y + 9}, {x - 5 + 1, y + 9}, {x - 5 + 1, y}, machineBackground, 0.5)
|
||||
local top = ARG.hudQuad(glasses, {x - 5, y - 1}, {x - 5, y}, {x - 5 + 1, y}, {x - 5 + 1, y - 1}, machineBackground)
|
||||
local bottom = ARG.hudQuad(glasses, {x-5, y+9}, {x-5, y+10}, {x-5+1, y+10}, {x-5+1, y+9}, machineBackground)
|
||||
local bottom =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 5, y + 9},
|
||||
{x - 5, y + 10},
|
||||
{x - 5 + 1, y + 10},
|
||||
{x - 5 + 1, y + 9},
|
||||
machineBackground
|
||||
)
|
||||
local hudText = ARG.hudText(glasses, "", x + 1, y + 1, color)
|
||||
local wedge = ARG.hudQuad(glasses, {x-5-10, y-1}, {x-5, y-1}, {x-5, y+10}, {x-5+11, y+10}, machineBackground)
|
||||
local wedge =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 5 - 10, y - 1},
|
||||
{x - 5, y - 1},
|
||||
{x - 5, y + 10},
|
||||
{x - 5 + 11, y + 10},
|
||||
machineBackground
|
||||
)
|
||||
local direction = 1
|
||||
local function advance()
|
||||
background.setVertex(3, math.min(width + 10, x + stepLength * i + 10), y + 9)
|
||||
@ -181,25 +229,107 @@ function ARWidgets.fluidMonitor(glasses, x, y, fluidMap)
|
||||
local fluids = comp.me_interface.getFluidsInNetwork()
|
||||
if initFluidMap then
|
||||
for i = 0, #fluidMap, 1 do
|
||||
local background = ARG.hudQuad(glasses, {x-8, y + i * h},{x-8, y+8 + i * h},{x+w, y+8 + i * h},{x+w, y + i * h}, hudColour, 0.5)
|
||||
local top = ARG.hudQuad(glasses, {x-10, y-1 + i * h},{x-10, y + i * h},{x+w, y + i * h},{x+w, y-1 + i * h}, hudColour)
|
||||
local bottom = ARG.hudQuad(glasses, {x-7, y+8 + i * h},{x-8, y+9 + i * h},{x+w, y+9 + i * h},{x+w, y+8 + i * h}, hudColour)
|
||||
local fill = ARG.hudQuad(glasses, {x+w, y + i * h},{x+w, y+8 + i * h},{x+w, y+8 + i * h},{x+w, y + i * h}, fluidMap[i].color, 0.7)
|
||||
local background =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 8, y + i * h},
|
||||
{x - 8, y + 8 + i * h},
|
||||
{x + w, y + 8 + i * h},
|
||||
{x + w, y + i * h},
|
||||
hudColour,
|
||||
0.5
|
||||
)
|
||||
local top =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 10, y - 1 + i * h},
|
||||
{x - 10, y + i * h},
|
||||
{x + w, y + i * h},
|
||||
{x + w, y - 1 + i * h},
|
||||
hudColour
|
||||
)
|
||||
local bottom =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 7, y + 8 + i * h},
|
||||
{x - 8, y + 9 + i * h},
|
||||
{x + w, y + 9 + i * h},
|
||||
{x + w, y + 8 + i * h},
|
||||
hudColour
|
||||
)
|
||||
local fill =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x + w, y + i * h},
|
||||
{x + w, y + 8 + i * h},
|
||||
{x + w, y + 8 + i * h},
|
||||
{x + w, y + i * h},
|
||||
fluidMap[i].color,
|
||||
0.7
|
||||
)
|
||||
local text = ARG.hudText(glasses, fluidMap[i].displayName, x, y + i * h, 0x777777, 0.75)
|
||||
text.setPosition(x * 1.33333 + 4, (y + i * h) * 1.33333 + 2)
|
||||
fillLevels[fluidMap[i].label] = fill
|
||||
if i % 2 == 0 then
|
||||
local wedge = ARG.hudQuad(glasses, {x-10, y + i * h},{x-10, y+9 + i * h},{x-6, y+9 + i * h},{x+3, y + i * h}, hudColour)
|
||||
local wedge =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 10, y + i * h},
|
||||
{x - 10, y + 9 + i * h},
|
||||
{x - 6, y + 9 + i * h},
|
||||
{x + 3, y + i * h},
|
||||
hudColour
|
||||
)
|
||||
else
|
||||
local wedge = ARG.hudQuad(glasses, {x-10, y + i * h},{x-10, y+9 + i * h},{x+3, y+9 + i * h},{x-6, y + i * h}, hudColour)
|
||||
local wedge =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 10, y + i * h},
|
||||
{x - 10, y + 9 + i * h},
|
||||
{x + 3, y + 9 + i * h},
|
||||
{x - 6, y + i * h},
|
||||
hudColour
|
||||
)
|
||||
end
|
||||
entries = i
|
||||
end
|
||||
entries = entries + 1
|
||||
local finish = ARG.hudQuad(glasses,{x-10, y + entries * h},{x-2, y+8 + entries * h},{x+w, y+8 + entries * h},{x+w, y + entries * h}, hudColour)
|
||||
local verticalStrip = ARG.hudQuad(glasses,{x-8, y},{x-8, y - 2 + entries * h},{x-7, y - 2 + entries * h},{x-7, y}, workingColour)
|
||||
local diagonalStrip = ARG.hudQuad(glasses,{x-8, y-2 + entries * h},{x, y+6 + entries * h},{x, y + 5 + entries * h},{x-7, y - 2 + entries * h}, workingColour)
|
||||
local horizontalStrip = ARG.hudQuad(glasses,{x, y + 5 + entries * h},{x, y+6 + entries * h},{x+w, y+6 + entries * h},{x+w, y + 5 + entries * h}, workingColour)
|
||||
local finish =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 10, y + entries * h},
|
||||
{x - 2, y + 8 + entries * h},
|
||||
{x + w, y + 8 + entries * h},
|
||||
{x + w, y + entries * h},
|
||||
hudColour
|
||||
)
|
||||
local verticalStrip =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 8, y},
|
||||
{x - 8, y - 2 + entries * h},
|
||||
{x - 7, y - 2 + entries * h},
|
||||
{x - 7, y},
|
||||
workingColour
|
||||
)
|
||||
local diagonalStrip =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x - 8, y - 2 + entries * h},
|
||||
{x, y + 6 + entries * h},
|
||||
{x, y + 5 + entries * h},
|
||||
{x - 7, y - 2 + entries * h},
|
||||
workingColour
|
||||
)
|
||||
local horizontalStrip =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x, y + 5 + entries * h},
|
||||
{x, y + 6 + entries * h},
|
||||
{x + w, y + 6 + entries * h},
|
||||
{x + w, y + 5 + entries * h},
|
||||
workingColour
|
||||
)
|
||||
initFluidMap = false
|
||||
elseif computer.uptime() - lastRefresh > 30 then
|
||||
for i = 0, #fluidMap, 1 do
|
||||
@ -220,8 +350,12 @@ end
|
||||
local function refreshDatabase(itemList)
|
||||
local filteredList = {}
|
||||
for i = 1, #itemList, 1 do
|
||||
if i % 200 == 0 then os.sleep() end
|
||||
if itemList[i].size >= 100 then filteredList[itemList[i].label] = itemList[i].size end
|
||||
if i % 200 == 0 then
|
||||
os.sleep()
|
||||
end
|
||||
if itemList[i].size >= 100 then
|
||||
filteredList[itemList[i].label] = itemList[i].size
|
||||
end
|
||||
itemList[i] = nil
|
||||
end
|
||||
return filteredList
|
||||
@ -231,9 +365,16 @@ local function rollingText(glasses, text, start, stop, y, color)
|
||||
local textObject = ARG.hudText(glasses, "", start, y, color)
|
||||
textObject.setAlpha(0.8)
|
||||
local backgroundEndWedge = ARG.hudTriangle(glasses, {stop, y - 2}, {stop, y + 10}, {stop + 12, y + 10}, hudColour)
|
||||
local backgroundStartWedge = ARG.hudTriangle(glasses, {start-12, y-2},{start, y+10},{start+12, y-2}, hudColour)
|
||||
local startWedge = ARG.hudQuad(glasses, {start, y-2},{start, y+8},{start+30, y+8}, {start+30, y-2}, hudColour)
|
||||
rollingTextObjects[#rollingTextObjects+1] = {t = textObject, bew = backgroundEndWedge, bsw = backgroundStartWedge, sw = startWedge}
|
||||
local backgroundStartWedge =
|
||||
ARG.hudTriangle(glasses, {start - 12, y - 2}, {start, y + 10}, {start + 12, y - 2}, hudColour)
|
||||
local startWedge =
|
||||
ARG.hudQuad(glasses, {start, y - 2}, {start, y + 8}, {start + 30, y + 8}, {start + 30, y - 2}, hudColour)
|
||||
rollingTextObjects[#rollingTextObjects + 1] = {
|
||||
t = textObject,
|
||||
bew = backgroundEndWedge,
|
||||
bsw = backgroundStartWedge,
|
||||
sw = startWedge
|
||||
}
|
||||
local stepSize = 1
|
||||
local steps = start - stop / stepSize
|
||||
local step = 0
|
||||
@ -266,10 +407,18 @@ local function rollingText(glasses, text, start, stop, y, color)
|
||||
end
|
||||
local function clearTicker(glasses)
|
||||
for i = 1, #rollingTextObjects do
|
||||
if rollingTextObjects[i].t ~= nil then glasses.removeObject(rollingTextObjects[i].t.getID()) end
|
||||
if rollingTextObjects[i].bew ~= nil then glasses.removeObject(rollingTextObjects[i].bew.getID()) end
|
||||
if rollingTextObjects[i].bsw ~= nil then glasses.removeObject(rollingTextObjects[i].bsw.getID()) end
|
||||
if rollingTextObjects[i].sw ~= nil then glasses.removeObject(rollingTextObjects[i].sw.getID()) end
|
||||
if rollingTextObjects[i].t ~= nil then
|
||||
glasses.removeObject(rollingTextObjects[i].t.getID())
|
||||
end
|
||||
if rollingTextObjects[i].bew ~= nil then
|
||||
glasses.removeObject(rollingTextObjects[i].bew.getID())
|
||||
end
|
||||
if rollingTextObjects[i].bsw ~= nil then
|
||||
glasses.removeObject(rollingTextObjects[i].bsw.getID())
|
||||
end
|
||||
if rollingTextObjects[i].sw ~= nil then
|
||||
glasses.removeObject(rollingTextObjects[i].sw.getID())
|
||||
end
|
||||
end
|
||||
rollingTextObjects = {}
|
||||
end
|
||||
@ -301,23 +450,30 @@ function ARWidgets.itemTicker(glasses, x, y, w)
|
||||
local function getTotalItemCount(items)
|
||||
local sum = 0
|
||||
for i = 1, #items, 1 do
|
||||
if i % 200 == 0 then os.sleep() end
|
||||
if i % 200 == 0 then
|
||||
os.sleep()
|
||||
end
|
||||
sum = sum + items[i].size
|
||||
end
|
||||
return sum
|
||||
end
|
||||
if initializeTicker then
|
||||
local background = ARG.hudQuad(glasses, {x, y+2},{x, y+14},{x+w, y+14},{x+w, y+2}, machineBackground, 0.5)
|
||||
local background =
|
||||
ARG.hudQuad(glasses, {x, y + 2}, {x, y + 14}, {x + w, y + 14}, {x + w, y + 2}, machineBackground, 0.5)
|
||||
local top = ARG.hudQuad(glasses, {x, y}, {x, y + 2}, {x + w, y + 2}, {x + w, y}, hudColour)
|
||||
local bottom = ARG.hudQuad(glasses, {x, y + 14}, {x, y + 20}, {x + w, y + 20}, {x + w, y + 14}, hudColour)
|
||||
local bottomStripe = ARG.hudQuad(glasses, {x, y+17},{x, y+18},{x+w, y+18},{x+w, y+17}, workingColour)
|
||||
local bottomStripe =
|
||||
ARG.hudQuad(glasses, {x, y + 17}, {x, y + 18}, {x + w, y + 18}, {x + w, y + 17}, workingColour)
|
||||
local wedge = ARG.hudTriangle(glasses, {x - 20, y}, {x, y + 20}, {x, y}, hudColour)
|
||||
local backgroundEndWedge = ARG.hudTriangle(glasses, {x, y + 2}, {x, y + 14}, {x + 12, y + 14}, hudColour)
|
||||
local backgroundStartWedge = ARG.hudTriangle(glasses, {x+w-12, y+2},{x+w, y+14},{x+w+12, y+2}, hudColour)
|
||||
local diagonalStripe = ARG.hudQuad(glasses, {x-16, y+2},{x, y+18},{x, y+17},{x-15, y+2}, workingColour)
|
||||
local backgroundStartWedge =
|
||||
ARG.hudTriangle(glasses, {x + w - 12, y + 2}, {x + w, y + 14}, {x + w + 12, y + 2}, hudColour)
|
||||
local diagonalStripe =
|
||||
ARG.hudQuad(glasses, {x - 16, y + 2}, {x, y + 18}, {x, y + 17}, {x - 15, y + 2}, workingColour)
|
||||
local bottomBorder = ARG.hudRectangle(glasses, x + w - 170, y + 28, 170, 4, hudColour)
|
||||
local dataBorder = ARG.hudRectangle(glasses, x + w - 170, 20, 170, 12, hudColour, 0.5)
|
||||
local endWedge = ARG.hudTriangle(glasses,{x+w-182, y+20},{x+w-170, y+32},{x+w-170, y+20}, hudColour)
|
||||
local endWedge =
|
||||
ARG.hudTriangle(glasses, {x + w - 182, y + 20}, {x + w - 170, y + 32}, {x + w - 170, y + 20}, hudColour)
|
||||
local divisor1 = ARG.hudRectangle(glasses, x + w - 118, y + 20, 2, 12, hudColour)
|
||||
local divisor2 = ARG.hudRectangle(glasses, x + w - 64, y + 20, 2, 12, hudColour)
|
||||
local bottomDataStripe = ARG.hudRectangle(glasses, x + w - 168, y + 30, 168, 1, workingColour)
|
||||
@ -376,9 +532,27 @@ function ARWidgets.cpuMonitor(glasses, x, y)
|
||||
local cpuSplitter = ARG.hudRectangle(glasses, x + 89, y + 9, 400, 3, hudColour)
|
||||
local cpuSplitter2 = ARG.hudRectangle(glasses, x + 102, y + 18, 380, 6, hudColour)
|
||||
local function createCpuIndicator(cpuX, cpuY)
|
||||
local status = ARG.hudQuad(glasses, {cpuX, cpuY}, {cpuX+6, cpuY+6}, {cpuX+16, cpuY+6}, {cpuX+10, cpuY}, hudColour, 1.0)
|
||||
local leftTriangle = ARG.hudTriangle(glasses, {cpuX, cpuY}, {cpuX, cpuY+6}, {cpuX+6, cpuY+6}, hudColour)
|
||||
local rightTriangle = ARG.hudQuad(glasses, {cpuX+10, cpuY}, {cpuX+16, cpuY+6}, {cpuX+18, cpuY+6}, {cpuX+18, cpuY}, hudColour)
|
||||
local status =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{cpuX, cpuY},
|
||||
{cpuX + 6, cpuY + 6},
|
||||
{cpuX + 16, cpuY + 6},
|
||||
{cpuX + 10, cpuY},
|
||||
hudColour,
|
||||
1.0
|
||||
)
|
||||
local leftTriangle =
|
||||
ARG.hudTriangle(glasses, {cpuX, cpuY}, {cpuX, cpuY + 6}, {cpuX + 6, cpuY + 6}, hudColour)
|
||||
local rightTriangle =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{cpuX + 10, cpuY},
|
||||
{cpuX + 16, cpuY + 6},
|
||||
{cpuX + 18, cpuY + 6},
|
||||
{cpuX + 18, cpuY},
|
||||
hudColour
|
||||
)
|
||||
return status
|
||||
end
|
||||
local i = 0
|
||||
@ -397,7 +571,15 @@ function ARWidgets.cpuMonitor(glasses, x, y)
|
||||
local rowStop1 = ARG.hudRectangle(glasses, x + 94 + i * 17, y + 3, 300, 6, hudColour)
|
||||
local rowStop2 = ARG.hudRectangle(glasses, x + 102 + j * 17, y + 12, 300, 6, hudColour)
|
||||
local horizontalStrip = ARG.hudRectangle(glasses, x + 100, y + 22, 210, 1, workingColour)
|
||||
local diagonalStrip = ARG.hudQuad(glasses, {x+89, y+11}, {x+89, y+12}, {x+100, y+23}, {x+100, y+22}, workingColour)
|
||||
local diagonalStrip =
|
||||
ARG.hudQuad(
|
||||
glasses,
|
||||
{x + 89, y + 11},
|
||||
{x + 89, y + 12},
|
||||
{x + 100, y + 23},
|
||||
{x + 100, y + 22},
|
||||
workingColour
|
||||
)
|
||||
initializeCpuMonitor = false
|
||||
end
|
||||
local cpus = comp.me_interface.getCpus()
|
||||
@ -415,15 +597,18 @@ local initializeTPS = true
|
||||
function ARWidgets.displayTPS(glasses, x, y)
|
||||
if initializeTPS then
|
||||
initializeTPS = false
|
||||
local background = ARG.hudQuad(glasses, {x+40, y+4}, {x+40, y+15}, {x+93, y+15}, {x+105, y+4}, hudColour, 0.6)
|
||||
local background =
|
||||
ARG.hudQuad(glasses, {x + 40, y + 4}, {x + 40, y + 15}, {x + 93, y + 15}, {x + 105, y + 4}, hudColour, 0.6)
|
||||
local startBlock = ARG.hudRectangle(glasses, x, y, 40, 23, hudColour)
|
||||
local top = ARG.hudRectangle(glasses, x + 40, y, 65, 4, hudColour)
|
||||
local bottom = ARG.hudRectangle(glasses, x + 40, y + 14, 50, 5, hudColour)
|
||||
local wedge1 = ARG.hudQuad(glasses, {x+40, y+19}, {x+40, y+23}, {x+42, y+23}, {x+46, y+19}, hudColour)
|
||||
local wedge1 =
|
||||
ARG.hudQuad(glasses, {x + 40, y + 19}, {x + 40, y + 23}, {x + 42, y + 23}, {x + 46, y + 19}, hudColour)
|
||||
local wedge2 = ARG.hudQuad(glasses, {x + 105, y}, {x + 86, y + 19}, {x + 93, y + 19}, {x + 112, y}, hudColour)
|
||||
local stripe1 = ARG.hudRectangle(glasses, x + 2, y + 20, 39, 1, workingColour)
|
||||
local stripe2 = ARG.hudRectangle(glasses, x + 45, y + 16, 48, 1, workingColour)
|
||||
local stripe3 = ARG.hudQuad(glasses, {x+41, y+20}, {x+41, y+21}, {x+45, y+17}, {x+45, y+16}, workingColour)
|
||||
local stripe3 =
|
||||
ARG.hudQuad(glasses, {x + 41, y + 20}, {x + 41, y + 21}, {x + 45, y + 17}, {x + 45, y + 16}, workingColour)
|
||||
local stripe4 = ARG.hudRectangle(glasses, x + 1, y + 2, 1, 19, workingColour)
|
||||
TPSText = ARG.hudText(glasses, "", x + 42, y + 6, workingColour, 1)
|
||||
end
|
||||
|
@ -1,7 +1,11 @@
|
||||
machineBackground = 0x121010; progressBackground = 0x272c2e
|
||||
labelColour = 0xFF00FF;
|
||||
errorColour = 0xFF0000;
|
||||
idleColour = 0xb300ff; workingColour = 0x00a6ff
|
||||
positiveEUColour = 0x00CC00; negativeEUColour = 0xCC0000
|
||||
timeColour = 0x5500FF; textColor = 0x000000
|
||||
hudColour = 0x1E1E28;
|
||||
machineBackground = 0x121010
|
||||
progressBackground = 0x272c2e
|
||||
labelColour = 0xFF00FF
|
||||
errorColour = 0xFF0000
|
||||
idleColour = 0xb300ff
|
||||
workingColour = 0x00a6ff
|
||||
positiveEUColour = 0x00CC00
|
||||
negativeEUColour = 0xCC0000
|
||||
timeColour = 0x5500FF
|
||||
textColor = 0x000000
|
||||
hudColour = 0x1E1E28
|
||||
|
@ -1,23 +1,29 @@
|
||||
comp = require("component");
|
||||
comp = require("component")
|
||||
color = {
|
||||
red = 0xFF0000, green = 0x00FF00, blue = 0x0000FF,
|
||||
purple = 0x5500FF, cyan = 0x00A6FF, lightGreen = 0x00CC00,
|
||||
lightGray = 0x272c2e, darkGray = 0x121010, white = 0x000000
|
||||
red = 0xFF0000,
|
||||
green = 0x00FF00,
|
||||
blue = 0x0000FF,
|
||||
purple = 0x5500FF,
|
||||
cyan = 0x00A6FF,
|
||||
lightGreen = 0x00CC00,
|
||||
lightGray = 0x272c2e,
|
||||
darkGray = 0x121010,
|
||||
white = 0x000000
|
||||
}
|
||||
local graphics = {}
|
||||
|
||||
function pixel(GPU, x, y, color)
|
||||
local screenY = math.ceil(y/2); local baseChar, baseForeground, baseBackground = GPU.get(x, screenY)
|
||||
local screenY = math.ceil(y / 2)
|
||||
local baseChar, baseForeground, baseBackground = GPU.get(x, screenY)
|
||||
GPU.setForeground(color)
|
||||
GPU.setBackground(baseBackground)
|
||||
if y % 2 == 1 then --Upper half of pixel
|
||||
GPU.set(x, screenY, "▀");
|
||||
GPU.set(x, screenY, "▀")
|
||||
else --Lower half of pixel
|
||||
GPU.set(x, screenY, "▄");
|
||||
GPU.set(x, screenY, "▄")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function graphics.rect(GPU, x, y, w, h, color)
|
||||
local hLeft = h
|
||||
if x > 0 and y > 0 then
|
||||
@ -41,9 +47,11 @@ function graphics.rect(GPU, x, y, w, h, color)
|
||||
end
|
||||
|
||||
function graphics.text(GPU, x, y, color, string)
|
||||
if y % 2 == 0 then error("Text position must be odd on y axis") end
|
||||
if y % 2 == 0 then
|
||||
error("Text position must be odd on y axis")
|
||||
end
|
||||
local screenY = math.ceil(y / 2)
|
||||
GPU.setForeground(color);
|
||||
GPU.setForeground(color)
|
||||
for i = 0, #string - 1 do
|
||||
local baseChar, baseForeground, baseBackground = GPU.get(x + i, screenY)
|
||||
GPU.setBackground(baseBackground)
|
||||
@ -52,15 +60,19 @@ function graphics.text(GPU, x, y, color, string)
|
||||
end
|
||||
|
||||
function graphics.centeredText(GPU, x, y, color, string)
|
||||
if y % 2 == 0 then error("Text position must be odd on y axis") end
|
||||
if y % 2 == 0 then
|
||||
error("Text position must be odd on y axis")
|
||||
end
|
||||
local screenY = math.ceil(y / 2)
|
||||
local oldForeground = GPU.setForeground(color); local oldBackground = GPU.getBackground()
|
||||
local oldForeground = GPU.setForeground(color)
|
||||
local oldBackground = GPU.getBackground()
|
||||
for i = 0, #string - 1 do
|
||||
local baseChar, baseForeground, baseBackground = GPU.get(x + i - math.ceil(#string / 2) + 1, screenY)
|
||||
GPU.setBackground(baseBackground)
|
||||
GPU.fill(x + i - math.ceil(#string / 2) + 1, screenY, 1, 1, string:sub(i + 1, i + 1))
|
||||
end
|
||||
GPU.setBackground(oldBackground); GPU.setForeground(oldForeground)
|
||||
GPU.setBackground(oldBackground)
|
||||
GPU.setForeground(oldForeground)
|
||||
end
|
||||
|
||||
function graphics.border(GPU, w, h, color)
|
||||
|
@ -1,5 +1,9 @@
|
||||
local draw = require("graphics"); local event = require("event"); local thread = require("thread"); local uc = require("unicode")
|
||||
local comp = require("component"); GPU = comp.proxy(comp.get("f26678f4"))
|
||||
local draw = require("graphics")
|
||||
local event = require("event")
|
||||
local thread = require("thread")
|
||||
local uc = require("unicode")
|
||||
local comp = require("component")
|
||||
GPU = comp.proxy(comp.get("f26678f4"))
|
||||
|
||||
local gui, quit, editing = {}, false, false
|
||||
local currentWindows = {}
|
||||
@ -18,14 +22,17 @@ end
|
||||
|
||||
local contextMenus = 0
|
||||
|
||||
|
||||
function contextMenu(GPU, x, y, data)
|
||||
function filterClicks(event) return event == "touch" end
|
||||
function filterClicks(event)
|
||||
return event == "touch"
|
||||
end
|
||||
inContextMenu = true
|
||||
contextMenus = contextMenus + 1
|
||||
local longestData = 0
|
||||
for i, data in pairs(data) do
|
||||
if #data > longestData then longestData = #data end
|
||||
if #data > longestData then
|
||||
longestData = #data
|
||||
end
|
||||
end
|
||||
local contextWindow = createWindow(GPU, longestData, #data * 2, "ContextMenu" .. contextMenus)
|
||||
GPU.setActiveBuffer(contextWindow)
|
||||
@ -36,20 +43,21 @@ function contextMenu(GPU, x, y, data)
|
||||
currentWindows["ContextMenu" .. contextMenus].x = x
|
||||
currentWindows["ContextMenu" .. contextMenus].y = y
|
||||
GPU.setActiveBuffer(0)
|
||||
|
||||
end
|
||||
|
||||
function keyboardListener()
|
||||
function processKey(event, address, key, code, player)
|
||||
local value = uc.char(key)
|
||||
if value == "." then quit = true end
|
||||
if value == "." then
|
||||
quit = true
|
||||
end
|
||||
if value == "e" then
|
||||
if editing then
|
||||
editing = false
|
||||
else
|
||||
editing = true end
|
||||
editing = true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
return event.listen("key_up", processKey)
|
||||
end
|
||||
@ -62,9 +70,15 @@ function processCommand(GPU, window, option)
|
||||
currentWindows["ColorBox"].y = 10
|
||||
end
|
||||
GPU.setActiveBuffer(currentWindows["ColorBox"].page)
|
||||
if option == 1 then draw.rect(GPU, 1, 1, 10, 10, color.red) end
|
||||
if option == 2 then draw.rect(GPU, 1, 1, 10, 10, color.blue) end
|
||||
if option == 3 then draw.rect(GPU, 1, 1, 10, 10, color.green) end
|
||||
if option == 1 then
|
||||
draw.rect(GPU, 1, 1, 10, 10, color.red)
|
||||
end
|
||||
if option == 2 then
|
||||
draw.rect(GPU, 1, 1, 10, 10, color.blue)
|
||||
end
|
||||
if option == 3 then
|
||||
draw.rect(GPU, 1, 1, 10, 10, color.green)
|
||||
end
|
||||
GPU.setActiveBuffer(0)
|
||||
end
|
||||
|
||||
@ -74,7 +88,9 @@ function mouseListener()
|
||||
activeWindow = checkCollision(x, y)
|
||||
draw.text(GPU, 1, 1, color.cyan, "Active window: " .. activeWindow)
|
||||
if key == 1.0 and editing then
|
||||
if inContextMenu then contextMenus = 0 end
|
||||
if inContextMenu then
|
||||
contextMenus = 0
|
||||
end
|
||||
contextMenu(GPU, x, y, {[1] = "Red", [2] = "Blue", [3] = "Green"})
|
||||
else
|
||||
if inContextMenu then
|
||||
@ -89,7 +105,8 @@ function mouseListener()
|
||||
contextMenus = 0
|
||||
end
|
||||
else
|
||||
if activeWindow ~= "None " then end
|
||||
if activeWindow ~= "None " then
|
||||
end
|
||||
xOffset = x - currentWindows[activeWindow].x
|
||||
yOffset = y - currentWindows[activeWindow].y
|
||||
end
|
||||
@ -111,7 +128,6 @@ end
|
||||
|
||||
function dropListener()
|
||||
function processDrop(event, address, x, y, key, player)
|
||||
|
||||
end
|
||||
return event.listen("drop", processDrop)
|
||||
end
|
||||
@ -125,7 +141,9 @@ end
|
||||
function compose(GPU)
|
||||
local stateBuffer = currentWindows["State"].page
|
||||
GPU.setActiveBuffer(stateBuffer)
|
||||
if editing then copyWindow(GPU, 1, 1, currentWindows["Black"].page) end
|
||||
if editing then
|
||||
copyWindow(GPU, 1, 1, currentWindows["Black"].page)
|
||||
end
|
||||
for window, params in pairs(currentWindows) do
|
||||
if params.w > 0 then
|
||||
copyWindow(GPU, params.x, params.y, params.page, stateBuffer)
|
||||
@ -133,7 +151,8 @@ function compose(GPU)
|
||||
end
|
||||
if inContextMenu then
|
||||
local cont = currentWindows["ContextMenu1"]
|
||||
copyWindow(GPU, cont.x, cont.y, cont.page) end
|
||||
copyWindow(GPU, cont.x, cont.y, cont.page)
|
||||
end
|
||||
GPU.setActiveBuffer(0)
|
||||
end
|
||||
|
||||
@ -144,7 +163,9 @@ end
|
||||
|
||||
--return gui
|
||||
|
||||
GPU = comp.proxy(comp.get("de837fec")); screen = comp.get("48ce2988"); GPU.bind(screen);
|
||||
GPU = comp.proxy(comp.get("de837fec"))
|
||||
screen = comp.get("48ce2988")
|
||||
GPU.bind(screen)
|
||||
GPU.freeAllBuffers()
|
||||
keyInput, mouseInput, drag = keyboardListener(), mouseListener(), dragListener()
|
||||
createWindow(GPU, 160, 100, "Black")
|
||||
@ -162,7 +183,10 @@ GPU.setActiveBuffer(0)
|
||||
copyWindow(GPU, 1, 1, currentWindows["Black"].page)
|
||||
|
||||
while true do
|
||||
if quit then event.cancel(keyInput); break end
|
||||
if quit then
|
||||
event.cancel(keyInput)
|
||||
break
|
||||
end
|
||||
compose(GPU)
|
||||
os.sleep(0.1)
|
||||
end
|
@ -1,4 +1,7 @@
|
||||
local comp = require("component"); local event = require("event"); local thread = require("thread"); local uc = require("unicode")
|
||||
local comp = require("component")
|
||||
local event = require("event")
|
||||
local thread = require("thread")
|
||||
local uc = require("unicode")
|
||||
local utility = {}
|
||||
|
||||
function utility.machine(address)
|
||||
@ -15,7 +18,12 @@ function utility.getPercent(number)
|
||||
end
|
||||
|
||||
function utility.time(number) --Returns a given number formatted as Hours Minutes Seconds
|
||||
if number == 0 then return 0 else return math.floor(number/3600).."h "..math.floor((number - math.floor(number/3600)*3600)/60).."min "..(number%60).."s" end
|
||||
if number == 0 then
|
||||
return 0
|
||||
else
|
||||
return math.floor(number / 3600) ..
|
||||
"h " .. math.floor((number - math.floor(number / 3600) * 3600) / 60) .. "min " .. (number % 60) .. "s"
|
||||
end
|
||||
end
|
||||
|
||||
function utility.splitNumber(number) --Returns given number formatted as XXX,XXX,XXX
|
||||
@ -29,12 +37,15 @@ function utility.splitNumber(number) --Returns given number formatted as XXX,XXX
|
||||
formattedNumber[i] = formattedNumber[i] .. ","
|
||||
end
|
||||
end
|
||||
if(sign < 0) then table.insert(formattedNumber, 1, "-") end
|
||||
if (sign < 0) then
|
||||
table.insert(formattedNumber, 1, "-")
|
||||
end
|
||||
return table.concat(formattedNumber, "")
|
||||
end
|
||||
|
||||
function utility.tier(number)
|
||||
local values = {[1] = "LV",
|
||||
local values = {
|
||||
[1] = "LV",
|
||||
[2] = "MV",
|
||||
[3] = "HV",
|
||||
[4] = "EV",
|
||||
@ -42,7 +53,7 @@ function utility.tier(number)
|
||||
[6] = "LuV",
|
||||
[7] = "ZPM",
|
||||
[8] = "UV",
|
||||
[9] = "UHV",
|
||||
[9] = "UHV"
|
||||
}
|
||||
return values[number]
|
||||
end
|
||||
@ -50,7 +61,9 @@ end
|
||||
function utility.exit(key)
|
||||
local function processKey(event, address, key, code, player)
|
||||
local value = uc.char(key)
|
||||
if value == "e" then run = false end
|
||||
if value == "e" then
|
||||
run = false
|
||||
end
|
||||
return false
|
||||
end
|
||||
event.listen("key_up", processKey)
|
||||
|
@ -1,5 +1,9 @@
|
||||
comp = require("component");screen = require("term"); computer = require("computer"); event = require("event")
|
||||
draw = require("graphics"); util = require("utility")
|
||||
comp = require("component")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
event = require("event")
|
||||
draw = require("graphics")
|
||||
util = require("utility")
|
||||
|
||||
local widgets = {}
|
||||
|
||||
@ -18,12 +22,16 @@ function widgets.gtMachineInit(GPU, name, address)
|
||||
--Check for tier on Processing Arrays
|
||||
if string.match(machine.getSensorInformation()[6], "tier") ~= nil then
|
||||
local tier = util.tier((string.gsub(machine.getSensorInformation()[6], "([^0-9]+)", "") - 1) / 10)
|
||||
if tier ~= nil then draw.text(GPU, 4, 5, accentB, ""..tier) end
|
||||
if tier ~= nil then
|
||||
draw.text(GPU, 4, 5, accentB, "" .. tier)
|
||||
end
|
||||
end
|
||||
--Check for parallel on Processing Arrays
|
||||
if string.match(machine.getSensorInformation()[7], "Parallel") ~= nil then
|
||||
local parallel = string.gsub(machine.getSensorInformation()[7], "([^0-9]+)", "")
|
||||
if parallel ~= nil then draw.text(GPU, 11+-#parallel.."", 5, mainColor, parallel.."x") end
|
||||
if parallel ~= nil then
|
||||
draw.text(GPU, 11 + -(#parallel) .. "", 5, mainColor, parallel .. "x")
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -75,11 +83,12 @@ function widgets.gtMachine(GPU, name, address)
|
||||
draw.rect(GPU, 3, 8, bars3, 1, mainColor)
|
||||
draw.rect(GPU, 27 - bars3, 2, bars3, 1, mainColor)
|
||||
end
|
||||
progressString = tostring(math.floor(machine.getWorkProgress()/20)).."/"..tostring(math.floor(machine.getWorkMaxProgress()/20)).."s"
|
||||
progressString =
|
||||
tostring(math.floor(machine.getWorkProgress() / 20)) ..
|
||||
"/" .. tostring(math.floor(machine.getWorkMaxProgress() / 20)) .. "s"
|
||||
middlePoint = math.min(9, 12 - #progressString / 2)
|
||||
draw.rect(GPU, 18, 5, 8, 2, background)
|
||||
draw.text(GPU, 26 - #progressString, 5, accentA, progressString)
|
||||
|
||||
else --No work
|
||||
_, f, _ = GPU.get(5, 1)
|
||||
if f ~= barColor then
|
||||
@ -93,7 +102,10 @@ function widgets.gtMachine(GPU, name, address)
|
||||
end
|
||||
end
|
||||
_, f, _ = GPU.get(6, 1)
|
||||
if ((windows[name].data == 0 or string.match(machine.getSensorInformation()[windows[name].data], ".*c0.*")) and machine.isWorkAllowed()) == true then
|
||||
if
|
||||
((windows[name].data == 0 or string.match(machine.getSensorInformation()[windows[name].data], ".*c0.*")) and
|
||||
machine.isWorkAllowed()) == true
|
||||
then
|
||||
if f ~= background then
|
||||
draw.rect(GPU, 6, 2, 1, 1, background)
|
||||
draw.rect(GPU, 23, 8, 1, 1, background)
|
||||
@ -119,7 +131,17 @@ function widgets.create(GPU, x, y, name, dataAddress, widget)
|
||||
local page = GPU.allocateBuffer(width, math.ceil(height / 2))
|
||||
GPU.setActiveBuffer(page)
|
||||
local widgetData = widget.initialize(GPU, name, dataAddress)
|
||||
windows[name] = {GPU = GPU, page=page, address = dataAddress, x=x, y=y, w=width, h=height, update = widget.update, data = widgetData}
|
||||
windows[name] = {
|
||||
GPU = GPU,
|
||||
page = page,
|
||||
address = dataAddress,
|
||||
x = x,
|
||||
y = y,
|
||||
w = width,
|
||||
h = height,
|
||||
update = widget.update,
|
||||
data = widgetData
|
||||
}
|
||||
GPU.setActiveBuffer(0)
|
||||
end
|
||||
|
||||
|
@ -1,13 +1,18 @@
|
||||
comp=require("component"); event=require("event"); screen=require("term"); computer = require("computer"); thread = require("thread")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
thread = require("thread")
|
||||
local AU = require("util")
|
||||
local AT = require("transport")
|
||||
local S = require("serialization"); local uc = require("unicode")
|
||||
local S = require("serialization")
|
||||
local uc = require("unicode")
|
||||
local D = require("dictionary")
|
||||
local network = comp.modem
|
||||
local id, AD
|
||||
local function requestID()
|
||||
network.broadcast(100, "requestID")
|
||||
local _, _, _, _, _, messageType, value = event.pull("modem_message");
|
||||
local _, _, _, _, _, messageType, value = event.pull("modem_message")
|
||||
while messageType ~= "sendID" do
|
||||
_, _, _, _, _, messageType, value = event.pull("modem_message")
|
||||
os.sleep(0.2)
|
||||
@ -21,25 +26,53 @@ function checkRepeat(recipe)
|
||||
if AT.isEmpty(AD["inputTransposer" .. i], 16) then
|
||||
if AT.check(AD["inputTransposer" .. i], recipe["input" .. i].name, recipe["input" .. i].amount) then
|
||||
correctItems = correctItems + 1
|
||||
else return false end
|
||||
else return false end
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
for i = 1, recipe.fluids, 1 do
|
||||
if AT.isEmpty(AD["fluidTransposer" .. i], 1) then
|
||||
if AT.check(AD["fluidTransposer"..i], fluidMap[recipe["fluid"..i].name].name, recipe["fluid"..i].amount / fluidMap[recipe["fluid"..i].name].size) then
|
||||
if
|
||||
AT.check(
|
||||
AD["fluidTransposer" .. i],
|
||||
fluidMap[recipe["fluid" .. i].name].name,
|
||||
recipe["fluid" .. i].amount / fluidMap[recipe["fluid" .. i].name].size
|
||||
)
|
||||
then
|
||||
correctItems = correctItems + 1
|
||||
else return false end
|
||||
else return false end
|
||||
else
|
||||
return false
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
if correctItems == recipe.inputs + recipe.fluids then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
if correctItems == recipe.inputs + recipe.fluids then return true else return false end
|
||||
end
|
||||
|
||||
local function processRecipe(recipe)
|
||||
local database, interface = AD.database, AD.input1
|
||||
local function insert()
|
||||
for i = 1, recipe.fluids, 1 do AT.move(AD["fluidTransposer"..i], recipe["fluid"..i].amount / fluidMap[recipe["fluid"..i].name].size, 1) end
|
||||
for i = 1, recipe.inputs, 1 do AT.move(AD["inputTransposer"..i], recipe["input"..i].amount, 16) end
|
||||
for i = 1, recipe.fluids, 1 do AT.empty(AD["fluidTransposer"..i]) end
|
||||
for i = 1, recipe.fluids, 1 do
|
||||
AT.move(
|
||||
AD["fluidTransposer" .. i],
|
||||
recipe["fluid" .. i].amount / fluidMap[recipe["fluid" .. i].name].size,
|
||||
1
|
||||
)
|
||||
end
|
||||
for i = 1, recipe.inputs, 1 do
|
||||
AT.move(AD["inputTransposer" .. i], recipe["input" .. i].amount, 16)
|
||||
end
|
||||
for i = 1, recipe.fluids, 1 do
|
||||
AT.empty(AD["fluidTransposer" .. i])
|
||||
end
|
||||
end
|
||||
for i = 1, recipe.inputs, 1 do
|
||||
database.clear(i)
|
||||
@ -53,7 +86,12 @@ local function processRecipe(recipe)
|
||||
AT.set(AD["input" .. i], database, i, recipe["input" .. i].amount)
|
||||
end
|
||||
for i = 1, recipe.fluids, 1 do
|
||||
AT.set(AD["fluid"..i], database, 20+i, recipe["fluid"..i].amount / fluidMap[recipe["fluid"..i].name].size)
|
||||
AT.set(
|
||||
AD["fluid" .. i],
|
||||
database,
|
||||
20 + i,
|
||||
recipe["fluid" .. i].amount / fluidMap[recipe["fluid" .. i].name].size
|
||||
)
|
||||
end
|
||||
::insertRecipes::
|
||||
insert()
|
||||
@ -69,8 +107,12 @@ local function processRecipe(recipe)
|
||||
network.broadcast(id, "jammed")
|
||||
else
|
||||
screen.write(" ... Assembly Started")
|
||||
while AD.controller.hasWork() do os.sleep(0.1) end
|
||||
if checkRepeat(recipe) then goto insertRecipes end
|
||||
while AD.controller.hasWork() do
|
||||
os.sleep(0.1)
|
||||
end
|
||||
if checkRepeat(recipe) then
|
||||
goto insertRecipes
|
||||
end
|
||||
end
|
||||
AT.clearAll(AD)
|
||||
screen.write(" ... finished task!\n")
|
||||
@ -109,7 +151,9 @@ local function startAssembly()
|
||||
storedID = io.open("ID", "w")
|
||||
storedID:write(id)
|
||||
else
|
||||
for line in io.lines("ID") do id = line + 0 end
|
||||
for line in io.lines("ID") do
|
||||
id = line + 0
|
||||
end
|
||||
end
|
||||
storedID:close()
|
||||
network.open(id)
|
||||
|
@ -13,9 +13,8 @@ dictionary = {
|
||||
["gt.metaitem.01.32705.name"] = "gt.metaitem.03.32084.name", --IV
|
||||
["gt.metaitem.03.32086.name"] = "gt.metaitem.03.32084.name",
|
||||
["gt.metaitem.03.32089.name"] = "gt.metaitem.03.32084.name",
|
||||
|
||||
["gt.metaitem.03.32085.name"] = "gt.metaitem.03.32083.name", --EV
|
||||
["gt.metaitem.01.32704.name"] = "gt.metaitem.03.32083.name",
|
||||
["gt.metaitem.01.32704.name"] = "gt.metaitem.03.32083.name"
|
||||
}
|
||||
|
||||
-- dictlist = {
|
||||
|
@ -1,11 +1,10 @@
|
||||
local path = "/home"
|
||||
local shell = require("shell")
|
||||
local download_list =
|
||||
{
|
||||
local download_list = {
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Programs/Assembly%20Line/assemblyClient.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Programs/Assembly%20Line/dictionary.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Programs/Assembly%20Line/transport.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Programs/Assembly%20Line/util.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Programs/Assembly%20Line/util.lua"
|
||||
}
|
||||
shell.setWorkingDirectory(path)
|
||||
print("Updating Files")
|
||||
|
@ -1,4 +1,9 @@
|
||||
comp=require("component"); event=require("event"); screen=require("term"); computer = require("computer"); thread = require("thread"); uc = require("unicode")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
thread = require("thread")
|
||||
uc = require("unicode")
|
||||
AU = require("util")
|
||||
local S = require("serialization")
|
||||
local D = require("dictionary")
|
||||
@ -23,13 +28,17 @@ local function getIDs()
|
||||
end
|
||||
local function contains(t, value)
|
||||
for k, v in pairs(t) do
|
||||
if v == value then return true end
|
||||
if v == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
local function getFree()
|
||||
for i = mainChannel, mainChannel + knownAssemblyLines, 1 do
|
||||
if assemblyStatus[i] == false then return i end
|
||||
if assemblyStatus[i] == false then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
@ -70,25 +79,50 @@ function startAssembly(assemblyport, recipe)
|
||||
end
|
||||
local function spairs(t, order)
|
||||
local keys = {}
|
||||
for k in pairs(t) do keys[#keys+1] = k end
|
||||
if order then table.sort(keys, function(a, b) return order(t, a, b) end) else table.sort(keys) end
|
||||
for k in pairs(t) do
|
||||
keys[#keys + 1] = k
|
||||
end
|
||||
if order then
|
||||
table.sort(
|
||||
keys,
|
||||
function(a, b)
|
||||
return order(t, a, b)
|
||||
end
|
||||
)
|
||||
else
|
||||
table.sort(keys)
|
||||
end
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
if keys[i] then return keys[i], t[keys[i] ] end
|
||||
if keys[i] then
|
||||
return keys[i], t[keys[i]]
|
||||
end
|
||||
end
|
||||
end
|
||||
function matchRecipe(recipes)
|
||||
local items = comp.me_interface.getItemsInNetwork()
|
||||
local foundItems = {}
|
||||
if #items > 0 then for i = 1, #items, 1 do foundItems[items[i].label] = items[i].size end end
|
||||
for outputLabel, recipe in spairs(recipes, function(t,a,b) return t[b].inputs < t[a].inputs end) do
|
||||
if #items > 0 then
|
||||
for i = 1, #items, 1 do
|
||||
foundItems[items[i].label] = items[i].size
|
||||
end
|
||||
end
|
||||
for outputLabel, recipe in spairs(
|
||||
recipes,
|
||||
function(t, a, b)
|
||||
return t[b].inputs < t[a].inputs
|
||||
end
|
||||
) do
|
||||
local found = 0
|
||||
local craftable = 1000
|
||||
for i = 1, recipe.inputs, 1 do
|
||||
local label, requiredAmount = recipe["input" .. i].name, recipe["input" .. i].amount
|
||||
if dictionary[label] ~= nil then label = dictionary[label] end
|
||||
if foundItems[label] == nil then break
|
||||
if dictionary[label] ~= nil then
|
||||
label = dictionary[label]
|
||||
end
|
||||
if foundItems[label] == nil then
|
||||
break
|
||||
else
|
||||
local existingAmount = foundItems[label]
|
||||
if existingAmount >= requiredAmount then
|
||||
@ -100,11 +134,14 @@ function matchRecipe(recipes)
|
||||
for i = 1, recipe.fluids, 1 do
|
||||
local label, requiredAmount
|
||||
if fluidMap[recipe["fluid" .. i].name] ~= nil then
|
||||
label, requiredAmount = fluidMap[recipe["fluid"..i].name].name, recipe["fluid"..i].amount / fluidMap[recipe["fluid"..i].name].size
|
||||
label, requiredAmount =
|
||||
fluidMap[recipe["fluid" .. i].name].name,
|
||||
recipe["fluid" .. i].amount / fluidMap[recipe["fluid" .. i].name].size
|
||||
else
|
||||
break
|
||||
end
|
||||
if foundItems[label] == nil then break
|
||||
if foundItems[label] == nil then
|
||||
break
|
||||
else
|
||||
local existingAmount = foundItems[label]
|
||||
if existingAmount >= requiredAmount then
|
||||
@ -113,7 +150,9 @@ function matchRecipe(recipes)
|
||||
end
|
||||
end
|
||||
end
|
||||
if found == recipe.inputs + recipe.fluids then return recipe, craftable end
|
||||
if found == recipe.inputs + recipe.fluids then
|
||||
return recipe, craftable
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
@ -1,4 +1,8 @@
|
||||
comp=require("component"); event=require("event"); screen=require("term"); computer = require("computer"); thread = require("thread")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
thread = require("thread")
|
||||
|
||||
local transport = {}
|
||||
|
||||
@ -16,12 +20,23 @@ function transport.clear(interface)
|
||||
end
|
||||
function transport.check(transposer, item, amount)
|
||||
local itemstack = transposer.getStackInSlot(0, 1)
|
||||
if itemstack == nil then return false else
|
||||
if itemstack.label == item and itemstack.size >= amount then return true else return false end end
|
||||
if itemstack == nil then
|
||||
return false
|
||||
else
|
||||
if itemstack.label == item and itemstack.size >= amount then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
function transport.isEmpty(transposer, slot)
|
||||
local itemstack = transposer.getStackInSlot(1, slot)
|
||||
if itemstack == nil then return true else return false end
|
||||
if itemstack == nil then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
function transport.clearAll(assemblydata)
|
||||
for i = 1, 15, 1 do
|
||||
|
@ -1,4 +1,8 @@
|
||||
comp=require("component"); event=require("event"); screen=require("term"); computer = require("computer"); thread = require("thread")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
thread = require("thread")
|
||||
|
||||
local assemblyUtil = {}
|
||||
|
||||
@ -7,7 +11,10 @@ local function addEntries(file, prompt, amount, type)
|
||||
for i = 1, amount, 1 do
|
||||
screen.write(prompt .. " " .. i .. " ")
|
||||
a, b, c = event.pull()
|
||||
while a ~= "component_added" do a, b, c = event.pull(); os.sleep() end
|
||||
while a ~= "component_added" do
|
||||
a, b, c = event.pull()
|
||||
os.sleep()
|
||||
end
|
||||
file:write(type .. i .. "," .. b .. "\n")
|
||||
screen.write(b .. "\n")
|
||||
end
|
||||
@ -21,13 +28,25 @@ local function addAuxilary(file, proxy, type)
|
||||
end
|
||||
end
|
||||
local function split(s, sep)
|
||||
local fields = {}; local sep = sep or " "; local pattern = string.format("([^%s]+)", sep)
|
||||
string.gsub(s, pattern, function(c) fields[#fields + 1] = c end)
|
||||
local fields = {}
|
||||
local sep = sep or " "
|
||||
local pattern = string.format("([^%s]+)", sep)
|
||||
string.gsub(
|
||||
s,
|
||||
pattern,
|
||||
function(c)
|
||||
fields[#fields + 1] = c
|
||||
end
|
||||
)
|
||||
return fields
|
||||
end
|
||||
local function proxy(address)
|
||||
machineAddress = comp.get(address)
|
||||
if(machineAddress ~= nil) then return comp.proxy(machineAddress) else return nil end
|
||||
if (machineAddress ~= nil) then
|
||||
return comp.proxy(machineAddress)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
local function configureClient()
|
||||
local file = io.open("addresses", "w")
|
||||
@ -73,13 +92,27 @@ function copyPattern(interface, slot, recipe, database)
|
||||
for i = 1, recipe.inputs, 1 do
|
||||
local item = recipe["input" .. i]
|
||||
local name = item.name
|
||||
if dictionary[name] ~= nil then name = dictionary[name] end
|
||||
if dictionary[name] ~= nil then
|
||||
name = dictionary[name]
|
||||
end
|
||||
interface.setInterfacePatternInput(slot, database, databaseMap[name], item.amount, i)
|
||||
end
|
||||
end
|
||||
function getControllerTier(assemblyData)
|
||||
local controller = assemblyData["controller"]
|
||||
return voltageToTier(math.floor(string.gsub(string.sub(controller.getSensorInformation()[4], 1, string.find(controller.getSensorInformation()[4], "/")-1), "([^0-9]+)", "") + 0))
|
||||
return voltageToTier(
|
||||
math.floor(
|
||||
string.gsub(
|
||||
string.sub(
|
||||
controller.getSensorInformation()[4],
|
||||
1,
|
||||
string.find(controller.getSensorInformation()[4], "/") - 1
|
||||
),
|
||||
"([^0-9]+)",
|
||||
""
|
||||
) + 0
|
||||
)
|
||||
)
|
||||
end
|
||||
local function addRecipe(recipelist, slot, source, sourceSide)
|
||||
if source.getStackInSlot(sourceSide, slot) ~= nil then
|
||||
|
@ -1,7 +1,15 @@
|
||||
comp=require("component");screen=require("term");computer=require("computer");event=require("event"); thread = require("thread"); sides = require("sides")
|
||||
get=require("utility"); ARG=require("ARGraphics"); G = require("graphics")
|
||||
comp = require("component")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
event = require("event")
|
||||
thread = require("thread")
|
||||
sides = require("sides")
|
||||
get = require("utility")
|
||||
ARG = require("ARGraphics")
|
||||
G = require("graphics")
|
||||
S = require("stockerUtil")
|
||||
local uc = require("unicode"); tx = require("transforms")
|
||||
local uc = require("unicode")
|
||||
tx = require("transforms")
|
||||
config = require("config")
|
||||
local GPU = comp.gpu
|
||||
interface = comp.me_interface
|
||||
@ -18,9 +26,23 @@ function mouseListener()
|
||||
if activeWindow == "Button" then
|
||||
GPU.setActiveBuffer(0)
|
||||
if drawerItem == nil or number == "" then
|
||||
G.rect(GPU, currentWindows["Button"].x+2, currentWindows["Button"].y*2+1, 6, 6, negativeEUColour)
|
||||
G.rect(
|
||||
GPU,
|
||||
currentWindows["Button"].x + 2,
|
||||
currentWindows["Button"].y * 2 + 1,
|
||||
6,
|
||||
6,
|
||||
negativeEUColour
|
||||
)
|
||||
else
|
||||
G.rect(GPU, currentWindows["Button"].x+2, currentWindows["Button"].y*2+1, 6, 6, positiveEUColour)
|
||||
G.rect(
|
||||
GPU,
|
||||
currentWindows["Button"].x + 2,
|
||||
currentWindows["Button"].y * 2 + 1,
|
||||
6,
|
||||
6,
|
||||
positiveEUColour
|
||||
)
|
||||
if itemsToStock[drawerItem] ~= nil then
|
||||
S.update(drawerItem, itemsToStock[drawerItem], number)
|
||||
itemsToStock[drawerItem] = number
|
||||
@ -37,7 +59,13 @@ function mouseListener()
|
||||
elseif activeWindow == "Number" then
|
||||
GPU.setActiveBuffer(0)
|
||||
if drawerItem == nil then
|
||||
G.centeredText(GPU, currentWindows["Number"].x+25, currentWindows["Number"].y*2+3, 0xFFFFFF, "Pattern refresh requested...")
|
||||
G.centeredText(
|
||||
GPU,
|
||||
currentWindows["Number"].x + 25,
|
||||
currentWindows["Number"].y * 2 + 3,
|
||||
0xFFFFFF,
|
||||
"Pattern refresh requested..."
|
||||
)
|
||||
S.refreshCraftables()
|
||||
end
|
||||
inNumberBox = true
|
||||
@ -63,7 +91,9 @@ function keyboardListener()
|
||||
inNumberBox = false
|
||||
G.refresh(GPU)
|
||||
end
|
||||
if key == 8 then number = string.sub(number, 1, #number-1) elseif (key >= 48 and key <= 57) then
|
||||
if key == 8 then
|
||||
number = string.sub(number, 1, #number - 1)
|
||||
elseif (key >= 48 and key <= 57) then
|
||||
number = number .. value
|
||||
end
|
||||
G.rect(GPU, currentWindows["Number"].x + 2, currentWindows["Number"].y * 2 + 1, 46, 6, 0x333333)
|
||||
@ -101,7 +131,13 @@ function getNewItem(GPU, x, y)
|
||||
GPU.setActiveBuffer(0)
|
||||
if itemsToStock[drawerItem] ~= nil then
|
||||
G.rect(GPU, currentWindows["Item"].x, currentWindows["Item"].y * 2 - 3, 60, 2, 0x000000)
|
||||
G.centeredText(GPU, currentWindows["Item"].x+30, currentWindows["Item"].y*2-3, 0xFFFFFF, "Configured: "..itemsToStock[drawerItem])
|
||||
G.centeredText(
|
||||
GPU,
|
||||
currentWindows["Item"].x + 30,
|
||||
currentWindows["Item"].y * 2 - 3,
|
||||
0xFFFFFF,
|
||||
"Configured: " .. itemsToStock[drawerItem]
|
||||
)
|
||||
end
|
||||
G.refresh(GPU)
|
||||
else
|
||||
@ -117,7 +153,13 @@ function getNewItem(GPU, x, y)
|
||||
GPU.setActiveBuffer(0)
|
||||
if itemsToStock[drawerItem] ~= nil then
|
||||
G.rect(GPU, currentWindows["Item"].x, currentWindows["Item"].y * 2 - 3, 60, 2, 0x000000)
|
||||
G.centeredText(GPU, currentWindows["Item"].x+30, currentWindows["Item"].y*2-3, 0xFFFFFF, "Configured: "..itemsToStock[drawerItem])
|
||||
G.centeredText(
|
||||
GPU,
|
||||
currentWindows["Item"].x + 30,
|
||||
currentWindows["Item"].y * 2 - 3,
|
||||
0xFFFFFF,
|
||||
"Configured: " .. itemsToStock[drawerItem]
|
||||
)
|
||||
end
|
||||
G.refresh(GPU)
|
||||
end
|
||||
@ -177,11 +219,11 @@ function craftableBox(GPU, x, y)
|
||||
if S.uniques() > 2500 then --Check against rebooted system
|
||||
if toStock > 0 then
|
||||
if drawerItem == label then
|
||||
G.text(GPU, 4, 3+2*i, workingColour, label);
|
||||
G.text(GPU, 4, 3 + 2 * i, workingColour, label)
|
||||
elseif craftables[label] == nil then
|
||||
G.text(GPU, 4, 3+2*i, negativeEUColour, label);
|
||||
G.text(GPU, 4, 3 + 2 * i, negativeEUColour, label)
|
||||
else
|
||||
G.text(GPU, 4, 3+2*i, 0xFFFFFF, label);
|
||||
G.text(GPU, 4, 3 + 2 * i, 0xFFFFFF, label)
|
||||
end
|
||||
if stockedAmount >= toStock then --In stock
|
||||
G.text(GPU, 59 - (#stockedString + 1), 3 + 2 * i, 0xFFFFFF, stockedString)
|
||||
@ -207,11 +249,17 @@ function craftableBox(GPU, x, y)
|
||||
G.refresh(GPU)
|
||||
end
|
||||
|
||||
mouseListener(); keyboardListener(); GPU.setResolution(160, 46); screen.clear()
|
||||
mouseListener()
|
||||
keyboardListener()
|
||||
GPU.setResolution(160, 46)
|
||||
screen.clear()
|
||||
G.clear()
|
||||
numberBox(GPU, 100, 41); button(GPU, 150, 41); craftableBox(GPU, 0, 0)
|
||||
numberBox(GPU, 100, 41)
|
||||
button(GPU, 150, 41)
|
||||
craftableBox(GPU, 0, 0)
|
||||
G.refresh(GPU)
|
||||
S.refreshCraftables(); S.loadPatterns()
|
||||
S.refreshCraftables()
|
||||
S.loadPatterns()
|
||||
local timeSinceRefresh = computer.uptime()
|
||||
while true do
|
||||
getNewItem(GPU, 100, 38)
|
||||
|
@ -1,6 +1,14 @@
|
||||
comp=require("component");screen=require("term");computer=require("computer");event=require("event"); thread = require("thread"); sides = require("sides")
|
||||
get=require("utility"); ARG=require("ARGraphics"); G = require("graphics")
|
||||
local uc = require("unicode"); tx = require("transforms")
|
||||
comp = require("component")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
event = require("event")
|
||||
thread = require("thread")
|
||||
sides = require("sides")
|
||||
get = require("utility")
|
||||
ARG = require("ARGraphics")
|
||||
G = require("graphics")
|
||||
local uc = require("unicode")
|
||||
tx = require("transforms")
|
||||
config = require("config")
|
||||
local GPU = comp.gpu
|
||||
local sUtil = {}
|
||||
@ -13,7 +21,13 @@ function sUtil.refreshCraftables()
|
||||
for i, craftable in pairs(c) do
|
||||
if i ~= "n" then
|
||||
if i % 10 == 0 then
|
||||
G.centeredText(GPU, currentWindows["Number"].x+25, currentWindows["Number"].y*2+3, 0xFFFFFF, "Discovering Patterns: "..i.." / "..#c)
|
||||
G.centeredText(
|
||||
GPU,
|
||||
currentWindows["Number"].x + 25,
|
||||
currentWindows["Number"].y * 2 + 3,
|
||||
0xFFFFFF,
|
||||
"Discovering Patterns: " .. i .. " / " .. #c
|
||||
)
|
||||
end
|
||||
end
|
||||
if craftable ~= #c then
|
||||
@ -26,34 +40,42 @@ local cachedAmounts = {}
|
||||
function sUtil.updateCache()
|
||||
local itemList = interface.getItemsInNetwork()
|
||||
for i = 1, #itemList, 1 do
|
||||
if i % 200 == 0 then os.sleep() end
|
||||
if i % 200 == 0 then
|
||||
os.sleep()
|
||||
end
|
||||
cachedAmounts[itemList[i].label] = itemList[i].size
|
||||
itemList[i] = nil
|
||||
end
|
||||
end
|
||||
function sUtil.getAmount(itemLabel)
|
||||
if cachedAmounts[itemLabel] == nil then return 0 else return cachedAmounts[itemLabel] end
|
||||
if cachedAmounts[itemLabel] == nil then
|
||||
return 0
|
||||
else
|
||||
return cachedAmounts[itemLabel]
|
||||
end
|
||||
end
|
||||
function sUtil.uniques()
|
||||
return #cachedAmounts
|
||||
end
|
||||
function sUtil.update(label, oldAmount, newAmount)
|
||||
local file = io.open("configured", 'r')
|
||||
local file = io.open("configured", "r")
|
||||
local fileContent = {}
|
||||
local lineNumber = 0
|
||||
local i = 1
|
||||
for line in file:lines() do
|
||||
if line == label..","..oldAmount then lineNumber = i end
|
||||
if line == label .. "," .. oldAmount then
|
||||
lineNumber = i
|
||||
end
|
||||
table.insert(fileContent, line)
|
||||
i = i + 1
|
||||
end
|
||||
io.close(file)
|
||||
file = io.open("configured", 'w')
|
||||
file = io.open("configured", "w")
|
||||
for index, value in ipairs(fileContent) do
|
||||
if index ~= lineNumber then
|
||||
file:write(value..'\n')
|
||||
file:write(value .. "\n")
|
||||
else
|
||||
file:write(label..","..newAmount..'\n')
|
||||
file:write(label .. "," .. newAmount .. "\n")
|
||||
end
|
||||
end
|
||||
io.close(file)
|
||||
@ -65,8 +87,16 @@ function sUtil.addPattern(label, amount)
|
||||
itemsToStock[label] = amount
|
||||
end
|
||||
local function split(s, sep)
|
||||
local fields = {}; local sep = sep or " "; local pattern = string.format("([^%s]+)", sep)
|
||||
string.gsub(s, pattern, function(c) fields[#fields + 1] = c end)
|
||||
local fields = {}
|
||||
local sep = sep or " "
|
||||
local pattern = string.format("([^%s]+)", sep)
|
||||
string.gsub(
|
||||
s,
|
||||
pattern,
|
||||
function(c)
|
||||
fields[#fields + 1] = c
|
||||
end
|
||||
)
|
||||
return fields
|
||||
end
|
||||
function sUtil.loadPatterns()
|
||||
|
@ -1,16 +1,23 @@
|
||||
comp = require("component"); event = require("event")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
AR = require("ARWidgets")
|
||||
ARG = require("ARGraphics")
|
||||
local wSampsa, hSampsa = 853, 473
|
||||
local powerHudX, powerHudY, powerHudW, powerHudH = 0, hSampsa - 24, wSampsa * 0.39 + 3, 14
|
||||
local glasses = comp.glasses
|
||||
glasses.removeAll()
|
||||
AR.minimapOverlay(glasses); AR.hudOverlayBase(glasses, 335, 449); AR.clear();
|
||||
AR.minimapOverlay(glasses)
|
||||
AR.hudOverlayBase(glasses, 335, 449)
|
||||
AR.clear()
|
||||
AR.crossHair(glasses, 422, 231)
|
||||
screen.clear()
|
||||
while true do
|
||||
AR.powerDisplay(glasses, comp.gt_machine, powerHudX, powerHudY, powerHudW, powerHudH)
|
||||
AR.fluidMonitor(glasses, 795, 153, {
|
||||
AR.fluidMonitor(
|
||||
glasses,
|
||||
795,
|
||||
153,
|
||||
{
|
||||
[0] = {label = "Oxygen Gas", displayName = "Oxygen", color = 0x688690, max = 128},
|
||||
[1] = {label = "Nitrogen Gas", displayName = "Nitrogen", color = 0x976868, max = 128},
|
||||
[2] = {label = "Hydrogen Gas", displayName = "Hydrogen", color = 0xa78282, max = 128},
|
||||
|
@ -1,4 +1,5 @@
|
||||
comp = require("component"); event = require("event")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
AR = require("ARWidgets")
|
||||
|
||||
while true do
|
||||
|
@ -1,4 +1,5 @@
|
||||
comp = require("component"); event = require("event")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
AR = require("ARWidgets")
|
||||
|
||||
while true do
|
||||
|
@ -1,4 +1,8 @@
|
||||
comp=require("component"); event=require("event"); screen=require("term"); computer = require("computer"); thread = require("thread")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
thread = require("thread")
|
||||
|
||||
local GPU = comp.gpu
|
||||
GPU.setResolution(54, 26)
|
||||
@ -15,7 +19,9 @@ function checkHeatLevels()
|
||||
for address, type in pairs(comp.list()) do
|
||||
if type == "reactor_chamber" then
|
||||
screen.write("Reactor " .. i)
|
||||
if i < 10 then screen.write(" ") end
|
||||
if i < 10 then
|
||||
screen.write(" ")
|
||||
end
|
||||
local reactor = comp.proxy(address)
|
||||
if reactor.getHeat() > 0 then
|
||||
GPU.setForeground(0xFF0000)
|
||||
|
@ -7,13 +7,16 @@ destinations = {
|
||||
[6] = {name = "Test", id = 3004}
|
||||
}
|
||||
|
||||
local comp=require("component"); local event=require("event"); local screen=require("term"); local computer = require("computer")
|
||||
local util = require("utility"); local draw=require("graphics")
|
||||
local comp = require("component")
|
||||
local event = require("event")
|
||||
local screen = require("term")
|
||||
local computer = require("computer")
|
||||
local util = require("utility")
|
||||
local draw = require("graphics")
|
||||
local GPU = comp.gpu
|
||||
GPU.setResolution(80, 25)
|
||||
|
||||
local boundingBoxes = {
|
||||
}
|
||||
local boundingBoxes = {}
|
||||
function createDestination(x, y, index)
|
||||
local width, height = 18, 6
|
||||
local page = GPU.allocateBuffer(width, math.ceil(height / 2))
|
||||
|
@ -1,4 +1,7 @@
|
||||
local comp=require("component"); local event=require("event"); local screen=require("term"); local computer = require("computer")
|
||||
local comp = require("component")
|
||||
local event = require("event")
|
||||
local screen = require("term")
|
||||
local computer = require("computer")
|
||||
|
||||
function cycle()
|
||||
comp.redstone.setOutput(2, 15)
|
||||
@ -20,7 +23,6 @@ local ticket = 1
|
||||
--end
|
||||
|
||||
function setDestination(destination)
|
||||
|
||||
end
|
||||
|
||||
function unload(index)
|
||||
@ -57,7 +59,8 @@ function doStartupSequence()
|
||||
gpu.freeAllBuffers()
|
||||
local colors = {
|
||||
[0] = 0x00a6ff,
|
||||
[1] = 0x000000}
|
||||
[1] = 0x000000
|
||||
}
|
||||
local buffer = gpu.allocateBuffer()
|
||||
gpu.setActiveBuffer(buffer)
|
||||
for i = 2, 20, 1 do
|
||||
@ -65,11 +68,7 @@ function doStartupSequence()
|
||||
copyWindow(gpu, 0, 0, buffer, 0)
|
||||
end
|
||||
gpu.setForeground(colors[i % 2])
|
||||
comp.gpu.fill(2 + i * 2,
|
||||
1 + i,
|
||||
80 - i * 4,
|
||||
40 - i * 2,
|
||||
"█")
|
||||
comp.gpu.fill(2 + i * 2, 1 + i, 80 - i * 4, 40 - i * 2, "█")
|
||||
os.sleep(0.1)
|
||||
end
|
||||
gpu.setActiveBuffer(0)
|
||||
|
@ -1,4 +1,5 @@
|
||||
comp = require("component"); event = require("event")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
|
||||
local transposer = comp.transposer
|
||||
local dark = 2
|
||||
|
@ -4,14 +4,22 @@ local players = {["Sampsa"] = 3, ["Dark"] = 2}
|
||||
local function findEmptyCans(player)
|
||||
local allItems = transposer.getAllStacks(players[player]).getAll()
|
||||
if #allItems > 30 then
|
||||
for i = 0, 39, 1 do if allItems[i].label == "Tin Can" then return i + 1 end end
|
||||
for i = 0, 39, 1 do
|
||||
if allItems[i].label == "Tin Can" then
|
||||
return i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function checkLevel(player)
|
||||
local itemStack = transposer.getStackInSlot(players[player], 28)
|
||||
if itemStack ~= nil then return itemStack.size else return nil end
|
||||
if itemStack ~= nil then
|
||||
return itemStack.size
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
local function transferFood(player)
|
||||
@ -19,14 +27,18 @@ local function transferFood(player)
|
||||
end
|
||||
local function transferEmpty(player)
|
||||
local slot = findEmptyCans(player)
|
||||
if slot ~= nil then transposer.transferItem(players[player], 0, 64, slot, 2) end
|
||||
if slot ~= nil then
|
||||
transposer.transferItem(players[player], 0, 64, slot, 2)
|
||||
end
|
||||
end
|
||||
|
||||
local function check(player)
|
||||
if transposer.getInventorySize(players[player]) == 40 then
|
||||
local inInventory = checkLevel(player)
|
||||
if inInventory ~= nil then
|
||||
if inInventory < 40 then transferFood(player) end
|
||||
if inInventory < 40 then
|
||||
transferFood(player)
|
||||
end
|
||||
os.sleep(0.2)
|
||||
transferEmpty(player)
|
||||
end
|
||||
|
@ -1,4 +1,7 @@
|
||||
local comp=require("component"); local event=require("event"); local screen=require("term"); local computer = require("computer")
|
||||
local comp = require("component")
|
||||
local event = require("event")
|
||||
local screen = require("term")
|
||||
local computer = require("computer")
|
||||
|
||||
local transposers = {}
|
||||
function configureTransposers()
|
||||
|
@ -1,4 +1,9 @@
|
||||
comp=require("component"); event=require("event"); screen=require("term"); computer = require("computer"); thread = require("thread"); uc = require("unicode")
|
||||
comp = require("component")
|
||||
event = require("event")
|
||||
screen = require("term")
|
||||
computer = require("computer")
|
||||
thread = require("thread")
|
||||
uc = require("unicode")
|
||||
|
||||
local LSC = comp.gt_machine
|
||||
local engaged = false
|
||||
@ -34,9 +39,13 @@ end
|
||||
local function checkLevels()
|
||||
local fill = getPercentage()
|
||||
if fill < 0.15 then
|
||||
if not engaged then engage() end
|
||||
if not engaged then
|
||||
engage()
|
||||
end
|
||||
elseif fill > 0.95 then
|
||||
if engaged then disengage() end
|
||||
if engaged then
|
||||
disengage()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,19 +1,16 @@
|
||||
local path = "/lib"
|
||||
local shell = require("shell")
|
||||
local download_list =
|
||||
{
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Libraries/ARWidgets.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Libraries/config.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Libraries/graphics.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Libraries/utility.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Libraries/widgets.lua",
|
||||
"https://raw.githubusercontent.com/S4mpsa/InfOS/master/Libraries/ARGraphics.lua"
|
||||
}
|
||||
shell.setWorkingDirectory(path)
|
||||
print("Updating Files")
|
||||
for k,v in pairs(download_list) do
|
||||
print("Fetching ",v)
|
||||
local command = "wget "..v.." -f"
|
||||
shell.execute(command)
|
||||
end
|
||||
|
||||
local tarMan = "https://raw.githubusercontent.com/mpmxyz/ocprograms/master/usr/man/tar.man"
|
||||
local tarBin = "https://raw.githubusercontent.com/mpmxyz/ocprograms/master/home/bin/tar.lua"
|
||||
local InfOS = "https://github.com/gordominossi/InfOS/releases/download/v0/InfOS.tar"
|
||||
|
||||
shell.setWorkingDirectory("/usr/man")
|
||||
shell.execute("wget " .. tarMan .. " -f")
|
||||
|
||||
shell.setWorkingDirectory("/bin")
|
||||
shell.execute("wget " .. tarBin .. " -f")
|
||||
|
||||
shell.setWorkingDirectory("/home")
|
||||
print("Updating InfOS")
|
||||
shell.execute("wget " .. InfOS .. " -f")
|
||||
shell.execute("tar -xf InfOS.tar")
|
||||
|
Loading…
x
Reference in New Issue
Block a user