145 posts
Location
the vast cosmos of my mind; binary!
Posted 19 December 2012 - 05:31 PM
i need halp with getting the program to operate properly if you run it in the current version of tekkit yeah I KNOW i feel the same about tekkit bleagh! *makeing noise in disgust* but here is the coding and i am sorry for no comments :(/>
I MADE THE NUMBER ONE! MISTAKE IN PROGRAMMING! not commenting I SCREWED UP!
here it is:
function keycardcheck()
while true do
if disk.isPresent("bottom") == true then
disk.getLabel("bottom")
if disk.getLabel("bottom") == "MOJO" then
redstone.setOutput("left", true)
sleep(2)
redstone.setOutput("left", false)
sleep(1)
disk.eject("bottom")
os.reboot()
elseif disk.isPresent("bottom") == false then return false
end
end
end
end
function passcheck()
print "what is the password? or do you have a keycard if you have a keycard insert it by holding shift and right cliking on the dick drive"
term.setCursorPos(1,5)
pass = io.read()
if pass == "gurefepicness" or disk.getLabel("bottom") == "MOJO" then
disk.eject("bottom")
print "WELCOME CONNOR/GUREKAM74"
sleep(1)
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
os.reboot()
elseif pass ~= "gurefepicness" then
print "YOU ARE NOT GUREKAM74 OR CMUR1!"
sleep(1)
print "FUCK OFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF!!!!!!!"
sleep(3)
disk.eject("bottom")
os.reboot()
elseif pass == "mojocmur1" or disk.getLabel("bottom") == "mojocmur1" then
print "welcome cmur1 to the admin panel"
print "would you like to create a new keycard"
usr = io.read()
if usr == "yes" then
print "what should the label be?"
label = io.read()
disk.setLabel("bottom", label)
print "succsessful"
sleep(2)
disk.eject("bottom")
sleep(1)
print "bye bye"
sleep(2)
os.reboot()
end
end
end
parallel.waitForAny(keycardcheck, passcheck)
I don't know how to explain the error or problem cause I don't know what is going on so don't ask me what the problem is I DON'T KNOW!
PS please excuse me for my language in the programming itself sorry if i offended anybody :)/>
145 posts
Location
the vast cosmos of my mind; binary!
Posted 19 December 2012 - 05:52 PM
PLEASE SOMEONE HELP
145 posts
Location
the vast cosmos of my mind; binary!
Posted 19 December 2012 - 05:57 PM
HELP!
145 posts
Location
the vast cosmos of my mind; binary!
Posted 19 December 2012 - 05:59 PM
ok i tryied working on figureing it out and still no luck :(/>
11 posts
Posted 19 December 2012 - 06:51 PM
For the love of God, POST YOUR ERROR MESSAGE!
145 posts
Location
the vast cosmos of my mind; binary!
Posted 19 December 2012 - 07:15 PM
ok here is what i think is going on
1. i can't get password information from the user and see if there is a floppy disk in the disk drive and that matches the label
2. i can't get the admin portion to work it just ignores it
3. whenever i run it it will say "parallel:22: :4: too long without yeilding" and i know this means it hasn't returned
there is a list of issues
212 posts
Location
Leeds, England
Posted 19 December 2012 - 07:22 PM
Here you go, a working code… nicely commented and indented so you dont get lost
function keycardcheck() -- Check for Keycard
while true do
sleep(0)
if disk.isPresent("bottom") then
disk.getLabel("bottom")
if disk.getLabel("bottom") == "MOJO" then
redstone.setOutput("left", true)
sleep(2)
redstone.setOutput("left", false)
sleep(1)
disk.eject("bottom")
os.reboot()
elseif not disk.isPresent("bottom") then
return false
end
end
end
end
function passcheck() --Checks for passcode
while true do
term.clear() --clears the terminal
term.setCursorPos(1,1) -- resets the cursor position for writing
print "what is the password? or do you have a keycard if you have a keycard insert it by holding shift and right cliking on the dick drive"
term.setCursorPos(1,5)
pass = read("*")
if pass == "gurefepicness" or disk.getLabel("bottom") == "MOJO" then --Checks Connors passcode
disk.eject("bottom")
print "WELCOME CONNOR/GUREKAM74"
sleep(1)
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
os.reboot()
elseif pass == "mojocmur1" or disk.getLabel("bottom") == "mojocmur1" then -- checks cmur1 s passcode
print "welcome cmur1 to the admin panel"
print "would you like to create a new keycard"
usr = io.read()
if usr == "yes" then
print "what should the label be?"
label = io.read()
disk.setLabel("bottom", label)
print "succsessful"
sleep(2)
disk.eject("bottom")
sleep(1)
print "bye bye"
sleep(2)
os.reboot()
end
else --Denies access and insults on incorrect passcode
print "YOU ARE NOT GUREKAM74 OR CMUR1!"
sleep(1)
print "FUCK OFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF!!!!!!!"
sleep(3)
disk.eject("bottom")
os.reboot()
end
end
end
parallel.waitForAny(keycardcheck, passcheck)
So many errors were in here but they were easy to miss
145 posts
Location
the vast cosmos of my mind; binary!
Posted 19 December 2012 - 07:27 PM
i would've "UPED YOU" but i reached my qouta
BUT thanks!
212 posts
Location
Leeds, England
Posted 19 December 2012 - 07:28 PM
i would've "UPED YOU" but i reached my qouta
BUT thanks!
haha no worries, if you have any other issues with the code let me know and ill take another look at it
145 posts
Location
the vast cosmos of my mind; binary!
Posted 20 December 2012 - 09:29 AM
ok thanks :)/>
145 posts
Location
the vast cosmos of my mind; binary!
Posted 20 December 2012 - 10:17 AM
ok i made a adjustment i need it to see if there is a disk in the disk drive before it can label it in the admin panel
here is the coding
function keycardcheck() -- Check for Keycard
while true do
sleep(0)
if disk.isPresent("bottom") then
disk.getLabel("bottom")
if disk.getLabel("bottom") == "MOJO" then
redstone.setOutput("left", true)
sleep(2)
redstone.setOutput("left", false)
sleep(1)
disk.eject("bottom")
os.reboot()
elseif not disk.isPresent("bottom") then
return false
end
end
end
end
function passcheck() --Checks for passcode
while true do
term.clear() --clears the terminal
term.setCursorPos(1,1) -- resets the cursor position for writing
print "what is the password? or do you have a keycard if you have a keycard insert it by holding shift and right cliking on the dick drive"
term.setCursorPos(1,5)
pass = read("*")
if pass == "gureepicness" or disk.getLabel("bottom") == "MOJO" then --Checks Connors passcode
disk.eject("bottom")
print "WELCOME CONNOR/GUREKAM74"
sleep(1)
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
os.reboot()
elseif pass == "mojocmur1" or disk.getLabel("bottom") == "mojocmur1" then -- checks cmur1 s passcode
print "welcome cmur1 to the admin panel"
print "would you like to create a new keycard"
usr = io.read()
if usr == "yes" then
print "what should the label be?"
label = io.read()
disk.setLabel("bottom", label)
if disk.isPresent("bottom") == false then
print "insuccsessful!"
print "please insert a disk into the disk drive"
while false do
disk.isPresent("bottom")
if disk.isPresent("bottom") == true then
return true
elseif disk.isPresent("bottom") == false then
return false
end
end
end
print "succsessful"
sleep(2)
disk.eject("bottom")
sleep(1)
print "bye bye"
sleep(2)
os.reboot()
end
else --Denies access and insults on incorrect passcode
print "YOU ARE NOT GUREKAM74 OR CMUR1!"
sleep(1)
print "FUCK OFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF!!!!!!!"
sleep(3)
disk.eject("bottom")
os.reboot()
end
end
end
parallel.waitForAny(keycardcheck, passcheck)
145 posts
Location
the vast cosmos of my mind; binary!
Posted 20 December 2012 - 10:21 AM
oh and i need it to be when i register a key card it is then added to the list of passwords/accses cards
79 posts
Posted 20 December 2012 - 11:39 AM
well cmur I suggest going to the wiki and learning up on fs.open. Here is some idea of what it will look like later:
BTW this is just an ameteur's idea, I suggest checking with others b4 taking my opinion XD
Bare in mind this might just write to the end of the file…im not really sure…
pass = fs.open("startup", "a") --This opens the file and let's you keep what was originally in it.
pass.writeLine("elseif pass == "gureepicness" or disk.getLabel("bottom") == "MOJO" then ")
pass.writeLine("disk.eject("bottom")")
pass.writeLine("print "WELCOME CONNOR/GUREKAM74")")
pass.writeLine("sleep(1)")
pass.writeLine("redstone.setOutput("left", true)")
pass.writeLine("sleep(3)")
pass.writeLine("redstone.setOutput("left", false)")
pass.writeLine("os.reboot()")
145 posts
Location
the vast cosmos of my mind; binary!
Posted 20 December 2012 - 11:48 AM
ok but i need it to be where you can't terminate the program help !
212 posts
Location
Leeds, England
Posted 21 December 2012 - 04:27 PM
oh and i need it to be when i register a key card it is then added to the list of passwords/accses cards
Try this: you will need to make the key cards again though but your passwords are safe
Spoiler
function getTable(path) --Opens file in a table
if fs.exists(path) then
local file = io.open(path, "r")
local lines = {}
local i = 1
local line = file:read("*l")
while line ~= nil do
lines[i] = line
line = file:read("*l")
i = i + 1
end
file:close()
return lines
end
return {}
end
function fwrite(path, text) --rewrites contents of a file
local file = assert(io.open(path, "w"))
file:write(text)
file:close()
end
function fwriteFromTable(path, t) --Writes table to file
local text = ""
for _, line in pairs(t) do
text = text..line.."\n"
end
fwrite(path, text)
end
local keycardList = getTable("cards")
local passwordsList = getTable("passwords")
function keycardcheck() -- Check for Keycard
while true do
sleep(0)
if disk.isPresent("bottom") then
local diskLabel = disk.getLabel("bottom")
for i,v in ipairs(keycardList) do
if diskLabel == v then
redstone.setOutput("left", true)
sleep(2)
redstone.setOutput("left", false)
sleep(1)
disk.eject("bottom")
os.reboot()
end
end
end
end
end
function passcheck() --Checks for passcode
while true do
term.clear() --clears the terminal
term.setCursorPos(1,1) -- resets the cursor position for writing
print "what is the password? or do you have a keycard if you have a keycard insert it by holding shift and right cliking on the dick drive"
term.setCursorPos(1,5)
pass = read("*")
for i,v in ipairs(passwordsList) do
if pass == v then
print ("WELCOME "..pass)
sleep(1)
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
os.reboot()
else
if pass == "gureepicness" then --Checks Connors passcode
print "WELCOME CONNOR/GUREKAM74"
sleep(1)
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
os.reboot()
elseif pass == "mojocmur1" then -- checks cmur1 s passcode
print "welcome cmur1 to the admin panel"
print "would you like to create a new keycard"
usr = io.read()
if usr == "yes" then
print "what should the label be?"
label = io.read()
while true do
sleep(0)
if not disk.isPresent("bottom") then
term.setCursorPos(1,11)
print "please insert a disk into the disk drive"
elseif disk.isPresent("bottom") then
disk.setLabel("bottom", label)
local cardWrite = fs.open("cards", "a")
cardWrite.write("\n"..label)
cardWrite.close()
local passWrite = fs.open("passords", "a")
passWrite.write("\n"..label)
passWrite.close()
print "succsessful"
sleep(2)
disk.eject("bottom")
sleep(1)
print "bye bye"
sleep(2)
os.reboot()
end
end
end
else
--Denies access and insults on incorrect passcode
print "YOU ARE NOT GUREKAM74 OR CMUR1!"
sleep(1)
print "FUCK OFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF!!!!!!!"
sleep(3)
disk.eject("bottom")
os.reboot()
end
end
end
end
end
parallel.waitForAny(keycardcheck, passcheck)
You need to make 2 files in the root directory, 1 called cards the other called passwords this is where the card and password data will be stored so its saved
145 posts
Location
the vast cosmos of my mind; binary!
Posted 21 December 2012 - 06:44 PM
THANKS ALOT NDFJAY
145 posts
Location
the vast cosmos of my mind; binary!
Posted 21 December 2012 - 06:47 PM
oh and i already know how to use FS.open("", "w") , FS.open("", "R"), etc.
but i didn't know how to put it together that was the problem so i was not asking for someone to do it for me. i ONLY do that if i have ABSOLUTELY no idea how to do it
212 posts
Location
Leeds, England
Posted 22 December 2012 - 06:46 AM
oh and i already know how to use FS.open("", "w") , FS.open("", "R"), etc.
but i didn't know how to put it together that was the problem so i was not asking for someone to do it for me. i ONLY do that if i have ABSOLUTELY no idea how to do it
no worries and the fs.open function is pretty simple heres some examples:
local file = fs.open("filepath", "r") -- opens a file to read
file.readAll() -- read all the contents of the file in fs.open
file.readLine() -- reads the first or n'th line in fs.open
file.close() -- closes the open file defined in file.open
-------------------------------------------------------------------------
local file - fs.open("filepath", "w") -- opens a file to write to
file.write("your text here") -- writes to the open file replacing the text
file.writeLine("your text") -- replaces the first or n'th line in the open file
file.close() -- closes the file()
-------------------------------------------------------------------------
local file = fs.open("filepath", "a") -- opens a file to append(adds text after the current text)
file.write("text") -- adds text to the end of the last line in fs.open
file.write("\n text") adds the text on a new line in fs.open
file.close() -- closes the file
if you have any more issues just post them here