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

Bios:337: [string "RFID"]:53: ')' expected

Started by micmou, 23 June 2013 - 12:53 PM
micmou #1
Posted 23 June 2013 - 02:53 PM
Okay so I know that it wants a parentheses but in the code which is below I believe they are all correct. At line 53 it looks good.
Some of the code is borrowed from Ty94

--If you want this to start at every boot of a computer run the following line of code in the startup
-- shell.run("RFID","door")
--The door stays open as long as you stay in the area of the reader
--					    !!! Make sure there is no creeper behind you !!!
-- Set up your own door system
admin = "1"
limit = "11"
--Make sure the following sides are equal to your build
--(Don´t change)
tArgs = {...}
lastTimer = {}
-- Check the arguments given
if #tArgs < 1 then
print("Usage:")
print("RFID write")
print("RFID door")
print("RFID installer")
return
end
mode = tArgs[1]
shell.run("clear")
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
--Installer
elseif mode == "installer" then
print("What do you want to install")
print("door or writer")
local input = read()
if input == "door" then
   print("We are going to save your security level to a password now.")
   print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
   print("Enter Password now.")
   local ps = read()
   term.clear()
   term.setCursorPos(1,1)
   print("What side do you want your Reader on")
   local reader = read()
   term.clear()
   term.setCursorPos(1,1)
   print("Now we are going to decide where you want your redstone")
   print("Remember the side your reader is on cant be used")
   print("Side A")
   local sidea = read()
   print("Now Side B This Side is only used by the admin card")
   local sideb = read()
   term.clear()
   term.setCursorPos(1,1)
   fs.open("startup", "w")
   file.write
   file.close()
local target = {} -- this is a table
  target.ps = ps
  target.reader = reader
  target.sidea = sidea
  target.sideb = sideb
local output = textutils.serialize(target) -- Now we turn table into string
-- now table is saved
local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
handle.close()
os.reboot()
end
elseif input == "writer"
  print("What side is you RFID writer on")
  local rw = read()
  then fs.open("writerside", "w")
   file.write(rw)
   file.close()
  fs.open("startup", "w")
   file.write("shell.run("RFID, "writer")")
   file.close()
  os.reboot()
else
  os.reboot()

if mode == "write" then
h = fs.open("writerside", "r")
local wriside = h.readALL()
h.close()
writer = peripheral.wrap(wriside)
print("What do you the security level on card to be?")
local doorPass = read()
term.clear()
term.setCursorPos(1,1)
print("What do you want the label to be?")
loacal cardLabel = read()
term.clear()
term.setCursorPos(1,1)
print("Enter writing mode")
print("Insert card in the writer")
while not writer.isPresent() do --Waits until a card is in the writer
  sleep(0)
end
if writer.encode(doorPass, cardLabel) then --Start write to card
  print("Start writing Pass to card")
else --Error handling
  if writer.isCoded() then
   print("Card is already coded\nInsert a blank card")
  elseif #cardLabel > 20 then
   print("Card Label is too long max. 20 char")
  elseif #doorPass > 82 then
   print("Data is too long max. 82 char")
  else
   print("Leave the card in the writer")
  end
  return
end
os.pullEvent("rfid_written") --Wait until the card is written
print("RFID card is coded")
print("Take the card out of the writer")
while writer.isCoded() do --Ends the program when the card is taken out of the writer
  sleep(0)
end
shell.run("clear")
------------------------------------------------------
------------------------------------------------------
elseif mode == "door" then
local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
local variables = handle.readAll() -- input is now the serialized table
handle.close()
local destination = textutils.unserialize(variables) -- this will decode our table
reader = peripheral.wrap(target.reader)
print("Door Contol is running")
while true do
  reader.scan() --Creats an "rfid_detected" when a card is in range
  event, p1 = os.pullEvent()
  if event == "rfid_detected" then
   if (p1 == admin) then
	    rs.setOutput(target.sidea, true)
	    rs.setOutput(target.sideb, true)
	    lastTimer = os.startTimer(1)
   elseif (p1 >= target.ps) and not (p1 > limit) then
	    rs.setOutput(target.sidea, true)
	    lastTimer = os.startTimer(1)
   end
  elseif event == "timer" and lastTimer == p1 then
   rs.setOutput(target.sidea, false)
   rs.setOutput(target.sideb, false)
  end
