Posted 04 June 2013 - 03:44 AM
Hi i am trying to get some simple programs and some of Wraithbone's simple GUI functions to work together on startup on an Advanced Computer , I am not getting errors and the time and menus will only execute manually and show blank on startup.
(prepare for lots of code)
Loadbar:
Login:
System Clock:
Windows style menu:
Startup:
could someone please point out what I'm doing wrong
Changelog of fixes
> * fixed the term.clear at startup
(prepare for lots of code)
Loadbar:
Spoiler
print("PTOS V0.1.2")
print("loading PTOS Core System Files And Settings")
function HorzLoadBar(sx, fx, sym)
x,y =term.getCursorPos()
if y >= 18 then
term.clear()
term.setCursorPos(sx,1)
x,y = sx,1
end
term.setCursorPos(sx,y)
write("[")
term.setCursorPos(sx,y)
term.setCursorPos(fx-1,y)
write("]")
mdp = math.floor((sx + fx)/2) - 3
for i = (sx+1),(fx-2) do
term.setCursorPos(i,y)
write(sym)
sleep(0.1)
term.setCursorPos(mdp,y+1)
write(string.format("%d",i/(fx-2) * 100))
write("%")
end
term.setCursorPos(1,y+2)
end
HorzLoadBar(15,35,"|")
term.clear()
Login:
Spoiler
print("PTOS V0.1.2")
write("Login: ")
lanswer = read()
if lanswer == "Pivotdude" then
write("Password: ")
else
os.reboot()
end
panswer = read("*")
if panswer == "1337" then
print("Welcome "..lanswer..".")
else
os.reboot()
end
term.clear()
System Clock:
Spoiler
print(textutils.formatTime(os.time(), false))
Windows style menu:
Spoiler
function VertMenu(tableofItems)
local selection = "";
local sIndex = 1;
while (selection == "") do
term.clear();
local xMax, yMax = term.getSize();
local y = math.floor(yMax/2) + math.floor(#tableofItems/2);
y = y - #tableofItems;
if y<1 then y = 1 end;
if #tableofItems > yMax then
print "ERROR: List does not fit on screen, reduce number of items in table";
return "";
end
for i = 1, #tableofItems do
if string.len(tableofItems[i]) >= xMax then
term.clear();
term.setCursorPos(1,1);
print (("ERROR: List item # "..i).." is too long please reduce");
return "";
end
local x = math.floor(xMax/2) - math.floor(string.len(tableofItems[i])/2);
if i == sIndex then x = x-1 end;
term.setCursorPos(x,y);
if i == sIndex then term.write("[") end;
term.write(tableofItems[i]);
if i == sIndex then term.write("]") end;
y = y+1;
end
local r,s = os.pullEvent("key");
if s == 208 then sIndex = sIndex +1 end;
if s == 200 then sIndex = sIndex -1 end;
if sIndex > #tableofItems then sIndex = 1 end;
if sIndex < 1 then sIndex = #tableofItems end;
if s == 28 then
term.clear();
term.setCursorPos(1,1);
return tableofItems[sIndex]
end
end
end
Startup:
Spoiler
shell.run("loadbar")
shell.run("login")
term.clear()
shell.run("menu")
shell.run("systemtime")
could someone please point out what I'm doing wrong
Changelog of fixes
> * fixed the term.clear at startup