13 posts
Posted 19 January 2013 - 11:21 PM
hey guys,
iv'e got an error when i send something from my other computer..
and its showing only when im using "print(hey)"
rednet.open("back")
term.clear()
term.setCursorPos(1,1)
i, m = rednet.receive()
write("van "..i.."")
print("hey")
write(m)
beside that.. can i put an varible or a string in a print()?
like this :
print(m)
or
print("you've got "..m.." cakes")
thats the reason im using write
7508 posts
Location
Australia
Posted 19 January 2013 - 11:25 PM
yes you can use variables inside of print… and you can concatenate strings around the variable… just make sure that the variable actually has something inside of it…
what is the exact error?
13 posts
Posted 19 January 2013 - 11:28 PM
thanks for the fast reply!
my error is
"startup"6" attempt to call string"
(ps. im dutch.. sorry for the bad english :)/> )
139 posts
Location
USA
Posted 19 January 2013 - 11:31 PM
the error you are getting might be from something else. The code you posted works fine. So…
what is the exact error?
13 posts
Posted 19 January 2013 - 11:37 PM
uhmm.. thats weird..
the one that is sending is:
term.clear()
term.setCursorPos(1,1)
rednet.open("back")
print("Mail box")
print()
write("Name: ")
n=read()
write("to: ")
i=tonumber(read())
print("message:")
print()
m=read()
rednet.send(i, m)
i think its something with "tonumber()" .. i dont know of that is true..
7508 posts
Location
Australia
Posted 19 January 2013 - 11:41 PM
tonumber will only error if you add any non-number characters…
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point…
Edited on 19 January 2013 - 10:42 PM
2088 posts
Location
South Africa
Posted 19 January 2013 - 11:44 PM
The tonumber() is needed because you need to convert the string of input (i) to a number in order to send a message to that PC/turtle via rednet.
On the other hand, your code has no errors…
This is exactly right to concatenate a string and a variable.
print("you've got "..m.." cakes")
Before that, maybe add a print(type(m)) to see if it's a string or whatever.
PS: Please use [
code]code here…[
/code] tags :)/>
13 posts
Posted 19 January 2013 - 11:45 PM
tonumber will only error if you add any non-number characters…
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point…
yeah, i know.. so maybe the receiver must convert the "tonmuber" to a string again?
818 posts
Posted 19 January 2013 - 11:48 PM
You have a variable, or a string rather called "print" somewhere on your computer.
7508 posts
Location
Australia
Posted 19 January 2013 - 11:48 PM
tonumber will only error if you add any non-number characters…
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point…
yeah, i know.. so maybe the receiver must convert the "tonmuber" to a string again?
No because the tonumber that you are performing is so the rednet API knows which computer to send to… but according to your error and the code you just posted the error is with
write("Name: ") not to number… is that script thats sending the "startup" file?
13 posts
Posted 19 January 2013 - 11:52 PM
tonumber will only error if you add any non-number characters…
so the error is on line 6 of that EXACT code? o.O
have you tried rebooting the computer recently? you may have overridden an OS function at some point…
yeah, i know.. so maybe the receiver must convert the "tonmuber" to a string again?
No because the tonumber that you are performing is so the rednet API knows which computer to send to… but according to your error and the code you just posted the error is with
write("Name: ") not to number… is that script thats sending the "startup" file?
yes, it is the startupfile..
13 posts
Posted 19 January 2013 - 11:59 PM
it works now!.
first what i have done whas removed print() out of
print("message:")
print() – this one removed
m=read()
and then i rebooted the computers
so helpfull!
thanks guys!
13 posts
Posted 20 January 2013 - 12:05 AM
there is only one problem left
I want to send i, m and n with
rednet.send(i, m, n)
when i do something like this
write("name ")
n=read()
then when i send Varible "n" there stands a number 3.
do you guys know a solusion?
7508 posts
Location
Australia
Posted 20 January 2013 - 12:27 AM
there is only one problem left
I want to send i, m and n with
rednet.send(i, m, n)
when i do something like this
write("name ")
n=read()
then when i send Varible "n" there stands a number 3.
do you guys know a solusion?
Sending end
-- read the variables here
rednet.send( i, textutils.serialize( {m,n} ) )
Receiving end
-- receive rednet
msgTable = textutils.unserialize( receivedMsg )
m = msgTable[1]
n = msgTable[2]
This will make a table of all the items you want to send by turning it into a string and sending it… Then at the other end will turn it back into a table where you can use it.