Posted 16 May 2012 - 01:07 AM
Ok, so i am making an application for a factory in a server, and I use one computer to register for a login and another to login. I have the register script down good, but when i try reading and transforming the data into a table. I get an error, i am extremely new to lua and coding. so if you could do a breakdown it would be highly appreciated.
this is the login script… tell me what needs to be done to get it working.
this is my registration code:
i still need to make a few adjustments to the signup code, but if you could tell me how to get this working itd be great… also some advice would be helpful as well. the login and signup computers are connected to the same disk.
this is the login script… tell me what needs to be done to get it working.
term.clear()
term.setCursorPos(12,1)
print(" __________________________")
term.setCursorPos(12,2)
print(" / CLOUDfactory /")
term.setCursorPos(12,3)
print("/ GreasyLogin0.0.5 /")
term.setCursorPos(12,4)
print("--------------------------")
term.setCursorPos(12,5)
print("| |")
term.setCursorPos(12,6)
print("| |")
term.setCursorPos(12,7)
print("| |")
term.setCursorPos(12,8)
print("| |")
term.setCursorPos(12,9)
print("--------------------------")
term.setCursorPos(13,6)
term.write("Login: ")
login = read()
term.setCursorPos(13,7)
term.write("Password: ")
pass = read("*")
time = os.time()
local file = fs.open("disk/users/"..login, "r")
input = file.readAll()
file.close()
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
return fields
end
t = split(input, ",")
rednet.open("bottom")
print(t)
x = 4 --Server ID
if t[1] == login and t[2] == pass then
Print("Welcome, "..user)
print("The time is: "..time)
sleep(1)
rednet.send(x, t.." Entered Factory")
os.shutdown()
else
print(t)
print("Incorrect Username/Password!")
sleep(1)
rednet.send(x, login..": minecraft time: "..time.." denied entry password used: ".. pass)
os.shutdown()
end
this is my registration code:
-- Register Program --
term.clear()
term.setCursorPos(1, 1)
print("__________________________")
term.setCursorPos(1, 2)
print("CloudFactory Regristation")
term.setCursorPos(1, 3)
print("--------------------------")
while true do
term.setCursorPos(12, 5)
term.write("*Username: ")
user = read()
if user == empty then
print("Please enter a username!")
else
break
end
end
term.setCursorPos(12, 6)
term.write("Email: ")
email = read()
while true do
term.setCursorPos(12, 7)
term.clearLine()
term.write("*Password: ")
pass = read("*")
term.setCursorPos(12, 8)
term.clearLine()
term.write("*Re-type Password: ")
pass2 = read("*")
if pass == pass2 then
term.clear()
term.setCursorPos(15, 15)
print("Register Succesful")
break
end
if pass2 == pass then
print("Regristation Succeful!")
else
print("Error: Passwords don't match!")
print("Please re-enter password!")
end
end
function readLines(sPath)
local file = fs.open(sPath, "r")
if file then
local tLines = {}
local sLine = file.readLine()
while sLine do
table.insert(tLines, sLine)
sLine = file.readLine()
end
file.close()
return tLines
end
end
function writeLines(tLines, sPath)
local file = fs.open(sPath, "w")
if file then
for _, line in ipairs(tLines) do
file.writeLine(line)
end
file.close()
end
end
t = user..","..pass..","..email
fs.makeDir("disk/users")
local file = io.open("disk/users/"..user, "w")
file:write(t) -- Write the user's name/pass/email
file:close()
i still need to make a few adjustments to the signup code, but if you could tell me how to get this working itd be great… also some advice would be helpful as well. the login and signup computers are connected to the same disk.