Jump to content




Mag-Card -=- Immibis Peripherals

peripheral api

2 replies to this topic

#1 moneymaster2012

  • Members
  • 38 posts

Posted 18 January 2015 - 02:51 AM

I get this error when I type in my card id:
startup:30: attempt to index ? (a nil value)

--Variables
reader = peripheral.wrap("right")
version = "1.0"
password = "five5"
--Functions
clear = function()
  term.clear()
  term.setCursorPos(1,1)
end
menu = function()
  clear()
  print("[1] Create Key")
  sEvent, param = os.pullEvent("key")
    if sEvent == "key" then
	  if param == 2 then
	    sleep(0.01)
	    create()
	  end
    end
end
create = function()
  clear()
  write"Room ID:  "
  data = read()
  label = data
  clear()
  print("Creating key...")  
  reader.beginWrite(data,label)
  sleep(1)
  os.pullEvent("mag_write_done")
  print("Process Complete! Room key: "..data)
  clear()
end
	   
login = function()
  clear()
  print("logging in...")
  sleep(1)
  clear()
  term.setCursorPos(5,10)
  write"Password:  "
  pass = read("*")
  if pass == password then
    menu()
  else
    clear()
    login()
  end
end
--Mission Control
login()


#2 GopherAtl

  • Members
  • 888 posts

Posted 18 January 2015 - 03:00 AM

Are you sure the peripheral is on the right? that error suggests the peripheral.wrap("right") returned nil.

#3 moneymaster2012

  • Members
  • 38 posts

Posted 18 January 2015 - 12:53 PM

View PostGopherAtl, on 18 January 2015 - 03:00 AM, said:

Are you sure the peripheral is on the right? that error suggests the peripheral.wrap("right") returned nil.
Positive





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users