Jump to content




Error for print

help lua wireless

13 replies to this topic

#1 phaleron

  • Members
  • 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

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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?

#3 phaleron

  • Members
  • 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 :) )

#4 crazyguymgd

  • Members
  • 139 posts
  • LocationUSA

Posted 19 January 2013 - 11:31 PM

the error you are getting might be from something else. The code you posted works fine. So...

View PostTheOriginalBIT, on 19 January 2013 - 11:25 PM, said:

what is the exact error?


#5 phaleron

  • Members
  • 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..

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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 by TheOriginalBIT, 19 January 2013 - 11:42 PM.


#7 remiX

  • Members
  • 2,076 posts
  • LocationSouth 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 :)

#8 phaleron

  • Members
  • 13 posts

Posted 19 January 2013 - 11:45 PM

View PostTheOriginalBIT, on 19 January 2013 - 11:41 PM, said:

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?

#9 Doyle3694

  • Members
  • 815 posts

Posted 19 January 2013 - 11:48 PM

You have a variable, or a string rather called "print" somewhere on your computer.

#10 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 19 January 2013 - 11:48 PM

View Postphaleron, on 19 January 2013 - 11:45 PM, said:

View PostTheOriginalBIT, on 19 January 2013 - 11:41 PM, said:

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?

#11 phaleron

  • Members
  • 13 posts

Posted 19 January 2013 - 11:52 PM

View PostTheOriginalBIT, on 19 January 2013 - 11:48 PM, said:

View Postphaleron, on 19 January 2013 - 11:45 PM, said:

View PostTheOriginalBIT, on 19 January 2013 - 11:41 PM, said:

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..

#12 phaleron

  • Members
  • 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 phaleron

  • Members
  • 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?

#14 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 20 January 2013 - 12:27 AM

View Postphaleron, on 20 January 2013 - 12:05 AM, said:

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users