My program doesn't seem to work in SMP, but works fine in SSP.
Here's the code.
--If you're wanting to make an application for
--CCGlass, please read the guide on the forums.
--Every time a developer doesn't read the guide,
--an innocent computer dies
--DEVMODE CONFIGURATION
--If you're just looking at the code, don't touch this
--Application makers, this is pointless for you too
devmode = true
newuserdev = false
--first we set ye color values
glcolors = {}
glcolors.red = 0xff3333
glcolors.blue = 0x7dd2e4
glcolors.yellow = 0xffff4d
glcolors.green = 0x4dff4d
glcolors.gray = 0xe0e0e0
glcolors.textGray = 0x676767
glcolors.text = 0x5a5a5
glcolors.otherBlue = 0x2e679f
glcolors.black = 0x000000
--second, we ensure the user isn't wasting an advanced cpu
if term.isColor() == true and devmode == false then
print("Error: You are on an advanced computer. This program will not allow other programs to be ran. Do you wish to continue anyway?(y/n, caps count)")
answer = read()
if answer == "n" then
error("User opted out")
end
end
function getSide()
print("Which side is the Terminal Glasses Bridge on?(top bottom left right back, caps count) ")
side = read()
sw = fs.open("glassside", "w")
sw.writeLine(side)
sw.close()
print("What is your desired username?")
username = read()
sw = fs.open("username", "w")
sw.writeLine(username)
sw.close()
print("Now, if you havn't already, take the terminal glasses you're going to use and right-click the terminal bridge.")
end
function load()
dir = "CCGlass/"
--note that this still runs on first time
on = true
gs = fs.open("glassside", "r")
side = gs.readLine()
gs.close()
glass = peripheral.wrap(side)
gs = fs.open("username", "r")
username = gs.readLine()
gs.close()
end
--Ye first thing where we draw stuff
function firstDraw()
oneText= glass.addText(10, 27.9, " ", glcolors.green)
twoText= glass.addText(10, 27.9, " ", glcolors.green)
threeText= glass.addText(10, 27.9, " ", glcolors.green)
fourText= glass.addText(10, 27.9, " ", glcolors.green)
fiveText= glass.addText(10, 27.9, " ", glcolors.green)
midText= glass.addText(29, 27.9, " ", glcolors.green)
highText= glass.addText(29, 27.9, " ", glcolors.red)
lowText= glass.addText(29, 27.9, " ", glcolors.otherBlue)
leftBox = glass.addBox(5, 0, 5, 60, glcolors.blue, 0.75)
bigBox = glass.addBox(10, 5, 48, 50, glcolors.gray, 0.75)
for bigWidth = 1, 20 do
bigBox.setWidth(bigWidth * 7.5)
sleep(0.01)
end
leftBox = glass.addBox(160, 0, 5, 60, glcolors.blue, 0.75)
--Putting default text
end
--The way the OS prints stuffs to the screen
function midPrint(text)
midText.setText(text)
midText.setScale(2)
midText.setZIndex(1)
w = bigBox.getWidth()
tw = midText.getWidth()
tw = tw*2
posx = math.floor(w-tw)/2, 2
posx = posx +10
midText.setX(posx)
posy = 20
midText.setY(posy)
end
function highPrint(text)
highText.setZIndex(1)
local w = bigBox.getWidth() --=150
highText.setText(text)
tw = highText.getWidth()
hposx = math.floor(w-tw)/2, 2
hposx = hposx+10
highText.setX(hposx)
posy = 10
highText.setY(posy)
end
function lowPrint(text)
local w = bigBox.getWidth()
lowText.setText(text)
lowText.setZIndex(1)
tw = lowText.getWidth()
posx = math.floor(w-tw)/2, 2
posx = posx +10
lowText.setX(posx)
lowText.setY(40)
end
--now we define print functions for books and such
function tinyPrint(text, line, color)
local w = bigBox.getWidth()
if line == 1 then
oneText.setY(5)
oneText.setColor(color)
oneText.setZIndex(1)
oneText.setText(text)
elseif line == 2 then
twoText.setY(15)
twoText.setColor(color)
twoText.setZIndex(1)
twoText.setText(text)
elseif line == 3 then
threeText.setY(25)
threeText.setColor(color)
threeText.setZIndex(1)
threeText.setText(text)
elseif line == 4 then
fourText.setY(35)
fourText.setColor(color)
fourText.setZIndex(1)
fourText.setText(text)
elseif line == 5 then
fiveText.setY(45)
fiveText.setColor(color)
fiveText.setZIndex(1)
fiveText.setText(text)
end
end
function tinyClear()
tinyPrint(" ", 1, glcolors.red)
tinyPrint(" ", 2, glcolors.red)
tinyPrint(" ", 3, glcolors.red)
tinyPrint(" ", 4, glcolors.red)
tinyPrint(" ", 5, glcolors.red)
end
function bigClear()
highPrint(" ")
midPrint(" ")
lowPrint(" ")
end
--now we launch apps based on what the user inputs
function homeScreenLaunch()
tinyClear()
evt, cmd = os.pullEvent("chat_command")
if cmd == "apps" then
launchApps()
elseif cmd == "shutdown" then
on = false
elseif cmd == "help" then
shell.run('CCGlass/ccghelp')
elseif cmd == "easteregg" then
username = "You have found the easter egg that breaks glass. Congratulations on your find!"
else
reprintHome()
end
reprintHome()
end
--now we launch 3rd party and default apps
function launchApps()
tinyClear()
highPrint("Launcher v0.001")
midPrint(" ")
lowPrint("Usage: $$appname")
evt, cmd = os.pullEvent("chat_command")
ok, error = pcall(shell.run("CCGlass/"..cmd.." "))
reprintHome()
end
--now we can reprint the homescreen
function reprintHome()
tinyClear()
highPrint("Welcome, "..username.."!")
midPrint("V0.0001")
lowPrint("Do $$help for help.")
end
--firsttime?
if fs.exists("glassside") == false or newuserdev == true then
getSide()
end
--here comes the advanced print function
function bookprint()
end
--[[begin execution]]
load()
firstDraw()
reprintHome()
while on == true do
homeScreenLaunch()
end
shell.run('clear')