145 posts
Location
the vast cosmos of my mind; binary!
Posted 23 November 2012 - 12:35 PM
my program keeps saying string expected
rednet.open(back, true)
function gettingNews()
while true do
message = rednet.recieve()
end
end
x = message
function displayingNews()
while true do
textutils.slowWrite(x, 5)
end
end
parallel.waitForAny(gettingNews(), displayingNews())
displayingNews()
1054 posts
Posted 23 November 2012 - 12:38 PM
It expects a string at the first line:
rednet.open('back', true)
instead of:
rednet.open(back, true)
In your code, it's looking for a variable named back which is nil, while it actually needs the string 'back'.
1054 posts
Posted 23 November 2012 - 12:43 PM
It expects a string at the first line:
rednet.open('back', true)
instead of:
rednet.open(back, true)
In your code, it's looking for a variable named back which is nil, while it actually needs the string 'back'.
Edit: message hasn't been declared yet when you do 'x = message', you might just wanna do this:
rednet.open(back, true)
local message = "" -- set to "" to make sure that it isn't nil when displayingNews uses it
function gettingNews()
while true do
message = rednet.recieve()
end
end
function displayingNews()
while true do
textutils.slowWrite(message, 5)
end
end
parallel.waitForAny(gettingNews, displayingNews)
Also, you should pass the function variables to parallel.waitForAny, not the result of the function calls. So rather my correction above than this:
parallel.waitForAny(gettingNews(), displayingNews())
Actual edit: How could I've pressed the wrong button..? ;)/>/>
145 posts
Location
the vast cosmos of my mind; binary!
Posted 23 November 2012 - 02:14 PM
ok now it is saying that
message = rednet.recieve()
is nil
help?
1054 posts
Posted 23 November 2012 - 02:44 PM
ok now it is saying that
message = rednet.recieve()
is nil
help?
A line of code cannot be nil. ;)/>/> What is the exact error? And what is your full code by now?
1688 posts
Location
'MURICA
Posted 23 November 2012 - 04:11 PM
ok now it is saying that
message = rednet.recieve()
is nil
help?
Should be
id, message = rednet.receive()
1054 posts
Posted 23 November 2012 - 05:03 PM
ok now it is saying that
message = rednet.recieve()
is nil
help?
Should be
id, message = rednet.receive()
Oh man… How could I've missed that? Time to go to bed. ;)/>/>