This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
xxangel17xx's profile picture

Help with code Error/fs.copy,fs.delete

Started by xxangel17xx, 17 July 2012 - 09:37 AM
xxangel17xx #1
Posted 17 July 2012 - 11:37 AM
HI i have been working on a admin lock to lock users consols
here is my code
Spoiler

fs.delete("startup")
fs.copy("disk/startup", "startup")
os.pullEvent = os.pullEventRaw
local side = "right"
local password1 = "********"
local password2 = "********"
local password3 = "********"
local password4 = "********"
local passwordadmin = "********"
term.clear()
sleep(1)
print("Admin console Lock Loading...")
sleep(2)
print("Your console has been locked by an admin")
sleep(1)
print("Please contact an admin to have it unlocked.")
sleep(2)
print("Admin please enter the unlock code.")
write("Code: ")
local input = read("*")
if input == password1 then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
print("Computer unlocking...")
print("To remove this lock please edit startup and delete the code")
os.pullEvent(terminate)
end
if input == password2 then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
print("Computer unlocking...")
print("To remove this lock please edit startup and delete the code")
os.pullEvent(terminate)
end
if input == password3 then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
print("Computer unlocking...")
print("To remove this lock please edit startup and delete the code")
os.pullEvent(terminate)
end
if input == password4 then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
print("Computer unlocking...")
print("To remove this lock please edit startup and delete the code")
os.pullEvent(terminate)
end
if input == passwordadmin then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
print("Computer unlocking...")
print("To remove this lock please edit startup and delete the code")
os.pullEvent(terminate)
else
term.clear()
term.setCursorPos(1,1)
print("Password incorrect User please donot try to bypass this Block!")
sleep(2)
os.shutdown()
end
when inserting floppy in to the drive it works but when i remove the floppy and rebooting the computer it says startup:2: no such file
when it should have copyed the startup from the floppy to the computer
am i doing somthing wrong?
maybe with the fs.delete & fs.copy?

Note:most of this code came from
KillerOfPie,s multi-password door lock+admin


Any help is greatly appreciated thanks
-Angel

Come take a look at it for your self on my server
ip:craftreborn.mchost.org
1lann #2
Posted 17 July 2012 - 12:06 PM
at line 2

fs.copy("disk/startup", "startup")
There is no disk inserted so it'll throw an error. What you should do is make another version without fs.copy("disk/startup", "startup") and copy that over to the computer
xxangel17xx #3
Posted 17 July 2012 - 01:01 PM
i was hoping to have it so you just insert the floppy disk drive and reboot the computer then you can remove the floppy and it is still on the computer dose any one know of a function or bit of code that can do that?
Lyqyd #4
Posted 17 July 2012 - 09:40 PM
Just have the floppy copy over another version of the startup file that doesn't have that line in it. It's the same thing, it'll just take you thirty seconds to make.
Exerro #5
Posted 18 July 2012 - 08:25 PM
put this in your code…
if fs.exists("disk/startup") then
–the code to copy the file
else
–the lock code
end