Posted 21 February 2012 - 09:02 PM
Currently I have this error
The error keeps changing as I changing the code.
But its not changing logically :\
currently it says "os.sleep(4)" is at fault.
[string "disk/startup"]:308: '=' expected
when I try to run my programThe error keeps changing as I changing the code.
But its not changing logically :\
currently it says "os.sleep(4)" is at fault.
Spoiler
-- Keycard installation/Cloning 1.0
-- This has been made by libraryaddict
-- Anyone caught modifying this will be given 0 damns
-- "Damns" is not a item.
-- If you have any suggestions please contact me
function Clone()
Clear()
print("=================================================")
print("| Welcome to LibraryOS Cloning Center |")
print("| |")
print("| |")
print("| Clone to (D)isk or to (C)omputer? |")
print("| |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6,24)
while true do
local e, p = os.pullEvent()
if p == 32 then -- Clone to disk it is
fs.copy("install","/disk/install")
fs.copy("KeyCardStartup","/disk/KeyCardStartup")
Cloned()
break
elseif p == 46 then -- Clone to computer it is
fs.copy("/disk/startup","install")
fs.copy("/disk/KeyCardStartup","KeyCardStartup")
Cloned()
break
end
end
end
function Cloned()
Clear()
print("=================================================")
print("| Welcome to LibraryOS Cloning Center |")
print("| |")
print("| |")
print("| Sucessfully cloned! You may take out |")
print("| the disk or press (E)ject. |")
print("| (T)erminate |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
while true do
local e, p = os.pullEvent()
if p == 18 then -- Eject
disk.eject(diskside)
break
elseif p == 20 then -- Exit
term.setCursorPos(1,1)
break
end
end
end
function Clear()
term.setCursorPos(1,1)
term.clear()
end
function CheckifExists()
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("| |")
print("| |")
print("| Settings already exist |")
print("| |")
print("| Overwrite? Y/N |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6,24)
os.sleep(1)
while true do
local e, p = os.pullEvent()
if p == 21 then
fs.delete("Keycard/Settings")
SetSettings()
break
elseif p == 49 then
CopyFiles()
break
else
term.setCursorPos(1, 7)
print("i Invalid option i")
sleep(0.5)
CheckifExists()
break
end
end
end
function Welcome()
diskside = fs.getDrive("/disk")
if disk.isPresent(diskside) == true then
Clear()
print("=================================================")
print("| Welcome to LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| Do you want to (I)nstall or (C)lone? |")
print("| Press Q to (Q)uit |")
print("| |")
print("| You can also (D)elete keycard files |")
print("| and create new (K)eycards |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(23,7)
while true do
local e, p = os.pullEvent()
if p == 23 then
if fs.exists("Keycard/Settings") == true then
CheckifExists()
break
else
SetSettings()
break
end
elseif p == 46 then -- Close
Clone()
break
elseif p == 32 then -- D for delete
KeycardDeleter()
break
elseif p == 37 then -- K for create! (Spelling never was my strong point)
KeycardMaker()
break
elseif p == 16 then -- Cancel
Clear()
Cancel()
break
end
end
elseif disk.isPresent(diskside) == false then
term.write("Error, Please insert a disk")
end
end
function Cancel()
print("=================================================")
print("| Welcome to LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| Professionally canceled! |")
print("| Take out the disk or press (E)ject. |")
print("| Also (T)erminate |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
while true do
local a, l = os.pullEvent()
if l == 18 then -- Eject
disk.eject(diskside)
break
elseif p == 20 then -- Exit
term.setCursorPos(1,1)
break
end
end
end
function SetSettings()
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| Please choose keycard password |")
print("| |")
print("| You dont need to memorise this |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6, 15)
term.write("Keycard password: ")
CardPass=io.read()
write("Ignore this") -- Get rid of y appearing
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| Please choose the letter to access the |")
print("| |")
print("| the password screen |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6, 15)
os.sleep(1)
while true do
local e, p = os.pullEvent()
if e == "key" then
PasswordLetter = p
break
end
end
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| Please choose your password |")
print("| |")
print("| You need to memorise this! |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6, 15)
write("Password: ")
KeyCardPass=io.read()
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| Choose the face to output |")
print("| The redstone signal. (top, left, back. etc) |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(7, 15)
write("Output face: ")
RedstoneDirection=io.read()
Clear()
diskside = fs.getDrive("/disk")
if disk.isPresent(diskside) then
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| Would you like to label it? |")
print("| |")
print("| (Y)es (N)o |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6,24)
while true do
local e, p = os.pullEvent()
if p == 21 then -- Yes
term.setCursorPos(11, 20)
labelme = io.read()
disk.setLabel(diskside, labelme)
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| You labeled it |")
print("| |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
elseif p == 49 then -- no
break
end
end
if fs.exists("/disk/Keycard") == true then
fs.delete("Keycard/Settings")
end
KeySettings = io.open("/disk/Keycard","w")
KeySettings:write("CardPass = "..[["]]..CardPass..[["]])
KeySettings:close()
end
fs.makeDir("Keycard")
EditKeycard = io.open("Keycard/Settings","w")
EditKeycard:write("KeyCardPass = "..[["]]..KeyCardPass..[["]])
EditKeycard:write("\nRedstoneDirection = "..[["]]..RedstoneDirection..[["]])
EditKeycard:write("\nPasswordLetter = "..PasswordLetter)
EditKeycard:write("\nCardPass = "..[["]]..CardPass..[["]])
EditKeycard:close()
CopyFiles()
end
function CopyFiles()
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| Congrats! You have installed it! |")
print("| |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
if fs.exists("startup") == true then
fs.delete("startup")
end
fs.copy("/disk/KeyCardStartup","startup")
fs.copy
os.sleep(4)
os.reboot()
end
function KeycardMaker
if fs.exists("Keycard/Password") == false then
if fs.exists("/disk/keycard") == false then
clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| Please insert a valid keycard |")
print("| Press any button to quit |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
sleep(1)
while true do
local e, p = os.pullEvent()
if e == "key" then
break
end
end
elseif fs.exists("/disk/keycard") == true then
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| Would you like to make a new Keycard |")
print("| data file on the computer? |")
print("| (Y)es (N)o |")
print("| |")
print("| [Needed for new keycards] |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
sleep(1)
while true do
local e, p = os.pullEvent()
if p == 21 then -- Yes
fs.copy("/disk/keycard","Keycard/Password")
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| The datafile has been made |")
print("| You can now manufature keycards |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
elseif p == 49 then -- no
break
end
end
end
elseif fs.exists("Keycard/Password") == true then
if fs.exists("/disk/keycard") == false then
clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| Would you like to make a new Keycard? |")
print("| |")
print("| (Y)es (N)o |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
sleep(1)
while true do
local e, p = os.pullEvent()
if p == 21 then -- Yes
fs.copy("Keycard/Password","/disk/keycard")
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| You just made a new keycard! |")
print("| Would you like to label it? |")
print("| (Y)es (N)o |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6,24)
while true do
local e, p = os.pullEvent()
if p == 21 then -- Yes
term.setCursorPos(11, 20)
labelme = io.read()
disk.setLabel(diskside, labelme)
print("Now labeled as "..[["]]..labelme..[["]]..)
break
elseif p == 49 then -- no
break
end
end
break
elseif p == 49 then -- no
break
end
end
elseif fs.exists("/disk/keycard") == true then
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| |")
print("| You need to delete a keycode! |")
print("| Press any button to quit |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
sleep(1)
while true do
local e, p = os.pullEvent()
if e == "key" then
break
end
end
end
end
end
function KeycardDeleter
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| Do you want to delete computer Keycard or |")
print("| floppy keycard? |")
print("| (C)omputer (F)loppy |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
term.setCursorPos(6,24)
while true do
local e, p = os.pullEvent()
if p == 46 then -- GET THE CODE - Computer
if fs.exists("/disk/keycard") == true then
fs.delete("/disk/keycard")
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| Keycard on the floppy has been deleted |")
print("| |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
elseif fs.exists("/disk/keycard") == false then
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| File not found |")
print("| |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
end
elseif p == 33 then -- GET THE CODE - Floppy
if fs.exists("Keycard/Password") == true then
fs.delete("Keycard/Password")
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| Keycard on the computer has been deleted |")
print("| |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
elseif fs.exists("Keycard/Password") == false then
Clear()
print("=================================================")
print("| LibraryOS Keycard Lock 1.0 |")
print("=================================================")
print("| |")
print("| File not found |")
print("| |")
print("| |")
print("| |")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
break
end
end
end
end
Welcome()