Posted 29 July 2014 - 12:40 PM
I got a problem with my OS it keeps saying main.lua 10 attempt to index ? (a nil value)
The whole OS starts like so:
first the startup:
fs.delete("src/advanced")
end
shell.run("pastebin get 8dKmgJzM dl.tmp")
if fs.exists("dl.tmp") then
fs.delete("dl.tmp")
x = 1
else
x = 0
end
if x == 1 then
fs.delete("startup")
shell.run("pastebin get HmZbq89u startup")
end
if x == 1 then
if fs.exists("src/cAPI") then
fs.delete("src/cAPI")
end
shell.run("pastebin get ea9LncrA src/cAPI")
end
if x == 1 and fs.exists("timosdls") then
fs.delete("timosdls")
shell.run("pastebin get YewJFgvW tstore")
end
if fs.exists("src/ver11") then
sleep(0,2)
elseif x == 1 then
shell.run("pastebin get Jm8Y1MZH src/ver11")
end
if x == 1 then
fs.delete("tstore")
shell.run("pastebin get YewJFgvW tstore")
end
if fs.exists("src/dllt") then
fs.delete("src/dllt")
end
if fs.exists("src/dlth") then
fs.delete("src/dlth")
end
if x == 1 then
shell.run("pastebin get 71GxxQMg src/dllt")
shell.run("pastebin get 5xCJPz5v src/dlth")
end
if x == 1 and fs.exists("cardtania") then
fs.delete("cardtania")
shell.run("pastebin get gxQ1PdBD cardtania")
end
if not fs.exists("src/animatecraft/v2") then
if fs.exists("animatecraft") then
fs.delete("animatecraft")
fs.delete("src/animatecraft/new")
fs.delete("src/animatecraft/edit")
fs.delete("src/animatecraft/player")
fs.delete("src/animatecraft/reimg")
shell.run("pastebin run JD12pdFM")
shell.run("mkdir src/animatecraft/v2")
end
end
shell.run("clear")
print("CraftOS")
print(" ")
if fs.exists("src/TOS") then
shell.run("pastebin get jFLvG79m stupRAW")
if fs.exists("stupRAW") then
fs.delete("TOSstartup")
fs.copy("stupRAW", "TOSstartup")
fs.delete("stupRAW")
end
print("BIOS update complete")
shell.run("TOSstartup")
end (This file updates everything)
second the TOSstartup:
if fs.exists("mainRAW") then
fs.delete("src/TOS/main.lua")
fs.copy("mainRAW", "src/TOS/main.lua")
fs.delete("mainRAW")
end
if fs.exists("src/TOS/ink") and not fs.exists("src/TOS/programs/ink") then
fs.move("src/TOS/ink", "src/TOS/programs/ink")
end
if fs.exists("mplayer") and not fs.exists("src/TOS/programs/mplayer") then
fs.move("mplayer", "src/TOS/programs/mplayer")
end
if not fs.exists("src/TOS/programs") then
shell.run("mkdir src/TOS/programs")
end
if not fs.exists("mplayer") then
shell.run("pastebin get 4JehP0i3 mplayer")
end
if not fs.exists("src/TOS/ink") then
shell.run("pastebin get JxzXPv03 src/TOS/ink")
end
if fs.exists("src/TOS/BG.img") then
fs.delete("src/TOS/BG.img")
end
if not fs.exists("cardtania") then
shell.run("pastebin run 08mhZzbV")
end
print("OS update complete")
sleep(2)
function login()
write("username: ")
uname = read()
if fs.exists("src/users/"..uname) then
write("password: ")
pw = read("*")
if fs.exists("src/users/"..uname.."/"..pw) then
print("access granted")
else
os.reboot()
end
else
os.reboot()
end
end
function create()
write("username: ")
uname = read()
if not fs.exists("src/users/"..uname) then
write("password: ")
pw = read("*")
shell.run("mkdir src/users/"..uname.."/"..pw)
else
print("user already exists")
end
end
shell.run("clear")
os.loadAPI("src/cAPI")
dBoot = cAPI.menu("boot in CraftOS", "boot in TOS")
if dBoot == 1 then error() end
shell.run("clear")
if term.isColor() then
term.setBackgroundColor(colors.blue)
term.setTextColor(colors.lightGray)
end
shell.run("clear")
print("WELCOME!")
print(" ")
print(" ")
print(" press any key to login")
os.pullEvent("key")
shell.run("clear")
mPos = cAPI.menu("login", "create account")
if mPos == 1 then
login()
else
create()
end
shell.run("clear")
shell.run("src/TOS/main.lua "..uname.." "..pw) (This updates th OS and is used for multiboot and login)
and third the main.lua:
uname = tArgs[1]
pw = tArgs[2]
function loadOptions(…)
arg = {…}
file = fs.open("src/users/"..arg[1].."/"..arg[2].."/settings", "r")
data = file.readAll()
file.close()
settings = textutils.unserialize(data)
bg = settings[1]
tx = settings[2]
end
function editOptions(…)
arg = {…}
fs.delete("src/users/"..arg[1].."/"..arg[2].."/settings")
shell.run("clear")
print("background: ")
print("aviable colors: ")
print("white, orange, magenta, lightBlue, yellow, lime, pink, gray,")
print("lightGray, cyan, purple, blue, brown, green, red, black")
print(" ")
write("your choose: ")
cho = read()
bg = "colors."..cho
shell.run("clear")
print("Text: ")
print("aviable colors: ")
print("white, orange, magenta, lightBlue, yellow, lime, pink, gray,")
print("lightGray, cyan, purple, blue, brown, green, red, black")
print(" ")
write("your choose: ")
cho = read()
tx = "colors."..cho
settings = {bg, tx}
file = fs.open("src/users/"..arg[1].."/"..arg[2].."/settings", "w")
file.writeLine(textutils.serialize(settings))
file.close()
shell.run("clear")
end
sleep(1)
shell.run("clear")
os.loadAPI("src/cAPI")
if fs.exists("src/users/"..uname.."/"..pw.."/settings") then
loadOptions(uname, pw)
else
bg = colors.blue
tx = colors.lightGray
end
function games()
mPos = cAPI.menu("Worm", "cardtania")
if mPos == 1 then
if term.isColor() then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
end
shell.run("clear")
shell.run("worm")
else
shell.run("cardtania")
end
end
function programlist()
shell.run("clear")
allprogs = fs.list("src/TOS/programs")
print("installed programs: ")
x = 1
while true do
if allprogs[x] == nil then break end
print(allprogs[x])
x = x + 1
end
write("please enter the program that you want to run: ")
torun = read()
shell.run("src/TOS/programs/"..torun)
end
while true do
if term.isColor() then
term.setBackgroundColor(bg)
term.setTextColor(tx)
end
shell.run("clear")
mPos = cAPI.menu("tstore", "explorer", "programs", "Games", "shutdown", "reboot", "CraftOS", "settings")
shell.run("clear")
if mPos == 1 then
shell.run("tstore")
elseif mPos == 2 then
shell.run("src/TOS/icebrowser")
elseif mPos == 5 then
os.shutdown()
elseif mPos == 6 then
os.reboot()
elseif mPos == 7 then
if term.isColor() then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
end
shell.run("clear")
error()
elseif mPos == 8 then
shell.run("clear")
editOptions(uname,pw)
shell.run("clear")
elseif mPos == 4 then
games()
elseif mPos == 3 then
programlist()
end
end(This is the main OS) This is the program what is not working yet
Please Help Me!!
The whole OS starts like so:
first the startup:
Spoiler
if fs.exists("src/advanced") thenfs.delete("src/advanced")
end
shell.run("pastebin get 8dKmgJzM dl.tmp")
if fs.exists("dl.tmp") then
fs.delete("dl.tmp")
x = 1
else
x = 0
end
if x == 1 then
fs.delete("startup")
shell.run("pastebin get HmZbq89u startup")
end
if x == 1 then
if fs.exists("src/cAPI") then
fs.delete("src/cAPI")
end
shell.run("pastebin get ea9LncrA src/cAPI")
end
if x == 1 and fs.exists("timosdls") then
fs.delete("timosdls")
shell.run("pastebin get YewJFgvW tstore")
end
if fs.exists("src/ver11") then
sleep(0,2)
elseif x == 1 then
shell.run("pastebin get Jm8Y1MZH src/ver11")
end
if x == 1 then
fs.delete("tstore")
shell.run("pastebin get YewJFgvW tstore")
end
if fs.exists("src/dllt") then
fs.delete("src/dllt")
end
if fs.exists("src/dlth") then
fs.delete("src/dlth")
end
if x == 1 then
shell.run("pastebin get 71GxxQMg src/dllt")
shell.run("pastebin get 5xCJPz5v src/dlth")
end
if x == 1 and fs.exists("cardtania") then
fs.delete("cardtania")
shell.run("pastebin get gxQ1PdBD cardtania")
end
if not fs.exists("src/animatecraft/v2") then
if fs.exists("animatecraft") then
fs.delete("animatecraft")
fs.delete("src/animatecraft/new")
fs.delete("src/animatecraft/edit")
fs.delete("src/animatecraft/player")
fs.delete("src/animatecraft/reimg")
shell.run("pastebin run JD12pdFM")
shell.run("mkdir src/animatecraft/v2")
end
end
shell.run("clear")
print("CraftOS")
print(" ")
if fs.exists("src/TOS") then
shell.run("pastebin get jFLvG79m stupRAW")
if fs.exists("stupRAW") then
fs.delete("TOSstartup")
fs.copy("stupRAW", "TOSstartup")
fs.delete("stupRAW")
end
print("BIOS update complete")
shell.run("TOSstartup")
end
second the TOSstartup:
Spoiler
shell.run("pastebin get 1S3EPhMg mainRAW")if fs.exists("mainRAW") then
fs.delete("src/TOS/main.lua")
fs.copy("mainRAW", "src/TOS/main.lua")
fs.delete("mainRAW")
end
if fs.exists("src/TOS/ink") and not fs.exists("src/TOS/programs/ink") then
fs.move("src/TOS/ink", "src/TOS/programs/ink")
end
if fs.exists("mplayer") and not fs.exists("src/TOS/programs/mplayer") then
fs.move("mplayer", "src/TOS/programs/mplayer")
end
if not fs.exists("src/TOS/programs") then
shell.run("mkdir src/TOS/programs")
end
if not fs.exists("mplayer") then
shell.run("pastebin get 4JehP0i3 mplayer")
end
if not fs.exists("src/TOS/ink") then
shell.run("pastebin get JxzXPv03 src/TOS/ink")
end
if fs.exists("src/TOS/BG.img") then
fs.delete("src/TOS/BG.img")
end
if not fs.exists("cardtania") then
shell.run("pastebin run 08mhZzbV")
end
print("OS update complete")
sleep(2)
function login()
write("username: ")
uname = read()
if fs.exists("src/users/"..uname) then
write("password: ")
pw = read("*")
if fs.exists("src/users/"..uname.."/"..pw) then
print("access granted")
else
os.reboot()
end
else
os.reboot()
end
end
function create()
write("username: ")
uname = read()
if not fs.exists("src/users/"..uname) then
write("password: ")
pw = read("*")
shell.run("mkdir src/users/"..uname.."/"..pw)
else
print("user already exists")
end
end
shell.run("clear")
os.loadAPI("src/cAPI")
dBoot = cAPI.menu("boot in CraftOS", "boot in TOS")
if dBoot == 1 then error() end
shell.run("clear")
if term.isColor() then
term.setBackgroundColor(colors.blue)
term.setTextColor(colors.lightGray)
end
shell.run("clear")
print("WELCOME!")
print(" ")
print(" ")
print(" press any key to login")
os.pullEvent("key")
shell.run("clear")
mPos = cAPI.menu("login", "create account")
if mPos == 1 then
login()
else
create()
end
shell.run("clear")
shell.run("src/TOS/main.lua "..uname.." "..pw)
and third the main.lua:
Spoiler
tArgs = {…}uname = tArgs[1]
pw = tArgs[2]
function loadOptions(…)
arg = {…}
file = fs.open("src/users/"..arg[1].."/"..arg[2].."/settings", "r")
data = file.readAll()
file.close()
settings = textutils.unserialize(data)
bg = settings[1]
tx = settings[2]
end
function editOptions(…)
arg = {…}
fs.delete("src/users/"..arg[1].."/"..arg[2].."/settings")
shell.run("clear")
print("background: ")
print("aviable colors: ")
print("white, orange, magenta, lightBlue, yellow, lime, pink, gray,")
print("lightGray, cyan, purple, blue, brown, green, red, black")
print(" ")
write("your choose: ")
cho = read()
bg = "colors."..cho
shell.run("clear")
print("Text: ")
print("aviable colors: ")
print("white, orange, magenta, lightBlue, yellow, lime, pink, gray,")
print("lightGray, cyan, purple, blue, brown, green, red, black")
print(" ")
write("your choose: ")
cho = read()
tx = "colors."..cho
settings = {bg, tx}
file = fs.open("src/users/"..arg[1].."/"..arg[2].."/settings", "w")
file.writeLine(textutils.serialize(settings))
file.close()
shell.run("clear")
end
sleep(1)
shell.run("clear")
os.loadAPI("src/cAPI")
if fs.exists("src/users/"..uname.."/"..pw.."/settings") then
loadOptions(uname, pw)
else
bg = colors.blue
tx = colors.lightGray
end
function games()
mPos = cAPI.menu("Worm", "cardtania")
if mPos == 1 then
if term.isColor() then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
end
shell.run("clear")
shell.run("worm")
else
shell.run("cardtania")
end
end
function programlist()
shell.run("clear")
allprogs = fs.list("src/TOS/programs")
print("installed programs: ")
x = 1
while true do
if allprogs[x] == nil then break end
print(allprogs[x])
x = x + 1
end
write("please enter the program that you want to run: ")
torun = read()
shell.run("src/TOS/programs/"..torun)
end
while true do
if term.isColor() then
term.setBackgroundColor(bg)
term.setTextColor(tx)
end
shell.run("clear")
mPos = cAPI.menu("tstore", "explorer", "programs", "Games", "shutdown", "reboot", "CraftOS", "settings")
shell.run("clear")
if mPos == 1 then
shell.run("tstore")
elseif mPos == 2 then
shell.run("src/TOS/icebrowser")
elseif mPos == 5 then
os.shutdown()
elseif mPos == 6 then
os.reboot()
elseif mPos == 7 then
if term.isColor() then
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
end
shell.run("clear")
error()
elseif mPos == 8 then
shell.run("clear")
editOptions(uname,pw)
shell.run("clear")
elseif mPos == 4 then
games()
elseif mPos == 3 then
programlist()
end
end
Please Help Me!!