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

Remote Control Turtle

Started by recneps, 26 June 2015 - 12:35 AM
recneps #1
Posted 26 June 2015 - 02:35 AM
So, I am playing on a modpack using computercraft. I am using wireless rednet to make a remote control turtle, using an Advanced Computer and an Advanced Wireless Turtle. So far, I have a program named "Turtle" on both, that should allow you to use keys WASD to make the turtle go forwards and backwards, as well as turning left and right. I can not get it to work, can somebody help me? Here are the programs and error messages used and returned by the turtle and computer. Okay, I got the turtle-side code fixed, but can not figure out the error in the computer.
So, I have an error in line 2, and I can not figure out what the error is. Can someone figure it out for me? Thank you.
Grim Reaper #2
Posted 26 June 2015 - 04:06 AM
Would it be possible for you to give us the code without the errors pasted into it exactly as you have it on the computer/turtle? That way, we can try and isolate the problem more easily instead of following your code line by line.
recneps #3
Posted 26 June 2015 - 05:23 AM
Oh, right, I had forgotten about the pastebin I made of the computer-side code.
Bomb Bloke #4
Posted 26 June 2015 - 05:44 AM
Instead of:

function(rawread)

… you presumably meant:

function rawread()
recneps #5
Posted 26 June 2015 - 04:18 PM
Oh, thank you.
recneps #6
Posted 26 June 2015 - 06:07 PM
So, I recently had errors with my world. I had to revert to a back-up, and lost progress with my turtle-side code. I managed to get it mostly fixed, but I now am getting a line 13 'then' expected error with this code.
KingofGamesYami #7
Posted 26 June 2015 - 06:47 PM
Wrong:
if message = "back" then

Correct:
if message == "back" then
Square789 #8
Posted 26 June 2015 - 06:49 PM
You need a double "=" if you are checking for something in an if-construction, as you did in all the other "ifs"
Ninjad
Edited on 26 June 2015 - 04:53 PM
recneps #9
Posted 27 June 2015 - 12:17 AM
Oh, I didn't notice I hadn't done it there again.
recneps #10
Posted 27 June 2015 - 12:27 AM
So, now, I have fixed the error messages and redone a few things, but I can not get it to work. The programs don't end, but I am not getting the turtle to move. Here is the turtle and computer-side code.
The_Cat #11
Posted 27 June 2015 - 12:36 AM
The programs don't end

Its not ending because "i" is never equal to 2, you have to add i=i+1 when a command is received.

As for it not actual working, you could try "rednet.send()" Here is wiki http://computercraft...iki/Rednet.send
Edited on 26 June 2015 - 11:15 PM
recneps #12
Posted 27 June 2015 - 01:43 AM
I mean, I want it never to end, until I terminate it, or until I press a kill-switch key which will set i to 2, and the send doesn't work.
Bomb Bloke #13
Posted 27 June 2015 - 02:11 AM
Are you sure the turtle has fuel? I see you're calling turtle.refuel(), but that won't do much of anything unless there's some suitable items in its currently selected inventory slot (eg charcoal).

Make sure the systems are in range of each other. Wireless modems have can only communicate over such-and-such a distance. If they're too far apart, pillar up to world height, place another computer + wireless modem, and run the repeat script on that.

turtle.forward()/turnLeft()/etc do not require arguments. Ditch the 1's, they'll be ignored.

Make use of the keys API! keys.w, keys.a, etc is a lot easier to read than 17, 30, etc.
recneps #14
Posted 27 June 2015 - 02:16 AM
So, I have done further tests, and I know that the rednet messages are not getting to the turtle. My tests have also revealed that it is not recognizing 'q' or 's' as '31' or '16' when I press the keys. Can someone find the errors in the turtle and computer-side code?
recneps #15
Posted 27 June 2015 - 02:25 AM
Are you sure the turtle has fuel? I see you're calling turtle.refuel(), but that won't do much of anything unless there's some suitable items in its currently selected inventory slot (eg charcoal).

Make sure the systems are in range of each other. Wireless modems have can only communicate over such-and-such a distance. If they're too far apart, pillar up to world height, place another computer + wireless modem, and run the repeat script on that.

turtle.forward()/turnLeft()/etc do not require arguments. Ditch the 1's, they'll be ignored.

Make use of the keys API! keys.w, keys.a, etc is a lot easier to read than 17, 30, etc.

Sorry, I didn't see this post before I made my last one. The turtle has a stack of coal in its slot, and the turtle and the computer are 30 blocks apart, so they should be in range, but I might have to check my config. I will try to start changing it to the keys API, if I can figure out how to use it properly.
KingofGamesYami #16
Posted 27 June 2015 - 03:00 AM
Try a longer timeout on the computer side. I'd try at least 1.5, I'm not sure how long it takes for a turtle action to resolve. turtle.forward() actually takes time to perform, so if it's more than a second, your script would send the message back too late.
recneps #17
Posted 27 June 2015 - 03:02 AM
I tried it with 2 originally, and the turtle hasn't moved the entire time.