Skip to content

Commit

Permalink
Started the power system layout on the ui
Browse files Browse the repository at this point in the history
  • Loading branch information
rater193 committed Apr 17, 2018
1 parent 8a727b1 commit 5d96bb0
Showing 1 changed file with 85 additions and 25 deletions.
110 changes: 85 additions & 25 deletions baseglasses/baseglasses.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,96 @@
local glib = require("rater193/library")

--Libraries
local component = require("component")
local thread = require("thread")

--Used variables
local glasses = component.glasses

--Clearing the glasses
glasses.removeAll()

function createBatteryContent()
local content = {
["bg"] = glasses.addRect(),
["textName"] = glasses.addTextLabel(),
["textPower"] = glasses.addTextLabel()
}

content.bg.setColor(0,0,0)
content.bg.setAlpha(0.5)
content.bg.setSize(256,23)

content.textName.setScale(1,1)
content.textName.setColor(255,255,255)
content.textName.setAlpha(1)

content.textPower.setScale(1,1)
content.textPower.setColor(255,255,255)
content.textPower.setAlpha(1)

return content
end

local batteries = {
{
["name"] = "Battery-1",
["power"] = {
["cur"] = "2435",
["max"] = "63215424",
["maxin"] = "10000",
["maxout"] = "10000",
["generatedLastTick"] = "10"
},
["content"] = createBatteryContent()
},
{
["name"] = "Battery-2",
["power"] = {
["cur"] = "2435",
["max"] = "63215424",
["maxin"] = "10000",
["maxout"] = "10000",
["generatedLastTick"] = "10"
},
["content"] = createBatteryContent()
},
{
["name"] = "Battery-3",
["power"] = {
["cur"] = "2435",
["max"] = "63215424",
["maxin"] = "10000",
["maxout"] = "10000",
["generatedLastTick"] = "10"
},
["content"] = createBatteryContent()
}
}

--Update thread
thread.create(function()
local debugText = glasses.addTextLabel()
debugText.setText("Debug loading")
debugText.setColor(255,255,255)
debugText.setScale(1,1)
debugText.setPosition(10,0)

local frameCount = 200

--Initial debug text
glib.createMessage(levels.warn, "This is a warning message")
glib.createMessage(levels.warn, "Test 2")

while(frameCount>0) do
debugText.setText("Messages: " .. tostring(#messages) .. ", Frames left: " .. tostring(frameCount) .. ", seconds: " .. tostring(frameCount/20))
glib.update()
frameCount = frameCount-1
os.sleep(1/40)
while true do
for i, v in pairs(batteries) do
local bg = v.content.bg
local textName = v.content.textName
local textPower = v.content.textPower

bg.setPosition(8, 8+(i*24))
bg.setColor(0,0,0)
bg.setAlpha(0.5)
bg.setSize(128,23)

textName.setPosition(10, 10+(i*24))
textName.setText("Battery: " .. tostring(v.name) .. "")

textPower.setPosition(10, 10+(i*24)+12)
textPower.setText("Power: 0/0")
end
os.sleep(1)
end
glasses.removeAll()
end)

--Calculation thread
thread.create(function()
local repeatTimes = 5
while (repeatTimes > 0) do
os.sleep(1)
createMessage(levels.error, "Error message, " .. tostring(repeatTimes))
repeatTimes = repeatTimes-1
end

end)

0 comments on commit 5d96bb0

Please sign in to comment.