Posted 03 June 2015 - 06:34 AM
I've been having problems with the boolean readouts. They screw up my interface on the advanced computers. Is there a way to disable these? And if you could tell me, what causes it to shift up like this?
Program leading to Engine Room Controls
The Engine Room Controls
button API I used
Program leading to Engine Room Controls
Spoiler
--Loads button API
os.loadAPI("button")
--Main Menu
function MainMenu()
StartingCredits()
button.setTable("Base Menu", BaseMenu, "", 2, 17, 4, 4)
button.setTable("Shutdown", os.shutdown, "", 42, 51, 19, 19)
button.screen()
while true do
button.pullEvent()
end
end
--Base Menu
function BaseMenu()
StartingCredits()
button.setTable("Engine Control", shell.run, "EngineControl", 2, 17, 4, 4)
button.setTable("<--", MainMenu, "", 1, 5, 19, 19)
button.setTable("Shutdown", os.shutdown, "", 42, 51, 19, 19)
button.screen()
while true do
button.pullEvent()
end
end
--Starting Credits
function StartingCredits()
term.clear()
button.clearTable()
term.setCursorPos(1,1)
term.write("Master Computer v1.0")
term.setCursorPos(1,2)
term.write(" Created by: WillisDoering")
end
--Start of Program
rednet.open("back")
MainMenu()
The Engine Room Controls
Spoiler
--Main Menu
function MainMenu()
term.clear()
button.clearTable()
button.heading("Engine Controls")
button.setTable("Engine 1", engine1, "", 2, 17, 3, 3)
button.setTable("<--", shell.exit, "", 1, 5, 19, 19)
button.setTable("Shutdown", os.shutdown, "", 42, 51, 19, 19)
button.screen()
end
--Engine 1 Controls
function engine1()
button.setButton("Engine 1", true)
button.label(30, 3, "Engine Controls")
button.setTable("Active", E1A, "", 19, 49, 6, 6)
button.setTable("Disabled", E1D, "", 19, 49, 8, 8)
button.setTable("Check Status", E1S, "", 19, 49, 10, 10)
button.screen()
end
function E1S()
rednet.broadcast("Inquiry", "E1S")
senderID, E1S, protocol = rednet.receive("E1SR", 2)
if E1S == true then
button.setButton("Active", true)
button.setButton("Disabled", false)
else
button.setButton("Disabled", true)
button.setButton("Active", false)
end
button.screen()
end
function E1A()
rednet.broadcast(true, "E1")
button.setButton("Active", true)
button.screen()
end
function E1D()
rednet.broadcast(false, "E1")
button.setButton("Disabled", false)
button.screen()
end
--Beginning program
MainMenu()
while true do
button.pullEvent()
end
button API I used
Spoiler
--code created by Direwolf20 and edited by WillisDoering
term.setTextColor(colors.white)
local button={}
term.setBackgroundColor(colors.black)
function clearTable()
button = {}
end
function setButton(name, buttonOn)
print(name)
print(button[name]["active"])
button[name]["active"] = buttonOn
screen()
end
function setTable(name, func, param, xmin, xmax, ymin, ymax)
button[name] = {}
button[name]["func"] = func
button[name]["active"] = false
button[name]["param"] = param
button[name]["xmin"] = xmin
button[name]["ymin"] = ymin
button[name]["xmax"] = xmax
button[name]["ymax"] = ymax
end
function fill(text, colorT, colorH, bData)
term.setBackgroundColor(colorH)
term.setTextColor(colorT)
local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
for j = bData["ymin"], bData["ymax"] do
term.setCursorPos(bData["xmin"], j)
if j == yspot then
for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
if k == xspot then
term.write(text)
else
term.write(" ")
end
end
else
for i = bData["xmin"], bData["xmax"] do
term.write(" ")
end
end
end
term.setBackgroundColor(colors.black)
end
function screen()
local currColorT
local currColorH
for name,data in pairs(button) do
local on = data["active"]
if on == true then
currColorT = colors.black
currColorH = colors.white
else
currColorT = colors.white
currColorH = colors.blue
end
fill(name, currColorT, currColorH, data)
end
end
function toggleButton(name)
button[name]["active"] = not button[name]["active"]
screen()
end
function flash(name)
toggleButton(name)
screen()
sleep(0.15)
toggleButton(name)
screen()
end
function checkxy(x, y)
for name, data in pairs(button) do
if y>=data["ymin"] and y <= data["ymax"] then
if x>=data["xmin"] and x<= data["xmax"] then
if data["param"] == "" then
data["func"]()
else
data["func"](data["param"])
end
return true
--data["active"] = not data["active"]
--print(name)
end
end
end
return false
end
function heading(text)
w, h = term.getSize()
term.setCursorPos((w-string.len(text))/2+1, 1)
term.write(text)
end
function label(w, h, text)
term.setCursorPos(w, h)
term.write(text)
end
function pullEvent()
event,side,x,y = os.pullEvent("mouse_click")
checkxy(x,y)
end