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

question permissions

Started by jumpingjoran, 27 March 2013 - 08:36 PM
jumpingjoran #1
Posted 27 March 2013 - 09:36 PM
Hello!

I want to know if i can make permissions on my login system.
Like admin can do everything so he can edit programs and make them and run them.
A moderator can only make new programs and edit there own programs and run there programs.
And a guest just onnly can run programs.

Im busy with creating a little os ecturly it is a login system but i want to have permissions on it.
Is this posible?

Here is my login system:
Spoiler
 function loading()
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[    Loading    ]")
	sleep(0.5)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[#              ]")
	sleep(0.7)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[###            ]")
	sleep(0.5)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[#####          ]")
	sleep(0.5)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[#######        ]")
	sleep(0.5)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[#########      ]")
	sleep(0.8)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[#############  ]")
	sleep(0.3)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[###############]")
	sleep(0.5)
	term.setCursorPos(17,11)
	term.clearLine()
	print ("[  Loading Done ]")
	sleep(2)
end

function start()
	term.clear()
	term.setCursorPos(1,1)
	print ("              __ |  __ |            Login System  ")
	print ("                ||    ||    _ \\ (_-<             ")
	print ("              __//  __// .\\___/ ___/             ")
	print ("------------------(Version: 2.7)------------------")
	print ("")
end

function welcome()
	term.clear()
	term.setCursorPos(1,1)
	print ("              __ |  __ |   Welcome, "..username.."")
	print ("                ||    ||    _ \\ (_-<             ")
	print ("              __//  __// .\\___/ ___/             ")
	print ("-----------------(Version: 1.2)-------------------")
	print ("")
end

function accountAccepted()
	term.setCursorPos(17,11)
	term.clearLine()
	print ("Account Accepted.")
	sleep(3)
end

function wrongLogin()
	term.setCursorPos(11,11)
	term.clearLine()
	textutils.slowPrint ("Username and/or Password do not match")
end

os.pullEvent = os.pullEventRaw
start()
print ("Login: ")
print ("")

write ("Username: ")
username = read()
write ("Password: ")
password = read ("*")
sleep(1)

-- admin account
if username == "admin" and password == "adminbypass" then    
	loading()
	accountAccepted()
	welcome()

-- jumpingjoran account
elseif username == "jumpingjoran" and password == "kutjoran" then    
	loading()
	accountAccepted()
	welcome()

-- no account whatsoever...
else
    loading()
	wrongLogin()
	sleep(3)
	os.reboot()
end 

Pastebin: http://pastebin.com/RkZrJDef
Also i want to know if you can like there are 3 computers with a modem with just a program that only set rednet on and that i have a computer with rednet and i can control them and send them files without there is a program on that computer.

Thnx for reading :)/>
Doyle3694 #2
Posted 27 March 2013 - 09:55 PM
It is possible, though some knowlege of enviroments and function overwriting is required
jumpingjoran #3
Posted 27 March 2013 - 10:04 PM
Okey but how? :P/>
im not the best coder i just know coding like how i did with my login the simple things
Mads #4
Posted 28 March 2013 - 06:01 AM
Just hook into the default functions.
jag #5
Posted 28 March 2013 - 08:41 AM
Yea! Edit the bios!
remiX #6
Posted 28 March 2013 - 08:54 AM
Surprised no one has commented on the fake loading screen :P/>

You could make your own imitation of the shell and when a command is executed, such as using the edit program on a program, check if they're an admin etc.
jag #7
Posted 28 March 2013 - 09:15 AM
Surprised no one has commented on the fake loading screen :P/>
Lol yea but I do believe I have trained away the interfering anger for that.
Mads #8
Posted 28 March 2013 - 10:05 AM
Btw, get rid of the fake loading screen. They suck.
jumpingjoran #9
Posted 30 March 2013 - 12:58 AM
i know the fake loading screen is fake :P/>
but they are funny!!
i dont know how to make it else… if u want to have it real
Mads #10
Posted 30 March 2013 - 02:22 AM
Well, since you're not actually loading something, you don't need it ;)/>
jumpingjoran #11
Posted 31 March 2013 - 08:53 AM
yeahh thats right but its just awesome to loading :P/> it look likes you're loading the accounts…
i could make a server for it so the computer gets the password from the master pc then it can be loading it for real?

but back to topic:

how do i get premissions… and im playing on a public server so i can't edit something in the files…
MudkipTheEpic #12
Posted 31 March 2013 - 08:57 AM
Look at OSRunner to see how it manages subfolders.

You could have the directory for Guest be .UserFolders/Admin/Guest and admin just be .UserFolders/Admin, so Admin could edit guest but not the other way around.

.OSRunner/APIs/osrunner seems to be what you need.
jumpingjoran #13
Posted 31 March 2013 - 12:17 PM
Thnx! im gonna searching for what i need to have of it!
Im also gonna make a server system so the password is on the server computer and with a big screen u can see who is logging in and in what computer id.
i want to make a register for new people who want to get on the computer if you are creating a new account on a stand-alone computer then u automaticly be a registered as a guest and if u are register in the server u can be made to admin.
and later i want a file share program so u can share your programs with other computers on the same server :)/>

but thats all for later! im first gonna search for the guest and admin code!
Dlcruz129 #14
Posted 31 March 2013 - 07:53 PM
Try using tables for each group, and then check what table the user is in, and give them the necessary permissions.
jumpingjoran #15
Posted 31 March 2013 - 10:18 PM
I get what u are saying but i dont know about tables i need to take a look at that!
I thought i make too os'es the normal one for the admin and a guest one with the premissions?
Or do u know a better way to do this?
Im not realy that good in computercraft but im looking at tutorials on youtube but there are not that much video's
jumpingjoran #16
Posted 31 March 2013 - 10:23 PM
I just got a idea i can make a file were the admins in are so if u want to edit something its checking if ur name is in the list of admins and then u get premission?
But then i need to always have the stand-alone computer always online i think i have a idea again :P/>
im making a offline and a online selection so when its online it connects to the server with premissions but when your offline the normal os is running :D/>
Dlcruz129 #17
Posted 01 April 2013 - 04:36 AM
The best way to learn Lua is:

1. Read the Lua PIL. http://lua.org/pil/contents.html.

2. Read the computercraft wiki for information on rednet. http://computercraft.info/wiki/

YouTube videos will only help you replicate others' work. Learning Lua yourself is more fun. The PIL has a whole chapter on tables, and the wiki has a page on file saving.

Good luck!
jumpingjoran #18
Posted 01 April 2013 - 04:42 AM
THNXX!!!
And gratzz to you! cuz you have posted on me with your 1000 post!
Dlcruz129 #19
Posted 01 April 2013 - 04:45 AM
THNXX!!!
And gratzz to you! cuz you have posted on me with your 1000 post!

No problem.
Thanks!
:P/>