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

[self-made pass-edit] [help] [solved. delete?]

Started by Goof, 07 December 2012 - 08:31 AM
Goof #1
Posted 07 December 2012 - 09:31 AM
Hello :D/>/>


Can anyone tell me why this doesnt work? it doesnt tell me any errors… it actually works fine, if i do not input extra word:

Spoiler> pass
Usage: pass <function>
Functions:
edit
-^- edit the password
>


thats what works fine… but when i type in:

> pass edit – or any other words than edit, then this happens:
Usage: pass <function>
Functions:
edit
-^- edit the password
>

i want, when i type in:

> pass edit
– then it will display this:
Do you want to edit your current password?
Y or N > – i cant come to this part.. before the problem is solved…





no pastebin:
Spoiler


local tArgs = { ... }

local functions = {
"edit",
"-^- Edit your password"
}

local function fRead()
if fs.exists("main/config.cfg") then
fRead1 = fs.open("main/Config.cfg", "r")
fPass = fRead1.readLine()
fRead1.close()
else
print("Error..... opening_error")
sleep(3)
end
end

local function fNew()
fWrite1 = fs.open("main/Config.cfg", "w")
fWrite1.writeLine(nPass2)
fWrite1.writeLine("3.0")
fWrite1.writeLine("0.0")
fWrite1.close()
end


if #tArgs == 0 then
print("Usage: pass <function>")
print("functions:")
for i = 1, #functions do
print(functions[i])
end
return
end

if #tArgs == 1 then
if tArgs[1] == "edit" then
fRead()
print("Do you want to edit your current password?")
write(" Y or N > ")
YN = read()
if YN == "Y" or YN == "y" then
print("Please type your current password: ")
write("> ")
cPass = read("#")
if cPass == fPass then
print("Please type new password: ")
write("> ")
nPass1 = read("¤")
print("Please confirm new password: ")
write("> ")
nPass2 = read("&amp;")
if nPass2 == nPass1 then
fNew()
term.clear()
term.setCursorPos(1,1)
print("Password set...")
print(nPass2)
sleep(5)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Your passwords does not match...")
sleep(2)
term.clear()
term.setCursorPos(1,1)
end
else
print("your input, does not match to the current password!...")
sleep(4)
term.clear()
term.setCursorPos(1,1)
end
end
end
end


pastebin:
Spoilerhttp://pastebin.com/dzwBLak3

Thanks in advance.

PS: This is being used in my AdvLock.. so i really need to get this solved…
____________________
-Mikk809h

ComputerCraft is awesome

Try my Computer lock, called "AdvLock"…

http://www.computercraft.info/forums2/index.php?/topic/6683-advlock-v-13pr1-lock-your-computer-with-advanced-technology-updated/
bjornir90 #2
Posted 07 December 2012 - 09:41 AM
Why there is a return at line 32 ? You call a return outside a function, it's maybe because of that you can't reach the edit part of your program. Also you can use an elseif instead of if on line 35.
Goof #3
Posted 07 December 2012 - 09:45 AM
ehm.. when i edited, to that, i still just got nothing….

code :
http://pastebin.com/Sd56Vacn


still doesnt work.. still just saying

Usage: pass <function>
bjornir90 #4
Posted 07 December 2012 - 10:12 AM
Put an else after the is tArgs == "edit" with a print("You don't type edit") or something like that so you will know if it match or not.
Goof #5
Posted 07 December 2012 - 11:05 AM
This is now solved.. Or actually not, but i just edited it to ask,

> pass

type "edit" to edit the current password

input > edit
– then it works fine, now.
but thanks for the quick response… That was realy apreciated.

thanks
Lyqyd #6
Posted 07 December 2012 - 11:19 AM
In response to the edited topic title, we generally don't delete solved questions, so that others using the search function would be able to find existing answers to their questions.
Goof #7
Posted 07 December 2012 - 11:53 AM
But the code is just "sad" and still not working… But i cannot post full code of AdvLock, because, that would be bad, and then everyone will be able to edit and copy it, and modify it as their own code. but okay. Then the topic will still stay open D:


Thanks

-Mikk809h
Dlcruz129 #8
Posted 07 December 2012 - 01:03 PM
We're not gonna steal your code. Just let us know what the problem is so we can help.
Goof #9
Posted 07 December 2012 - 07:20 PM
But as the topic said, its now solved… I can poste the "pass" program, but not the full code for AdvLock.

i will post pass code ASAP


thanks

-mikk809h
Goof #10
Posted 07 December 2012 - 07:32 PM
the Pass code…


http://pastebin.com/dzwBLak3