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

[1.42][SSP][Possible]Turtle can't turn on computers

Started by Matrixmage, 25 September 2012 - 10:13 PM
Matrixmage #1
Posted 26 September 2012 - 12:13 AM
I am building a GPS tower building program, and i have been getting some help from the ask a pro section, and someone showed me the code to make a turtle turn on a computer, but once I implemented it I kept getting ":102: attempt to index ? (a nil value)". I then posted the offending code on the ask a pro section, only to have someone tell me that it should work. If its not already apparent, to reproduce the possible bug, use the peripheral.wrap code to try to turn on a computer with a turtle. If anymore info is needed, feel free to let me know. Also I'm using a wireless mining turtle.

The offending code, for reference:

local c = peripheral.wrap("front")

c.turnOn() --turn on the comp
MysticT #2
Posted 26 September 2012 - 12:22 AM
Works fine for me. Are you sure the computer is in front of the turtle?

Edit: the error it's in line 102, but of what file? Is it part of a program?
Matrixmage #3
Posted 26 September 2012 - 12:27 AM
Its just a GPS tower building program, in a function, the variable is at the top though.
MysticT #4
Posted 26 September 2012 - 12:33 AM
Then let us see the code, at least the function.
Matrixmage #5
Posted 26 September 2012 - 12:34 AM
Here's the function, also I'm 100% sure that the turtle is in front of the comp.

Spoiler


local function compPlace()
move("forward", 2) --move two off the arm
turn("left", 2) --turn around
moveUpDown("down", 1) --move down one

turtle.select(2) --select the comp
turtle.place() --place the comp

moveUpDown("up", 1) --move up one
move("forward", 1) --move on top of the comp

moveUpDown("up", 1) --go up
turtle.select(3) --select the modem
turtle.placeDown() --place the modem
turn("left", 2) --turn around

move("forward", 1) --go forward, end being 2 off the tower
turn("left", 2) --turn around
moveUpDown("down", 3) --move down to one below the comp

turtle.select(4) --slect the disk drive
turtle.place() --place the disk drive

turtle.select(5) --slect the disk
turtle.drop(1) --put the disk in the drive

turtle.select(1) --select the tower building block again

moveUpDown("up", 1) --move to the comp's level
sleep(1)
c.turnOn() --turn on the comp
sleep(1)

moveUpDown("down", 1) --move to the disk drives level
turtle.suck() --get the disk back

turtle.dig() --get the drive back

moveUpDown("up", 3)
move("forward", 2)
moveUpDown("down", 1)
end
MysticT #6
Posted 26 September 2012 - 12:38 AM
But there's no local c = peripheral.wrap("front") there, c is not defined :P/>/>
Matrixmage #7
Posted 26 September 2012 - 12:39 AM
It is, it's at the top of the code, check my first post :P/>/>
Matrixmage #8
Posted 26 September 2012 - 12:42 AM
I have to go, wont be able to give anymore input for the next 40 min or so… I'll check when I get back.
Cloudy #9
Posted 26 September 2012 - 12:43 AM
Post your entire code. You may be doing things wrong that we can't see.
MysticT #10
Posted 26 September 2012 - 01:15 AM
Wait… you wrap the peripheral before being in front of it? :P/>/>
You can't wrap a peripheral that's not there. How would you get it's methods otherwise?
Matrixmage #11
Posted 26 September 2012 - 01:25 AM
Wait what? You have to do that? Hrmmm… no one told me that…. AND when I put it in ask a pro, no one brought that up, and I'm pretty sure I mentioned that they were separate… Well that's a mystery solved, hope I didn't bug you guys TOO much :P/>/>

P.S. I'm sending this from my phone, so I can't test it yet, but I'm pretty sure that this will fix it, if it doesn't, I'll tell you. Again, Thanks!