Jump to content




help i cant find string


  • You cannot reply to this topic
6 replies to this topic

#1 cmurtheepic

  • Members
  • 158 posts
  • Locationthe 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()
 
 
 


#2 Orwell

    Self-Destructive

  • Members
  • 1,091 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'.

#3 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 23 November 2012 - 12:43 PM

View PostOrwell, on 23 November 2012 - 12:38 PM, said:

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..? ;)/>

#4 cmurtheepic

  • Members
  • 158 posts
  • Locationthe 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?

#5 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 23 November 2012 - 02:44 PM

View Postcmurtheepic, on 23 November 2012 - 02:14 PM, said:

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?

#6 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 23 November 2012 - 04:11 PM

View Postcmurtheepic, on 23 November 2012 - 02:14 PM, said:

ok now it is saying that
message = rednet.recieve()
is nil
help?
Should be
id, message = rednet.receive()


#7 Orwell

    Self-Destructive

  • Members
  • 1,091 posts

Posted 23 November 2012 - 05:03 PM

View PostKingdaro, on 23 November 2012 - 04:11 PM, said:

View Postcmurtheepic, on 23 November 2012 - 02:14 PM, said:

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. ;)/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users