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

[1.31+] [v0.01] m0d'z Login API (non-tested) (inf accounts) (admins and guests)

Started by ComputerCraftFan11, 02 May 2012 - 04:05 AM
ComputerCraftFan11 #1
Posted 02 May 2012 - 06:05 AM
This is a API that makes easier logins.
It has not been tested (yet…) so please report bugs here.

function getVersion() --Version of the API
return "v0.01"
end

function makeAdmin(user)
if isAccount(user) == false then return false end

file = fs.open(user.."/.admin", "w")
file:write("true")
file:close()

end

function isAdmin(user)
if isAccount(user) == false then return false end

return fs.exists(user.."/.admin")

end

function isAccount(user) --Returns true if the path given is a account
if fs.exists(user) and fs.isDir(user) then
  if fs.exists(user.."/.pass") then
   return true
  else
   return false
  end
else
  return false
end
end
function newAccount(user, pass) --Creates a account with the specified username and password
if isAccount(user) then
  error("Account already exists!")
end

fs.makeDir(user)
file = fs.open(user.."/.pass", "w")
file:write(pass)
file:close()
end
function isPass(user, pass) --Returns true if "pass" == the real password.
if fs.isAccount(user) then
  passfile = fs.open(user.."/.pass", "r")
  password = passfile:readAll()
  passfile:close()

  if pass == password then
   return true
  else
   return false
  end
else
  return false
end
end
function passRead(user) --Creates a read() function that returns true if you entered the correct password
return isPass(user, read("*"))
end
--	  =======================	  --
--	  =   EXAMPLE PROGRAM   =	  --
--	  =======================	  --
--write("Username: ")
--username = read()
--write("Password: ")
--if passRead(username) then
--  print("lol")
--else
--  print("fail")
--end
Most of the information is in the code above.
digpoe #2
Posted 07 May 2012 - 09:39 AM
nice, but any scripts running this would be able to be terminated, because of read() using os.pullEvent() - so, I'm not sure this will work, but you can try typing at the top:

os.pullEvent() = os.pullEventRaw()
ComputerCraftFan11 #3
Posted 24 May 2012 - 09:40 AM
nice, but any scripts running this would be able to be terminated, because of read() using os.pullEvent() - so, I'm not sure this will work, but you can try typing at the top:

os.pullEvent() = os.pullEventRaw()

That's something the coders do incase they want it to be terminated
Lyqyd #4
Posted 24 May 2012 - 11:11 PM
nice, but any scripts running this would be able to be terminated, because of read() using os.pullEvent() - so, I'm not sure this will work, but you can try typing at the top:

os.pullEvent() = os.pullEventRaw()

That's something the coders do incase they want it to be terminated

Um, no. That's what you do to prevent the terminate event getting thrown and handled, terminating the program.
ComputerCraftFan11 #5
Posted 25 May 2012 - 02:02 AM
nice, but any scripts running this would be able to be terminated, because of read() using os.pullEvent() - so, I'm not sure this will work, but you can try typing at the top:

os.pullEvent() = os.pullEventRaw()

That's something the coders do incase they want it to be terminated

Um, no. That's what you do to prevent the terminate event getting thrown and handled, terminating the program.

I meant the person making the program can remove the terminating them self because some programs allow terminating (since they might not be a lock)
PixelToast #6
Posted 25 May 2012 - 03:07 AM
i dont use os.pullEvent() = os.pullEventRaw() because it messes with read and sleep and stuff so you have to use pcall, but if you use pcall you are already safe from ctrl t
Luanub #7
Posted 25 May 2012 - 03:19 AM
nice, but any scripts running this would be able to be terminated, because of read() using os.pullEvent() - so, I'm not sure this will work, but you can try typing at the top:

os.pullEvent() = os.pullEventRaw()
nice, but any scripts running this would be able to be terminated, because of read() using os.pullEvent() - so, I'm not sure this will work, but you can try typing at the top:

os.pullEvent() = os.pullEventRaw()

That's something the coders do incase they want it to be terminated

Um, no. That's what you do to prevent the terminate event getting thrown and handled, terminating the program.


Putting in a ctrl+t prevention into an API is a waste of time and its probably in the long run going to cause you issues.
You can't terminate an API like you can a program(you unload API's). You would want to put it in the program that you make that uses the API…
PixelToast #8
Posted 25 May 2012 - 03:20 AM
i just edit the bios.lua on my server for ctrl-t prevention
ComputerCraftFan11 #9
Posted 25 May 2012 - 03:21 AM
i just edit the bios.lua on my server for ctrl-t prevention

Then you can't terminate out of anything, and it's easier to infect people with viruses…
PixelToast #10
Posted 25 May 2012 - 03:23 AM
i just edit the bios.lua on my server for ctrl-t prevention

Then you can't terminate out of anything, and it's easier to infect people with viruses…
i think i am fully capable of a thing called modifying an if statement to detect if the user wants to prevent ctrl t or not
ComputerCraftFan11 #11
Posted 25 May 2012 - 04:29 AM
i just edit the bios.lua on my server for ctrl-t prevention

Then you can't terminate out of anything, and it's easier to infect people with viruses…
i think i am fully capable of a thing called modifying an if statement to detect if the user wants to prevent ctrl t or not

What if someone doesn't know how? huh? HUH? HUHUHUUHUH?!??!??!??!?!

Save the n00bs!

you said "server"