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

problem with turtle turning on turtle

Started by bigbaddevil6, 23 April 2014 - 04:50 AM
bigbaddevil6 #1
Posted 23 April 2014 - 06:50 AM
I began working on a piece of code that will place turtles and transfer programs. Nowhere near finished just testing what I got so far.

I keep getting a 15: attempt to index ? (a nil value)

If I do it manually in the Lua interface its fine. It doesn't help I'm really tired, and been writing code to go with this all day.


rednet = peripheral.wrap("left")

function place()
  com = peripheral.wrap("front")
	 --select turtle slot
  turtle.select(1)
  turtle.place()
  turtle.up()
	 --select diskDrive slot
  turtle.select(2)
  turtle.place()
	 --select floppy disk slot
  turtle.select(3)
  turtle.drop()
	 --TODO place transfer buildSignal as type()
	 --TODO place transfer buildWall as type()
  turtle.down()
  com.turnOn() -- This is line 15
  turtle.up()
	 --grab disk
  turtle.suck()
  turtle.down()
  sleep(5)
  com.reboot()
  turtle.up()
  turtle.select(2)
  turtle.dig()
  turtle.down()
end

for i = 1, 3 do
  turtle.forward()
end

place()
turtle.back()
turtle.back()
place()

EDIT: Fixed code during paste
Edited on 23 April 2014 - 04:52 AM
CometWolf #2
Posted 23 April 2014 - 07:11 AM
Your wrapping the peripheral, then placing the turtle. Which means your essentially wrapping air, which is not a peripheral at all, thus not returning a table of methods either. Personally i would just use peripheral.call("front","turnOn")
bigbaddevil6 #3
Posted 23 April 2014 - 04:18 PM
ahh ok, My original plan was to make it the variable global so I didn't have to keep doing the wrap. But with that being the case I'll go with what you said and do the call.