end
end
micmou #2
Posted 23 June 2013 - 03:21 PM
Dark helped me new code now i get bios:337: [string "RFID":31: '<eof>' expected

--If you want this to start at every boot of a computer run the following line of code in the startup
-- shell.run("RFID","door")
--The door stays open as long as you stay in the area of the reader
--					    !!! Make sure there is no creeper behind you !!!
-- Set up your own door system
admin = "1"
limit = "11"
--Make sure the following sides are equal to your build
--(Don´t change)
tArgs = {...}
lastTimer = {}
-- Check the arguments given
if #tArgs < 1 then
print("Usage:")
print("RFID write")
print("RFID door")
print("RFID installer")
return
end
mode = tArgs[1]
shell.run("clear")
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
--Installer
elseif mode == "installer" then
print("What do you want to install")
print("door or writer")
local input = read()
if input == "door" then
   print("We are going to save your security level to a password now.")
   print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
   print("Enter Password now.")
   local ps = read()
   term.clear()
   term.setCursorPos(1,1)
   print("What side do you want your Reader on")
   local reader = read()
   term.clear()
   term.setCursorPos(1,1)
   print("Now we are going to decide where you want your redstone")
   print("Remember the side your reader is on cant be used")
   print("Side A")
   local sidea = read()
   print("Now Side B This Side is only used by the admin card")
   local sideb = read()
   term.clear()
   term.setCursorPos(1,1)
   fs.open("startup", "w")
   file.write("shell.run(\"RFID\", \"door\")")
   file.close()
local target = {} -- this is a table
  target.ps = ps
  target.reader = reader
  target.sidea = sidea
  target.sideb = sideb
local output = textutils.serialize(target) -- Now we turn table into string
-- now table is saved
local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
handle.close()
os.reboot()
end
elseif input == "writer"
  print("What side is you RFID writer on")
  local rw = read()
  then fs.open("writerside", "w")
   file.write(rw)
   file.close()
  fs.open("startup", "w")
   file.write("shell.run(\"RFID\", \"write\")")
   file.close()
  os.reboot()
else
  os.reboot()
end
if mode == "write" then
h = fs.open("writerside", "r")
local wriside = h.readALL()
h.close()
writer = peripheral.wrap(wriside)
print("What do you the security level on card to be?")
local doorPass = read()
term.clear()
term.setCursorPos(1,1)
print("What do you want the label to be?")
loacal cardLabel = read()
term.clear()
term.setCursorPos(1,1)
print("Enter writing mode")
print("Insert card in the writer")
while not writer.isPresent() do --Waits until a card is in the writer
  sleep(0)
end
if writer.encode(doorPass, cardLabel) then --Start write to card
  print("Start writing Pass to card")
else --Error handling
  if writer.isCoded() then
   print("Card is already coded\nInsert a blank card")
  elseif #cardLabel > 20 then
   print("Card Label is too long max. 20 char")
  elseif #doorPass > 82 then
   print("Data is too long max. 82 char")
  else
   print("Leave the card in the writer")
  end
  return
end
os.pullEvent("rfid_written") --Wait until the card is written
print("RFID card is coded")
print("Take the card out of the writer")
while writer.isCoded() do --Ends the program when the card is taken out of the writer
  sleep(0)
end
shell.run("clear")
------------------------------------------------------
------------------------------------------------------
elseif mode == "door" then
local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
local variables = handle.readAll() -- input is now the serialized table
handle.close()
local destination = textutils.unserialize(variables) -- this will decode our table
reader = peripheral.wrap(target.reader)
print("Door Contol is running")
while true do
  reader.scan() --Creats an "rfid_detected" when a card is in range
  event, p1 = os.pullEvent()
  if event == "rfid_detected" then
   if (p1 == admin) then
	    rs.setOutput(target.sidea, true)
	    rs.setOutput(target.sideb, true)
	    lastTimer = os.startTimer(1)
   elseif (p1 >= target.ps) and not (p1 > limit) then
	    rs.setOutput(target.sidea, true)
	    lastTimer = os.startTimer(1)
   end
  elseif event == "timer" and lastTimer == p1 then
   rs.setOutput(target.sidea, false)
   rs.setOutput(target.sideb, false)
  end
end
end
Engineer #3
Posted 23 June 2013 - 03:24 PM
First of all, when I tried to run it myself, I got an error. But the thing is, not the error you have described. The error was: 25: `<eof>` expected. (It actually gave me this error a few times on different lines.
So, I fixed it:
Spoiler

--If you want this to start at every boot of a computer run the following line of code in the startup
-- shell.run("RFID","door")
--The door stays open as long as you stay in the area of the reader
--										  !!! Make sure there is no creeper behind you !!!
-- Set up your own door system
admin = "1"
limit = "11"
--Make sure the following sides are equal to your build
--(Don´t change)
tArgs = {...}
lastTimer = {}
-- Check the arguments given
if #tArgs &amp;lt; 1 then
	print("Usage:")
	print("RFID write")
	print("RFID door")
	print("RFID installer")
	return
end
mode = tArgs[1]
shell.run("clear")

--Installer
if mode == "installer" then
	print("What do you want to install")
	print("door or writer")
	local input = read()
elseif input == "door" then
	print("We are going to save your security level to a password now.")
	print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
	print("Enter Password now.")
	local ps = read()
	
	term.clear()
	term.setCursorPos(1,1)
	print("What side do you want your Reader on")
	local reader = read()
	term.clear()
	term.setCursorPos(1,1)
	
	print("Now we are going to decide where you want your redstone")
	print("Remember the side your reader is on cant be used")
	print("Side A")
	local sidea = read()
	
	print("Now Side B This Side is only used by the admin card")
	local sideb = read()
	
	term.clear()
	term.setCursorPos(1,1)
	
	fs.open("startup", "w")
	file.write
	file.close()
	
	local target = {} -- this is a table
	target.ps = ps
	target.reader = reader
	target.sidea = sidea
	target.sideb = sideb
	local output = textutils.serialize(target) -- Now we turn table into string
	-- now table is saved
	local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
	handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
	handle.close()
	os.reboot()
elseif input == "writer" then
	print("What side is you RFID writer on")
	local rw = read()
	fs.open("writerside", "w")
	file.write(rw)
	file.close()
	fs.open("startup", "w")
	file.write("shell.run("RFID, "writer")")
	file.close()
	os.reboot()

elseif mode == "write" then
	h = fs.open("writerside", "r")
	local wriside = h.readALL()
	h.close()
	
	writer = peripheral.wrap(wriside)
	print("What do you the security level on card to be?")
	local doorPass = read()
	
	term.clear()
	term.setCursorPos(1,1)
	print("What do you want the label to be?")
	loacal cardLabel = read()
	
	term.clear()
	term.setCursorPos(1,1)
	print("Enter writing mode")
	print("Insert card in the writer")
	
	while not writer.isPresent() do --Waits until a card is in the writer
		sleep(0)
	end
	if writer.encode(doorPass, cardLabel) then --Start write to card
		print("Start writing Pass to card")
	else --Error handling
		if writer.isCoded() then
			print("Card is already coded\nInsert a blank card")
		elseif #cardLabel &amp;gt; 20 then
			print("Card Label is too long max. 20 char")
		elseif #doorPass &amp;gt; 82 then
			print("Data is too long max. 82 char")
		else
			print("Leave the card in the writer")
		end
		return
	end
	
	os.pullEvent("rfid_written") --Wait until the card is written
	print("RFID card is coded")
	print("Take the card out of the writer")
	
	while writer.isCoded() do --Ends the program when the card is taken out of the writer
		sleep(0)
	end
	
	shell.run("clear")
	
elseif mode == "door" then
	local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
	local variables = handle.readAll() -- input is now the serialized table
	handle.close()
	
	local destination = textutils.unserialize(variables) -- this will decode our table
	reader = peripheral.wrap(target.reader)
	print("Door Contol is running")
	
	while true do
		reader.scan() --Creats an "rfid_detected" when a card is in range
		event, p1 = os.pullEvent()
		if event == "rfid_detected" then
			if (p1 == admin) then
				rs.setOutput(target.sidea, true)
				rs.setOutput(target.sideb, true)
				lastTimer = os.startTimer(1)
			elseif (p1 &amp;gt;= target.ps) and not (p1 &amp;gt; limit) then
				rs.setOutput(target.sidea, true)
				lastTimer = os.startTimer(1)
			end
		elseif event == "timer" and lastTimer == p1 then
			rs.setOutput(target.sidea, false)
			rs.setOutput(target.sideb, false)
		end
	end
end
So lets learn how an if statement is contructed:

if <condition> then
	-- Do stuff
elseif <another condition> then
	-- Do other stuff
else
   -- Do other stuff
end
The else, and the elseif or optional, BUT you must it do it this way if you use them.

So, now to the actual error: 54: `=` expected
Lets go to line 51 - 53 in the code I posted:

fs.open("startup", "w")
file.write
file.close()
Now you do not have anything at the file.write, so lua starts to think its a variable. Which we dont want to do. If you are writing anything to it do it like this:

local file = fs.open("startup","w")
file.write("This is what gets written to the file")
file.close()

After that fix, I got another error: 74:`)` expected
Lets go to line 74:

file.write("shell.run("RFID, "writer")")
I see what you want to do here, you have two different ways of doing this:

file.write("shell.run('RFID, writer')")
file.write("shell.run(\"RFID, writer\")")

Another error: 90: `=` expected
Lets go to line 90:

loacal cardLabel = read()
That is just a typo:

local cardLabel = read()

And we are done! I normally dont ask this, but please hit that green arrow to the right, I have put some time in this :P/>/&amp;gt;
The typing was the worst thing….

Oh, and the code:
Spoiler

--If you want this to start at every boot of a computer run the following line of code in the startup
-- shell.run("RFID","door")
--The door stays open as long as you stay in the area of the reader
--                                          !!! Make sure there is no creeper behind you !!!
-- Set up your own door system
admin = "1"
limit = "11"
--Make sure the following sides are equal to your build
--(Don´t change)
tArgs = {...}
lastTimer = {}
-- Check the arguments given
if #tArgs &amp;lt; 1 then
	print("Usage:")
	print("RFID write")
	print("RFID door")
	print("RFID installer")
	return
end
mode = tArgs[1]
shell.run("clear")

--Installer
if mode == "installer" then
	print("What do you want to install")
	print("door or writer")
	local input = read()
elseif input == "door" then
	print("We are going to save your security level to a password now.")
	print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
	print("Enter Password now.")
	local ps = read()
	
	term.clear()
	term.setCursorPos(1,1)
	print("What side do you want your Reader on")
	local reader = read()
	term.clear()
	term.setCursorPos(1,1)
	
	print("Now we are going to decide where you want your redstone")
	print("Remember the side your reader is on cant be used")
	print("Side A")
	local sidea = read()
	
	print("Now Side B This Side is only used by the admin card")
	local sideb = read()
	
	term.clear()
	term.setCursorPos(1,1)
	
	fs.open("startup", "w")
	file.write("")
	file.close()
	
	local target = {} -- this is a table
	target.ps = ps
	target.reader = reader
	target.sidea = sidea
	target.sideb = sideb
	local output = textutils.serialize(target) -- Now we turn table into string
	-- now table is saved
	local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
	handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
	handle.close()
	os.reboot()
elseif input == "writer" then 
	print("What side is you RFID writer on")
	local rw = read()
	fs.open("writerside", "w")
	file.write(rw)
	file.close()
	fs.open("startup", "w")
	file.write("shell.run(\"RFID, writer\")")
	file.close()
	os.reboot()

elseif mode == "write" then
	h = fs.open("writerside", "r")
	local wriside = h.readALL()
	h.close()
	
	writer = peripheral.wrap(wriside)
	print("What do you the security level on card to be?")
	local doorPass = read()
	
	term.clear()
	term.setCursorPos(1,1)
	print("What do you want the label to be?")
	local cardLabel = read()
	
	term.clear()
	term.setCursorPos(1,1)
	print("Enter writing mode")
	print("Insert card in the writer")
	
	while not writer.isPresent() do --Waits until a card is in the writer
		sleep(0)
	end
	if writer.encode(doorPass, cardLabel) then --Start write to card
		print("Start writing Pass to card")
	else --Error handling
		if writer.isCoded() then
			print("Card is already coded\nInsert a blank card")
		elseif #cardLabel &amp;gt; 20 then
			print("Card Label is too long max. 20 char")
		elseif #doorPass &amp;gt; 82 then
			print("Data is too long max. 82 char")
		else
			print("Leave the card in the writer")
		end
		return
	end
	
	os.pullEvent("rfid_written") --Wait until the card is written
	print("RFID card is coded")
	print("Take the card out of the writer")
	
	while writer.isCoded() do --Ends the program when the card is taken out of the writer
		sleep(0)
	end
	
	shell.run("clear")
	
elseif mode == "door" then
	local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
	local variables = handle.readAll() -- input is now the serialized table
	handle.close()
	
	local destination = textutils.unserialize(variables) -- this will decode our table
	reader = peripheral.wrap(target.reader)
	print("Door Contol is running")
	
	while true do
		reader.scan() --Creats an "rfid_detected" when a card is in range
		event, p1 = os.pullEvent()
		if event == "rfid_detected" then
			if (p1 == admin) then
				rs.setOutput(target.sidea, true)
				rs.setOutput(target.sideb, true)
				lastTimer = os.startTimer(1)
			elseif (p1 &amp;gt;= target.ps) and not (p1 &amp;gt; limit) then
				rs.setOutput(target.sidea, true)
				lastTimer = os.startTimer(1)
			end
		elseif event == "timer" and lastTimer == p1 then
			rs.setOutput(target.sidea, false)
			rs.setOutput(target.sideb, false)
		end
	end
end
Edited on 23 June 2013 - 01:32 PM
darkrising #4
Posted 23 June 2013 - 03:28 PM
Edit: ninja'd by engineer :P/>

Went through it quickly.
Spoiler

--If you want this to start at every boot of a computer run the following line of code in the startup
-- shell.run("RFID","door")
--The door stays open as long as you stay in the area of the reader
--										  !!! Make sure there is no creeper behind you !!!
-- Set up your own door system
admin = "1"
limit = "11"
--Make sure the following sides are equal to your build
--(Don´t change)
tArgs = {...}
lastTimer = {}
-- Check the arguments given
if #tArgs < 1 then
  print("Usage:")
  print("RFID write")
  print("RFID door")
  print("RFID installer")
  return
end
mode = tArgs[1]
shell.run("clear")

--Installer
if mode == "installer" then
  print("What do you want to install")
  print("door or writer")
  local input = read()
  if input == "door" then
	print("We are going to save your security level to a password now.")
	print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
	print("Enter Password now.")
	local ps = read()

	term.clear()
	term.setCursorPos(1,1)
	print("What side do you want your Reader on")
	local reader = read()

	term.clear()
	term.setCursorPos(1,1)
	print("Now we are going to decide where you want your redstone")
	print("Remember the side your reader is on cant be used")
	print("Side A")
	local sidea = read()
	print("Now Side B This Side is only used by the admin card")
	local sideb = read()

	term.clear()
	term.setCursorPos(1,1)
	fs.open("startup", "w")
	file.write("shell.run(\"RFID\", \"door\")")
	file.close()

	target = {}
	target.ps = ps
	target.reader = reader
	target.sidea = sidea
	target.sideb = sideb

	output = textutils.serialize(target)

	handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
	handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
	handle.close()
	os.reboot()
  end
elseif input == "writer"
  print("What side is you RFID writer on")
  local rw = read()
  then fs.open("writerside", "w")
  file.write(rw)
  file.close()
  fs.open("startup", "w")
  file.write("shell.run(\"RFID\", \"write\")")
  file.close()
  os.reboot()
else
  os.reboot()
end

if mode == "write" then
  h = fs.open("writerside", "r")
  local wriside = h.readALL()
  h.close()
  writer = peripheral.wrap(wriside)
  print("What do you the security level on card to be?")
  local doorPass = read()

  term.clear()
  term.setCursorPos(1,1)
  print("What do you want the label to be?")
  loacal cardLabel = read()
  term.clear()
  term.setCursorPos(1,1)
  print("Enter writing mode")
  print("Insert card in the writer")

  while not writer.isPresent() do --Waits until a card is in the writer
	sleep(0.1)
  end
if writer.encode(doorPass, cardLabel) then --Start write to card
  print("Start writing Pass to card")
else --Error handling
  if writer.isCoded() then
	print("Card is already coded\nInsert a blank card")
  elseif #cardLabel > 20 then
	print("Card Label is too long max. 20 char")
  elseif #doorPass > 82 then
	print("Data is too long max. 82 char")
  else
	print("Leave the card in the writer")
  end
  return
end

os.pullEvent("rfid_written") --Wait until the card is written
print("RFID card is coded")
print("Take the card out of the writer")
while writer.isCoded() do --Ends the program when the card is taken out of the writer
  sleep(0)
end
shell.run("clear")

if mode == "door" then
  local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
  local variables = handle.readAll() -- input is now the serialized table
  handle.close()
  local destination = textutils.unserialize(variables) -- this will decode our table
  reader = peripheral.wrap(target.reader)
  print("Door Contol is running")
  while true do
	reader.scan() --Creats an "rfid_detected" when a card is in range
	event, p1 = os.pullEvent()
	if event == "rfid_detected" then
	  if (p1 == admin) then
		rs.setOutput(target.sidea, true)
		rs.setOutput(target.sideb, true)
		lastTimer = os.startTimer(1)
	  elseif (p1 >= target.ps) and not (p1 > limit) then
		rs.setOutput(target.sidea, true)
		lastTimer = os.startTimer(1)
	  end
	end
  end

  if event == "timer" and lastTimer == p1 then
	rs.setOutput(target.sidea, false)
	rs.setOutput(target.sideb, false)
  end
end
micmou #5
Posted 23 June 2013 - 04:28 PM
Okay so with Engineers code. I replaced all of the greater than and less than sign and replaced and fixed errors I found when testing it. After I get done specifying my variables in the program installer i get RFID:53: attempt to index ? (a nil value) and then When I go through with the writer installation it doesn't ask what side you want your writer on. To replicate type RFID installer and then type door for door installation error the writer for the writer installation issue. Also it must be name RFID.

-- Set up your own door system
admin = "1"
limit = "11"
--Make sure the following sides are equal to your build
--(Don´t change)
tArgs = {...}
lastTimer = {}
-- Check the arguments given
if #tArgs < 1 then
	    print("Usage:")
	    print("RFID write")
	    print("RFID door")
	    print("RFID installer")
	    return
end
mode = tArgs[1]
shell.run("clear")
--Installer
if mode == "installer" then
	    print("What do you want to install")
	    print("door or writer")
	    local input = read()
elseif input == "door" then
	    print("We are going to save your security level to a password now.")
	    print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
	    print("Enter Password now.")
	    local ps = read()
	   
	    term.clear()
	    term.setCursorPos(1,1)
	    print("What side do you want your Reader on")
	    local reader = read()
	    term.clear()
	    term.setCursorPos(1,1)
	   
	    print("Now we are going to decide where you want your redstone")
	    print("Remember the side your reader is on cant be used")
	    print("Side A")
	    local sidea = read()
	   
	    print("Now Side B This Side is only used by the admin card")
	    local sideb = read()
	   
	    term.clear()
	    term.setCursorPos(1,1)
	   
	    fs.open("startup", "w")
	    file.write("shell.run(\"RFID, door\")")
	    file.close()
	   
	    local target = {} -- this is a table
	    target.ps = ps
	    target.reader = reader
	    target.sidea = sidea
	    target.sideb = sideb
	    local output = textutils.serialize(target) -- Now we turn table into string
	    -- now table is saved
	    local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
	    handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
	    handle.close()
	    os.reboot()
	    end
elseif input == "writer" then
	    print("What side is you RFID writer on")
	    local rw = read()
	    fs.open("writerside", "w")
	    file.write(rw)
	    file.close()
	    fs.open("startup", "w")
	    file.write("shell.run(\"RFID, writer\")")
	    file.close()
	    os.reboot()
elseif mode == "write" then
	    h = fs.open("writerside", "r")
	    local wriside = h.readALL()
	    h.close()
	   
	    writer = peripheral.wrap(wriside)
	    print("What do you the security level on card to be?")
	    local doorPass = read()
	   
	    term.clear()
	    term.setCursorPos(1,1)
	    print("What do you want the label to be?")
	    local cardLabel = read()
	   
	    term.clear()
	    term.setCursorPos(1,1)
	    print("Enter writing mode")
	    print("Insert card in the writer")
	   
	    while not writer.isPresent() do --Waits until a card is in the writer
			    sleep(0)
	    end
	    if writer.encode(doorPass, cardLabel) then --Start write to card
			    print("Start writing Pass to card")
	    else --Error handling
			    if writer.isCoded() then
					    print("Card is already coded\nInsert a blank card")
			    elseif #cardLabel > 20 then
					    print("Card Label is too long max. 20 char")
			    elseif #doorPass > 82 then
					    print("Data is too long max. 82 char")
			    else
					    print("Leave the card in the writer")
			    end
			    return
	    end
	   
	    os.pullEvent("rfid_written") --Wait until the card is written
	    print("RFID card is coded")
	    print("Take the card out of the writer")
	   
	    while writer.isCoded() do --Ends the program when the card is taken out of the writer
			    sleep(0)
	    end
	   
	    shell.run("clear")
	   
elseif mode == "door" then
	    local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
	    local variables = handle.readAll() -- input is now the serialized table
	    handle.close()
	   
	    local destination = textutils.unserialize(variables) -- this will decode our table
	    reader = peripheral.wrap(target.reader)
	    print("Door Contol is running")
	   
	    while true do
			    reader.scan() --Creats an "rfid_detected" when a card is in range
			    event, p1 = os.pullEvent()
			    if event == "rfid_detected" then
					    if (p1 == admin) then
							    rs.setOutput(target.sidea, true)
							    rs.setOutput(target.sideb, true)
							    lastTimer = os.startTimer(1)
					    elseif (p1 >= target.ps) and not (p1 > limit) then
							    rs.setOutput(target.sidea, true)
							    lastTimer = os.startTimer(1)
					    end
			    elseif event == "timer" and lastTimer == p1 then
					    rs.setOutput(target.sidea, false)
					    rs.setOutput(target.sideb, false)
			    end
	    end
end
Engineer #6
Posted 23 June 2013 - 04:33 PM

file.write("shell.run(\"RFID, door\")")

Sorry, my bad. It should be:

file.write("shell.run(\"RFID\",\"door\")")
micmou #7
Posted 23 June 2013 - 04:53 PM
Okay with the mess up fixed I get bios:337: [string "RFID"]:64 '<eof>' expected which is fixed by changing an elseif to if and ending it here pastebin.com/j3dQFWjc I get bios:337: [string "RFID"]:76: '<eof>' expected. What i think the issue is as that there is an elseif but that is for the mode write not the door or writer it is for actually writing data to cards
Engineer #8
Posted 23 June 2013 - 05:29 PM
Why didnt you listen?
You are doing this essentially:

if <condition> then
 -- code
end
elseif <condition> then
end

It should be:

if <condition> then
  -- code
elseif <condition> then
  -- code
end

Take a look for it around line 76.
Fixed code:
Spoiler

-- Set up your own door system
local admin = "1"
local limit = "11"
--Make sure the following sides are equal to your build
--(Don´t change)
local tArgs = {...}
local lastTimer = {}
-- Check the arguments given
if #tArgs < 1 then
	print("Usage:")
	print("RFID write")
	print("RFID door")
	print("RFID installer")
	return
end
local mode = tArgs[1]
shell.run("clear")

--Installer
if mode == "installer" then
	print("What do you want to install")
	print("door or writer")
	local input = read()
	if input == "door" then
		print("We are going to save your security level to a password now.")
		print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
		print("Enter Password now.")
		local ps = read()

		term.clear()
		term.setCursorPos(1,1)
		print("What side do you want your Reader on")
		local reader = read()
		term.clear()
		term.setCursorPos(1,1)
		
		print("Now we are going to decide where you want your redstone")
		print("Remember the side your reader is on cant be used")
		print("Side A")
		local sidea = read()

		print("Now Side B This Side is only used by the admin card")
		local sideb = read()

		term.clear()
		term.setCursorPos(1,1)
		
		fs.open("startup", "w")
		file.write("shell.run(\"RFID\",\"door\")")
		file.close()

		local target = {} -- this is a table
		target.ps = ps
		target.reader = reader
		target.sidea = sidea
		target.sideb = sideb
		local output = textutils.serialize(target) -- Now we turn table into string
		-- now table is saved
		local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
		handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
		handle.close()
		os.reboot()
	end
elseif input == "writer" then
	print("What side is you RFID writer on")
	local rw = read()
	fs.open("writerside", "w")
	file.write(rw)
	file.close()
	
	fs.open("startup", "w")
	file.write("shell.run(\"RFID\",\"write\")")
	file.close()
	os.reboot()
elseif mode == "write" then
	h = fs.open("writerside", "r")
	local wriside = h.readALL()
	h.close()

	writer = peripheral.wrap(wriside)
	print("What do you the security level on card to be?")
	local doorPass = read()
	
	term.clear()
	term.setCursorPos(1,1)
	print("What do you want the label to be?")
	local cardLabel = read()

	term.clear()
	term.setCursorPos(1,1)
	print("Enter writing mode")
	print("Insert card in the writer")

	while not writer.isPresent() do --Waits until a card is in the writer
		sleep(0)
	end
	if writer.encode(doorPass, cardLabel) then --Start write to card
		print("Start writing Pass to card")
	else --Error handling
		if writer.isCoded() then
			print("Card is already coded\nInsert a blank card")
		elseif #cardLabel > 20 then
			print("Card Label is too long max. 20 char")
		elseif #doorPass > 82 then
			print("Data is too long max. 82 char")
		else
			print("Leave the card in the writer")
		end
		return
	end

	os.pullEvent("rfid_written") --Wait until the card is written
	print("RFID card is coded")
	print("Take the card out of the writer")

	while writer.isCoded() do --Ends the program when the card is taken out of the writer
		sleep(0)
	end       
	shell.run("clear")

elseif mode == "door" then
	local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
	local variables = handle.readAll() -- input is now the serialized table
	handle.close()

	local destination = textutils.unserialize(variables) -- this will decode our table
	reader = peripheral.wrap(target.reader)
	print("Door Contol is running")
	
	while true do
		reader.scan() --Creats an "rfid_detected" when a card is in range
		event, p1 = os.pullEvent()
		if event == "rfid_detected" then
			if (p1 == admin) then
				rs.setOutput(target.sidea, true)
				rs.setOutput(target.sideb, true)
				lastTimer = os.startTimer(1)
			elseif (p1 >= target.ps) and not (p1 > limit) then
				rs.setOutput(target.sidea, true)
				lastTimer = os.startTimer(1)
			end
		elseif event == "timer" and lastTimer == p1 then
			rs.setOutput(target.sidea, false)
			rs.setOutput(target.sideb, false)
		end
	end
end
micmou #9
Posted 23 June 2013 - 06:16 PM
Okay Thank you I am sorry for not listening. The error it is giving RFID:49: attempt to index ? a nil value. the line 49 is this one
file.write("shell.run(\"RFID\",\"door\")") and that is where it is stopping also to store the variable persistently. I am using a table to store them here is the thing in question. Well I wanted to know if the table is set up correctly.

Write variable to table and save as string

if input == "door" then
				print("We are going to save your security level to a password now.")
				print("note must be between 0 and 11 and can be a decimal max of 82 Chars")
				print("Enter Password now.")
				local ps = read()
			  
				term.clear()
				term.setCursorPos(1,1)
				print("What side do you want your Reader on")
				local reader = read()
				term.clear()
				term.setCursorPos(1,1)
			  
				print("Now we are going to decide where you want your redstone")
				print("Remember the side your reader is on cant be used")
				print("Side A")
				local sidea = read()
			  
				print("Now Side B This Side is only used by the admin card")
				local sideb = read()
			  
				term.clear()
				term.setCursorPos(1,1)
			  
				fs.open("startup", "w")
				file.write("shell.run(\"RFID\",\"door\")")
				file.close()
			  
				local target = {} -- this is a table
				target.ps = ps
				target.reader = reader
				target.sidea = sidea
				target.sideb = sideb
				local output = textutils.serialize(target) -- Now we turn table into string
				-- now table is saved
				local handle = assert(fs.open("vars", "w"), "Couldn't save vars") -- this will give you an error if something's gone wrong
				handle.write(output) -- this is where the magic happens, we're storing the entire "target" table
				handle.close()
				os.reboot()

Read file unserialize string. Rebuild into table refrence table values as target.variablename as var input variables in checker

elseif mode == "door" then
				local handle = assert(fs.open("vars", "r"), "Couldn't load vars") -- this file is opened in read mode
				local variables = handle.readAll() -- input is now the serialized table
				handle.close()
			  
				local destination = textutils.unserialize(variables) -- this will decode our table
				reader = peripheral.wrap(target.reader)
				print("Door Contol is running")
			  
				while true do
						reader.scan() --Creats an "rfid_detected" when a card is in range
						event, p1 = os.pullEvent()
						if event == "rfid_detected" then
								if (p1 == admin) then
										rs.setOutput(target.sidea, true)
										rs.setOutput(target.sideb, true)
										lastTimer = os.startTimer(1)
								elseif (p1 >= target.ps) and not (p1 > limit) then
										rs.setOutput(target.sidea, true)
										lastTimer = os.startTimer(1)
								end
						elseif event == "timer" and lastTimer == p1 then
								rs.setOutput(target.sidea, false)
								rs.setOutput(target.sideb, false)

EDIT: the varaiable admin is just the master pass
micmou #10
Posted 24 June 2013 - 08:40 AM
Okay so I don't mean to bump I would rather use this thread than create a new one. But I need help looking at something I am going to be re writing the program from the beginning. But I was looking at darks code for his installer and I need a little help Understanding.
https://github.com/d...urity/installer
The code I don't get is lines 48-57 I know this in it and this is about it. I will highlight in blue what i get and red on what I don't mostly it is just how it is put together which is what I need help with.
EDIT: It took out my nice formatting D: so i added Plus signs colored white.
++++for i = 1, #programs do
+++++print("")
+++++write("Downloading: "..programs)
+++++getGit = http.get(NVersion[programs].GitURL)
+++++getGit = getGit.readAll()
+++++local file = fs.open(pathAnswer..programs, "w")
+++++file.write(getGit)
+++++file.close()
+++++write(".. Done")
+++++sleep(1)
++++end
Bomb Bloke #11
Posted 24 June 2013 - 10:40 AM
The first flagged line starts a loop that'll count through each element in the "programs" table. The other flagged segments refer to data in that table.

http://lua-users.org/wiki/TablesTutorial
http://www.lua.org/pil/4.3.4.html