Posted 21 April 2016 - 01:50 AM
Hey guys. I am currently working on a startup called "SecureStart".
I have been researching ways to be able to block disk drives/disks from overriding the current startup file, but sadly have found nothing.
I want to try and keep the code as small as possible. I have heard that it can only be done by editing the files in the computercraft.zip file, but that is something I don't want to do.
I have seen one particular post the shows the code in the zip file so I copied it and rewrote it..
The copied code is under secureStart().
After trying to run this it did not work so I am stuck unless someone knows a cunning way around it.
Here is the code:
os.pullEvent = os.pullEventRaw
function secureStart()
for n,sSide in pairs(redstone.getsides()) do
if disk.isPresent(sSide) and disk.hasData(sSide)
then
fs.delete(disk.getMountPath(sSide))
end
end
end
function clearSCR() – Clears screen
term.clear()
term.setCursorPos(1,1)
end
function textColour()
term.setTextColor(colors.yellow)
end
function Pass() – Sets password variable
password = "TheBlackPlaguE2017*"
end
function askPass() – Asks for password
textutils.slowWrite("Please enter the password: ")
end
function receivePass() – Reads for input
username = "TheWhiteKhan"
greet = "Welcome, "
welcome = greet..username
input = read("*")
if input == password then
clearSCR()
term.setTextColor(colors.green)
textutils.slowPrint("Login Successful")
sleep(0.5)
clearSCR()
term.setTextColor(colors.orange)
textutils.slowPrint(welcome)
sleep(0.5)
else
clearSCR()
term.setTextColor(colors.red)
textutils.slowPrint("Login Insuccessful")
sleep(0.5)
clearSCR()
textutils.slowPrint("Shutting down")
sleep(1)
os.shutdown()
end
end
——————PROGRAM BEGINS——————
secureStart()
clearSCR()
textColour()
Pass()
askPass()
receivePass()
clearSCR()
I have been researching ways to be able to block disk drives/disks from overriding the current startup file, but sadly have found nothing.
I want to try and keep the code as small as possible. I have heard that it can only be done by editing the files in the computercraft.zip file, but that is something I don't want to do.
I have seen one particular post the shows the code in the zip file so I copied it and rewrote it..
The copied code is under secureStart().
After trying to run this it did not work so I am stuck unless someone knows a cunning way around it.
Here is the code:
Spoiler
——————SecureStart 1.1—————–os.pullEvent = os.pullEventRaw
function secureStart()
for n,sSide in pairs(redstone.getsides()) do
if disk.isPresent(sSide) and disk.hasData(sSide)
then
fs.delete(disk.getMountPath(sSide))
end
end
end
function clearSCR() – Clears screen
term.clear()
term.setCursorPos(1,1)
end
function textColour()
term.setTextColor(colors.yellow)
end
function Pass() – Sets password variable
password = "TheBlackPlaguE2017*"
end
function askPass() – Asks for password
textutils.slowWrite("Please enter the password: ")
end
function receivePass() – Reads for input
username = "TheWhiteKhan"
greet = "Welcome, "
welcome = greet..username
input = read("*")
if input == password then
clearSCR()
term.setTextColor(colors.green)
textutils.slowPrint("Login Successful")
sleep(0.5)
clearSCR()
term.setTextColor(colors.orange)
textutils.slowPrint(welcome)
sleep(0.5)
else
clearSCR()
term.setTextColor(colors.red)
textutils.slowPrint("Login Insuccessful")
sleep(0.5)
clearSCR()
textutils.slowPrint("Shutting down")
sleep(1)
os.shutdown()
end
end
——————PROGRAM BEGINS——————
secureStart()
clearSCR()
textColour()
Pass()
askPass()
receivePass()
clearSCR()