Posted 03 August 2013 - 10:10 AM
Title: Edit file from Lua?
I've written a login system, and it works fine. I decided I wanted a receptionists desk, so I uploaded the pastebin, went to the receptionist desk, got the pastebin.
So I decided that when the receptionis logs in, he/she would edit a file, entitled "problem?"
The problem is, that I don't know how to call to edit that file from Lua, or if there is a way.
Here's the code around the area that I want it at:
I'll paste the rest of the code here
I've written a login system, and it works fine. I decided I wanted a receptionists desk, so I uploaded the pastebin, went to the receptionist desk, got the pastebin.
So I decided that when the receptionis logs in, he/she would edit a file, entitled "problem?"
The problem is, that I don't know how to call to edit that file from Lua, or if there is a way.
Here's the code around the area that I want it at:
...
password = read("*")
if password == "(password)" then
write("password accepted")
sleep(2)
-- edit problem?
sleep(1)
os.shutdown()
elseif password == "(masterpassword)" then
...
Everything works fine, I just don't know how to call to edit that file from Lua. I just basically want the user to edit problem? and then have the computer turn of so he/she can't edit startup.I'll paste the rest of the code here
Spoiler
term.clear()
term.setCursorPos(1,1)
os.pullEvent = os.pullEventRaw
term.setTextColor(32)
sleep(1)
print(" #")
print(" # ## # # ######")
print(" # # # # # #")
print(" # # # #### #####")
print(" # ###### # # #")
print(" # # # # # #")
print(" ####### # # # # ######")
sleep(1)
print(" #### #### ##### #####")
print(" # # # # # # # #")
print(" # # # # # # #")
print(" # # # ##### #####")
print(" # # # # # # #")
print(" #### #### # # #") -- btw this is just LakeCorp ASCII
write("Login Now Loading:")
sleep(1)
write("#")
sleep(1)
write("#")
sleep(1)
write("#")
sleep(1)
write("#")
sleep(1)
write("#:")
sleep(2)
print(" ")
print("Loading Complete!")
print("Welcome LakeCorp Receptionist!")
print("Enter Password")
password = read("*")
if password == "(password)" then
write("Password Accepted")
sleep(2)
--edit problem?
sleep(1)
os.reboot
redstone.setOutput ("left",false)
os.shutdown()
elseif password == "(masterpassword)" then
term.clear()
print("Welcome Laketri, you may edit now!")
sleep(1)
else
write("Inorrect Password")
redstone.setOutput ("back",true)
sleep(2)
term.clear()
print(" alert")
sleep(25)
os.shutdown()
end