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

rednet : 87 : number expected

Started by jamiemac262, 15 February 2015 - 06:04 PM
jamiemac262 #1
Posted 15 February 2015 - 07:04 PM
okay, i was trying to create a simple network that let's players wander through my base based on their access Level. i've hit a small snag though, i'm using the Mag Reader for verification, on the one door i have(so far) when i swipe my access card, the Server computer crashes with this message

rednet : 87 : number expected

if anybody can spot the problem i would appreciate any help you can offer :)/>


path= "users/"

function newUser(username, access)
if fs.exists(path..username) then
  return false
else
  h = fs.open(path..username, w)
  h.write("7")
  h.flush()
  h.close()
end
end
function getUser(username)
  if fs.exists(path..username) then
	h = fs.open(path..username, r)
	access = h.readline()
	h.close()
	return access
end
end
function processRequest(id, message)

sends = getUser(message)
rednet.send(tonumber(id), sends)

end

rednet.open("back")

id,message = os.pullEvent("rednet_message")
processRequest(id, message)

Con0747 #2
Posted 15 February 2015 - 08:12 PM
I think you need you something to collect the event type:

local event, id, message = os.pullEvent("rednet_message")
HPWebcamAble #3
Posted 15 February 2015 - 09:12 PM
Like Con0747 said you need to store the event type.

os.pullEvent() will always return the event, even when you specify a filter.

So in your case its returning "rednet_message", senderID, mesage

You are only accepting 2, so 'id' becomes "rednet_message" and 'message' becomes the ID of the sender.

Also, somethings I noticed in your code:

h = fs.open(path..username, w)
h.write("7")
h.flush()
h.close()

'w' in the first line should have quotes (""), since it needs a string.

And you only need to do close(), not flush() and close().
Flush is used when you want to save to the file without closing it.
Close saves anyway.
Bomb Bloke #4
Posted 15 February 2015 - 09:12 PM
Better yet, use rednet.receive():

local id, message = rednet.receive()
TechedZombie #5
Posted 15 February 2015 - 09:50 PM
I think you need you something to collect the event type:

local event, id, message = os.pullEvent("rednet_message")
No I have used the redstone event to simply wait for a redstone signal before contuining in a program so I do not think that is the problem
HPWebcamAble #6
Posted 16 February 2015 - 03:17 AM
No I have used the redstone event to simply wait for a redstone signal before contuining in a program so I do not think that is the problem

Con is right, I elaborated in my previous post.

Also this is rednet, not redstone.