-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControl.lua
More file actions
71 lines (70 loc) · 2.15 KB
/
Control.lua
File metadata and controls
71 lines (70 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local GUI = require("GUI")
local buffer = require("doubleBuffering")
local component = require("component")
local reactor = {}
local auto = false
local min, max = 0
---------------------------------------------------------------------------------------------------------------------------------------------------------
--MainContainer
local mainContainer = GUI.fullScreenContainer()
--MainPanel
mainContainer:addChild(GUI.panel(1, 1, mainContainer.width, mainContainer.height, 0x2D2D2D))
--ReactorSelection
local i = 1
for address, type in component.list("br_reactor") do
reactor[i] = component.proxy(address)
i = i+1
end
--Functions
function check()
if auto == true then
if max < min then
else
end
--ButtonCreating
mainContainer:addChild(GUI.button(2,2,60,6,0xFFFFFF,0x555555,0xAAAAAA,0x2D2D2D,"Turn reactor on")).onTouch = function()
reactor[1].setActive(true)
end
mainContainer:addChild(GUI.button(64,2,60,6,0xFFFFFF,0x555555,0xAAAAAA,0x2D2D2D,"Turn reactor off")).onTouch = function()
reactor[1].setActive(false)
end
local button1 = mainContainer:addChild(GUI.roundedButton(55,15,10,1,0xFFFFFF,0x555555,0xAAAAAA,0x2D2D2D,"Apply"))
--Slider
local slider = mainContainer:addChild(GUI.slider(4,10,30,0x66DB80,0x000000,0xFFFFFF,0xAAAAAA,1,10000000,5000000,true,"Minimum limit: "," ."))
slider.roundValues=true
slider.onValueChanged = function (value)
button1.onTouch = function()
min = value
end
end
local slider1 = mainContainer:addChild(GUI.slider(4,15,30,0x66DB80,0x000000,0xFFFFFF,0xAAAAAA,1,10000000,5000000,true,"Maximum limit: "," ."))
slider1.roundValues=true
slider1.onValueChanged = function (value)
button1.onTouch = function()
max = value
end
end
--Switches
local switch1 = mainContainer:addChild(GUI.switch(55,10,8,0x66DB80,0x1D1D1D,0xEEEEEE,true))
switch1.onStateChanged = function(switch,state)
auto = switch1.state
GUI.error(max)
end
else
GUI.error(min)
end
end
--Check
while true do
if auto == true then
if reactor[1]:getEnergyStored() > max then
reactor[1].setActive(false)
elseif reactor[1]:getEnergyStored() < min then
reactor[1].setActive(true)
end
end
end
--Drawing
mainContainer:draw()
buffer.draw(true)
mainContainer:startEventHandling()