I've got two issues with this code, number one being that I've added text, it appears, but when i click a button it disappears.
Number two is pages not working.
Any help is greatly appreciated!
os.loadAPI("touchpoint")
tM = touchpoint.new("back")
tS = touchpoint.new("back")
tA = touchpoint.new("back")
m = peripheral.wrap("back")
--Pages
local t
turbine = nil
r = "N/A"
RF = {}
RPM = {}
trb = {}
trb[0] = peripheral.wrap("BigReactors-Turbine_0")
trb[1] = peripheral.wrap("BigReactors-Turbine_1")
trb[2] = peripheral.wrap("BigReactors-Turbine_2")
trb[3] = peripheral.wrap("BigReactors-Turbine_3")
trb[4] = peripheral.wrap("BigReactors-Turbine_4")
trb[5] = peripheral.wrap("BigReactors-Turbine_5")
function mainPage()
t = tA
end
function test()
print("test")
end
function changePage(changeTo) --Change Page
if t == tA or t == tM then
oldT = t
t = changeTo
else
t = oldT
end
end
function getRPM()
if turbine == nil then
r = "N/A"
else
r = trb[turbine].getRotorSpeed()
end
end
function information()
getRPM()
if t == tA or t == tM then
m.setCursorPos(1,1)
m.setBackgroundColor(colors.gray)
m.write("Turbine 1")
m.setCursorPos(1,2)
m.write("RPM:")
end
end
--Things happen from here
do --Buttons
tA:add("All Turbines", function() test() end, 52, 2, 65, 4)
tA:add("Turbine 1", function() turbine = 0 end, 47, 6, 57, 8)
tA:add("Turbine 2", function() turbine = 1 end, 59, 6, 69, 8)
tA:add("Turbine 3", function() turbine = 2 end, 47, 10, 57, 12)
tA:add("Turbine 4", function() turbine = 3 end, 59, 10, 69, 12)
tA:add("Turbine 5", function() turbine = 4 end, 47, 14, 57, 16)
tA:add("Turbine 6", function() turbine = 5 end, 59, 14, 69, 16)
tA:add("Overall", function() changePage() end, 59, 23, 69, 25)
tA:add("Manual", function() end, 59, 18, 69, 20)
tA:add("Auto", function() end, 47, 18, 57, 20)
tM:add("All Turbines", function() test() end, 52, 2, 65, 4)
tM:add("Turbine 1", function() test() end, 47, 6, 57, 8)
tM:add("Turbine 2", function() end, 59, 6, 69, 8)
tM:add("Turbine 3", function() end, 47, 10, 57, 12)
tM:add("Turbine 4", function() end, 59, 10, 69, 12)
tM:add("Turbine 5", function() end, 47, 14, 57, 16)
tM:add("Turbine 6", function() end, 59, 14, 69, 16)
tM:add("Overall", function() changePage(tS) end, 59, 23, 69, 25)
tM:add("Manual", function() changePage(tM) end, 59, 18, 69, 20)
tM:add("Auto", function() changePage(tA) end, 47, 18, 57, 20)
--tM:add("Power", function() end,
--tM:add("Coils", function() end,
--tM:add("Reactor", function() end,
tS:add("Main", function() changePage(oldT) end, 59, 23, 69, 25)
end
mainPage() --set mode to auto on start
while true do
m.clear()
t:draw() --draw buttons
information() --RPMs, RF/t, etc.
local event, p1 = t:handleEvents(os.pullEvent())
if event == "button_click" then
t:run(p1)
end
end
Thanks!