Spoiler
--this is the BlueTide OS 2.0.0 program
--copyright of BlueTide Programs.inc, Benedict Allen, all members of BlueTide Programs.inc and all members of programcraft.inc
--if you wish to use this program please contact Benedict Allen(awsumben13 on cc forums) and make sure you give the credit to BlueTide Programs
--for tips and info visit the BlueTide Website at www.bluetideprograms.webs.com or for more programs www.bluetideprograms.weebly.com/download.html
--usability functions
local function clear()
term.clear()
term.setCursorPos(1,1)
end
local function clearPos(x,y)
term.clear()
term.setCursorPos(x,y)
end
local function writePos(x,y,text)
term.setCursorPos(x,y)
term.write(text)
end
function clearPrint(x,y,text)
term.clear()
term.setCursorPos(x,y)
term.write(text)
end
function clearLine(y)
writePos(1,y," ")
end
function reset(file, x, y)
if fs.exists(file) then
h = fs.open(file, "w")
h.write("")
h.close()
term.setCursorPos(x,y)
term.write("File reset")
sleep(2)
else
term.setCursorPos(x,y)
term.write("file not found")
sleep(2)
end
end
function tip(help)
while true do
clear()
print(help)
writePos(1,18,"press enter or backspace to exit")
event, key = os.pullEvent()
if key == 28 or key == 14 then
break
end
end
end
function drawBox(x,y,z,n)
writePos(x,y,"+")
term.setCursorPos(x+1,y)
for i = 1,(z-x)-1 do
write("-")
end
writePos(z,y,"+")
term.setCursorPos(x+1,n)
for i = 1,(z-x)-1 do
write("-")
end
for i = 1,(n-y)-1 do
writePos(x,y+i,"|")
end
for i = 1,(n-y)-1 do
writePos(z,y+i,"|")
end
writePos(x,n,"+")
writePos(z,n,"+")
end
--end
--programs functions
function drawFieldOne()
writePos(1,1,"Welcome: Benedict BlueTideOS 1.4.0")
writePos(1,2,"==================================================")
writePos(1,17,"==================================================")
writePos(1,18," Programs Notifications Shortcuts Explorer ")
if fieldSelected == 1 then
if f1Selected == 1 then
writePos(2,18,"[")
writePos(11,18,"]")
elseif f1Selected == 2 then
writePos(13,18,"[")
writePos(27,18,"]")
elseif f1Selected == 3 then
writePos(29,18,"[")
writePos(39,18,"]")
elseif f1Selected == 4 then
writePos(41,18,"[")
writePos(50,18,"]")
end
end
end
function runFieldOne()
clear()
drawFieldTwo()
drawFieldOne()
if programRunning ~= "desktop" then
writePos(20,10,"[not selected]")
end
event, key, p2, p3, p4, p5 = os.pullEvent()
if key == 203 and f1Selected > 1 then
f1Selected = f1Selected-1
elseif key == 205 and f1Selected < 4 then
f1Selected = f1Selected+1
elseif key == 14 then
exit()
elseif key == 15 then
fieldSelected = 2
elseif key == 42 then
event, key, p2, p3, p4, p5 = os.pullEvent()
if key == 32 then
programRunning = "desktop"
drawFieldTwo()
end
elseif key == 28 and f1Selected == 1 then
programApp()
elseif key == 28 and f1Selected == 2 then
notificationShower()
elseif key == 28 and f1Selected == 3 then
shortcutApp()
elseif key == 28 and f1Selected == 4 then
programRunning = "explorer"
fieldSelected = 2
elseif key == 29 or key == 157 then
tip("BlueTide OS v-"..version.."nn Controls:nn Switch field/tab = tabn Exit = backspacen Move cursor = arrow keysn Get controls = ctrln Select Option = enternn Shortcut keys:nn ctrl = helpn tab = switch tabsn control panel = right shiftn desktop = left shift-d")
end
end
function drawFieldTwo()
if programRunning == "explorer" then
drawBrowserScreen()
elseif programRunning == "desktop" then
drawDesktop()
end
end
function runFieldTwo()
clear()
drawFieldOne()
drawFieldTwo()
if programRunning == "explorer" then
fileBrowser()
elseif programRunning == "desktop" then
fieldSelected = 1
end
if key == 15 then
fieldSelected = 1
end
end
function drawBrowserScreen()
if dirViewing == "/" then
dirDisplayed = "Computer"
else
dirDisplayed = dirViewing
k = string.len(dirDisplayed)
if k > 25 then
dirDisplayed = string.sub(dirDisplayed, k-25,k)
end
end
writePos(1,3,"BlueTide Explorer - "..dirDisplayed)
writePos(1,4,"--------------------------------------------------")
getFiles()
if explorerItemCount > 12 then
newItemCount = 12
else
newItemCount = explorerItemCount
end
for i = 1,newItemCount do
if fs.isDir(dirDisplayed.."/"..listOfFiles[i]) then
writePos((string.len(listOfFiles[i]))+1,4+i," - Directory")
else
writePos((string.len(listOfFiles[i]))+1,4+i," - File")
end
end
if explorerItemCount < 13 then
for i = 1,explorerItemCount do
writePos(2,4+i,listOfFiles[i])
end
else
for i = 1,12 do
writePos(2,4+i,listOfFiles[i])
end
writePos(2,14,"More...")
end
if fieldSelected == 2 then
if browserSelected < 13 then
writePos(1,4+browserSelected,">")
end
end
end
function getFiles()
listOfFiles = fs.list(dirViewing)
explorerItemCount = #listOfFiles
end
function fileBrowser()
clear()
drawFieldOne()
drawFieldTwo()
event, key, p2, p3, p4, p5 = os.pullEvent()
if key == 208 and browserSelected < explorerItemCount and browserSelected < 12 then
browserSelected = browserSelected+1
elseif key == 200 and browserSelected > 1 then
browserSelected = browserSelected-1
elseif key == 15 then
fieldSelected = 1
elseif key == 14 then
exit()
elseif key == 42 then
event, key, p2, p3, p4, p5 = os.pullEvent()
if key == 32 then
programRunning = "desktop"
drawFieldTwo()
end
elseif key == 13 and dirViewing ~= "bluetide" then
dirViewing = shell.resolve("..")
elseif key == 28 then
if fs.isDir(dirViewing.."/"..listOfFiles[browserSelected]) then
table.insert(fileOrder, "/") table.insert(fileOrder, listOfFiles[browserSelected])
dirViewing = dirViewing.."/"..listOfFiles[browserSelected]
else
end
end
end
--end
--variables
browserSelected = 1
listOfFiles = {}
explorerItemCount = #listOfFiles
explorerItems = {"";}
dirViewing = "bluetide"
notificationAn1Time = 0.001
programSelected = 1
f1Selected = 1
loopBreaker = false
fieldSelected = 1
blueTidePrograms = {"BlueMail","BlueWord","BlueTide AntiVirus","BlueVille","BlueNewGame","Tutorial","BlueTunes"}
OS_shortcuts = {}
characters = {}
programRunning = "desktop"
fileOrder = {""}
userLoggedIn = "DefaultUser"
version = "2.0.0"
shortcutPath = "bluetide/users/"..userLoggedIn.."/shortcuts"
shortcuts = fs.list(shortcutPath)
shortcutSelected = 1
notificationAn2Time = 0.3
notificationCount = 0
possibleNotifications = {"New email", "Disk Inserted", "New peripheral found", "Redstone signal change", "Rednet GPS ping"}
notifications = {"Email from 1", "Disk Inserted", "New peripheral found", "Redstone signal change", "Rednet GPS ping"}
notificationSelected = 1
--end
--code
while loopBreaker ~= true do
if fieldSelected == 1 then
runFieldOne()
elseif fieldSelected == 2 then
runFieldTwo()
end
end
clear()
--end
i removed all of the unneccesarry functions and stuff and the reason it has such a wierd setup is so it can draw and run any of the functions and always have the taskbar present and so when in the taskbar it can draw the program without running it