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.
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Remote Control Turtle
Started by recneps, 26 June 2015 - 12:35 AMPosted 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.
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.
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.
Posted 26 June 2015 - 05:23 AM
Oh, right, I had forgotten about the pastebin I made of the computer-side code.
Posted 26 June 2015 - 05:44 AM
Instead of:
… you presumably meant:
function(rawread)
… you presumably meant:
function rawread()
Posted 26 June 2015 - 04:18 PM
Oh, thank you.
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.
Posted 26 June 2015 - 06:47 PM
Wrong:
Correct:
if message = "back" then
Correct:
if message == "back" then
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
Ninjad
Edited on 26 June 2015 - 04:53 PM
Posted 27 June 2015 - 12:17 AM
Oh, I didn't notice I hadn't done it there again.
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
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.
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.
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.
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.
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.
Posted 27 June 2015 - 03:02 AM
I tried it with 2 originally, and the turtle hasn't moved the entire time.