Jump to content




Rednet Send Turtle Data [Error]

turtle computer wireless

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

#1 nynoray

  • New Members
  • 24 posts

Posted 13 September 2012 - 02:34 AM

Hey, I'm trying to send the resuts of turtle.getItemCount() from the turtle to a computer

-- i usually have a print(turtle.getItemCode(1)) before i try to send it out like
if something == "this" then
print(turtle.getItemCode(1))
rednet.send(8, turtle.getItemCode(1))
end
-- the #of items in that slot will print but then i get an error saying something like :350: string expected

--i did try making  slot1 = turtle.getItemCode(1)  so,
print(slot1)
rednet.send(8, slot1)
--same error, also made 8 = id
print(slot1)
rednet.send(id, slot1)
-still no :P/>/>, just prints.

with that code I'm just trying to help you understand what is happening. That is not the full program, it is basically code I made up now based on the part of the program giving me errors and the only part that doesn't work.

Any help would be appreciated, I'm still trying to learn lua :)/> (if my explanation made no sense tell me)

#2 NIN3

  • New Members
  • 57 posts
  • LocationEverywhere.

Posted 13 September 2012 - 02:37 AM

If your using
turtle.getItemCode(1)= slot1
Then you need to turn it around to
slot1 = turtle.getItemCode(1)

Hope it works :)/>
EDIT: fixed crap color codes.....

#3 nynoray

  • New Members
  • 24 posts

Posted 13 September 2012 - 02:39 AM

View PostNIN3, on 13 September 2012 - 02:37 AM, said:

If your using
turtle.getItemCode(1)= slot1
Then you need to turn it around to
slot1 = turtle.getItemCode(1)

Hope it works :)/>
EDIT: fixed crap color codes.....

sorry ill fix that on the thread i just checked my coding and it was ordered like that already

#4 NIN3

  • New Members
  • 57 posts
  • LocationEverywhere.

Posted 13 September 2012 - 03:22 AM

Can you give us the exact code then? It would appear as if you have other parts...
Also, do you have a error code with a line number?

#5 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 13 September 2012 - 04:27 AM

What errors are you getting?

#6 nynoray

  • New Members
  • 24 posts

Posted 13 September 2012 - 11:09 AM

View PostZoinky, on 13 September 2012 - 04:27 AM, said:

What errors are you getting?

View PostNIN3, on 13 September 2012 - 03:22 AM, said:

Can you give us the exact code then? It would appear as if you have other parts...
Also, do you have a error code with a line number?

I get the error - Rednet:350: String expected - clearly not a line in the coding, but if i remove that one line no problems so ill assume it is the -rednet.send(8, slot)


rednet.open("right")
while true do
--also tried adding -local slot - here
sender, message, distance = rednet.receive()
slot = turtle.getItemCount(1)
  if message == "inv" then
  print(slot)
  rednet.send(8, slot)
end
end


still prints on the turtle screen... I always fail with rednet somehow.

#7 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 13 September 2012 - 03:00 PM

.getItemCount return a number, rednet.send needs a string. try to do slot = tonumber(turtle.getItemCount(1))

Anyways a good way to find stuff liek this is too open the rednet api file up. Copyed the function send below.

SendFunction (All credit goes too the maker of rednet api.
Spoiler


#8 nynoray

  • New Members
  • 24 posts

Posted 13 September 2012 - 06:40 PM

View Postsjele, on 13 September 2012 - 03:00 PM, said:

.getItemCount return a number, rednet.send needs a string. try to do slot = tonumber(turtle.getItemCount(1))

Anyways a good way to find stuff liek this is too open the rednet api file up. Copyed the function send below.

SendFunction (All credit goes too the maker of rednet api.
Spoiler

when I add the tonumber thing it seems to make no difference :)/>. I don't know why this doesn't work in the first place.

#9 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

Posted 14 September 2012 - 05:24 AM

View Postnynoray, on 13 September 2012 - 06:40 PM, said:

View Postsjele, on 13 September 2012 - 03:00 PM, said:

.getItemCount return a number, rednet.send needs a string. try to do slot = tonumber(turtle.getItemCount(1))

Anyways a good way to find stuff liek this is too open the rednet api file up. Copyed the function send below.

SendFunction (All credit goes too the maker of rednet api.
Spoiler

when I add the tonumber thing it seems to make no difference :)/>. I don't know why this doesn't work in the first place.
Correction it should be:
rednet.send(id, tostring(turtle.getItemCount(1))


#10 nynoray

  • New Members
  • 24 posts

Posted 14 September 2012 - 07:38 PM

View PostHuman, on 14 September 2012 - 05:24 AM, said:

View Postnynoray, on 13 September 2012 - 06:40 PM, said:

View Postsjele, on 13 September 2012 - 03:00 PM, said:

.getItemCount return a number, rednet.send needs a string. try to do slot = tonumber(turtle.getItemCount(1))

Anyways a good way to find stuff liek this is too open the rednet api file up. Copyed the function send below.

SendFunction (All credit goes too the maker of rednet api.
Spoiler

when I add the tonumber thing it seems to make no difference :)/>. I don't know why this doesn't work in the first place.
Correction it should be:
rednet.send(id, tostring(turtle.getItemCount(1))

ty it worked





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users