This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Immow's profile picture

expected string -> rednet.send()

Started by Immow, 09 December 2012 - 12:54 PM
Immow #1
Posted 09 December 2012 - 01:54 PM
Hello there, most of the time fidling around for a few hours I can make things work for me. I just started learning programming and I have a litle problem that I can't seem to solve.

I'm trying to make a lift with turtles since there are no frames and redpower yet in Feed the Beast :(/>

It works but I recieve this error: rednet:350: string expected, this has probably to do with tArgs part… I think :)/>

The problematic code I use to send to my turtles

tArgs = {...}
up = (tArgs[1])
down = (tArgs[2])

rednet.open("top")
rednet.send(9, tArgs[1])
rednet.send(9, tArgs[2])

What my turtles use to recieve it (I want it to be two if statements if possible)
print("Lift program running, hold CTRL T to terminate")
rednet.open("left")
repeat
local id, msg = rednet.receive()
if msg == "up" then
  for i=1, 5 do
  turtle.up()
  end
  else
	for x=1, 5 do
  turtle.down()
  end
end
until nil

SOLVED

tArgs = {...}
rednet.open("top")
rednet.send(9, tArgs[1])
MemoryLeak21 #2
Posted 09 December 2012 - 02:34 PM
Try this.


tArgs[1] = "up"
tArgs[2] = "down"

Otherwise, Lua thinks you're just declaring a global variable and setting it to whatever's in tArgs[1] or tArgs[2]. Then, when you send it over Rednet, it's blank and not a string, which is what rednet.send() is expecting.