Jump to content




Remote Control Turtle Program

turtle computer wireless

22 replies to this topic

#1 CastleMan2000

  • Members
  • 195 posts
  • LocationThe trashcan where all Undertale trash is

Posted 22 April 2012 - 12:05 AM

Hello, I just made two programs designed to be able to control a turtle from a console. The console and turtle must be wireless in order to work, and the turtle should preferably be a mining turtle. The program is somewhat WIP, because it currently does not have the capability to move, dig, or build vertically, but these features should be coming shortly, I just need to decide the keys. The turtle program provides feedback on it's computer, but I will probably have it send feedback to the console as well. That would be pretty tough, though.

Console
function RCmaster()
while true do
local sEvent, param = os.pullEvent("key")
if(sEvent == "key") then
if(param == 200) then
rednet.broadcast("TS Forward")
elseif (param == 208) then
rednet.broadcast("TS Backward")
elseif (param == 203) then
rednet.broadcast("TS TurnLeft")
elseif (param == 205) then
rednet.broadcast("TS TurnRight")
elseif (param == 28) then
rednet.broadcast("TS PlaceBlock")
end
end
end
end
print("What side is your modem on?")
local modem = read()
rednet.open(modem)
term.clear()
textutils.slowPrint("TurtleControl Initiated.")
print ("Use arrow keys to move and Enter to place blocks.")
RCmaster()

Turtle
function RCslave()
while true do
local scrap, message = rednet.receive()
if message == "TS Forward" then
print("Forward")
if turtle.detect() == true then
turtle.dig()
end
turtle.forward()
elseif message == "TS Backward" then
print("Backward")
turtle.back()
elseif message == "TS TurnLeft" then
print("Turn Left")
turtle.turnLeft()
elseif message == "TS TurnRight" then
print("Turn Right")
turtle.turnRight()
elseif message == "TS PlaceBlock" then
if turtle.detect() == true then
print("Block Present")
else
print("Place Block")
turtle.place()
end
end
end
end
rednet.open("right")
textutils.slowPrint("TurtleReceive Initiated.")
RCslave()

This is a very simple remote control turtle program, but I may try to implement a few fancy things. I'm using the Tekkit pack, so unfortunately I can't find the save files for the programs.

ToDo:
Vertical movement and actions
Possible warning if you are stretching the limit of signal range
Not allowing turtles to destroy one another

PS: I'm new to this forum :)/>

#2 EatenAlive3

  • New Members
  • 53 posts

Posted 22 April 2012 - 12:20 AM

Nice, and welcome :3

#3 cant_delete_account

  • Members
  • 484 posts

Posted 22 April 2012 - 12:28 AM

To access the save files, just go to %AppData%/.techniclauncher/tekkit/saves/YOURWORLDNAME/computer/YOURCOMPUTERID
YOURCOMPUTERID can be a Turtle ID too, to get your Computer ID type 'id' in your computer. (not in a program)
Then in that folder there will be all of the files for that computer.

#4 EmTeaKay

  • Members
  • 115 posts

Posted 22 April 2012 - 03:14 AM

Or you can go to 'C:Users[Name]AppDataroaming.minecraftsaves[World Name]computer[ID Number'
I hope this helped!

#5 CastleMan2000

  • Members
  • 195 posts
  • LocationThe trashcan where all Undertale trash is

Posted 23 April 2012 - 01:05 AM

View Postthesbros, on 22 April 2012 - 12:28 AM, said:

To access the save files, just go to %AppData%/.techniclauncher/tekkit/saves/YOURWORLDNAME/computer/YOURCOMPUTERID
YOURCOMPUTERID can be a Turtle ID too, to get your Computer ID type 'id' in your computer. (not in a program)
Then in that folder there will be all of the files for that computer.

I'm on a mac, but I found it easily enough. Thank you! I crashed all of my computers, one of which had a project on them, with my virus! Plus, I can keep working on the turtle program!

#6 samip

  • New Members
  • 2 posts

Posted 26 April 2012 - 03:44 PM

So how i can use that? (i know that i need wireless modem but where?)

#7 tytynguyen

  • New Members
  • 1 posts

Posted 27 April 2012 - 02:26 PM

How did you know where the keys were?(Params) Is there a list somewhere?

#8 connor

  • New Members
  • 12 posts

Posted 28 April 2012 - 02:50 AM

you need to add a command where you can see what you're turtle is seeing

#9 Tiin57

    Java Lunatic

  • Members
  • 1,412 posts
  • LocationIndiana, United States

Posted 14 July 2012 - 07:11 PM

View Postconnor, on 28 April 2012 - 02:50 AM, said:

you need to add a command where you can see what you're turtle is seeing
I'm not sure if that's possible. You might install something like the CCTV mod, integrate it with rednet, and use that signal, but as far as I know, regular Computercraft does not support video of any sort. (I can't speak for CCsensors, though.)
Also, excellent work on this. I am working on something similar, and I will credit you for helping with a rednet code error. :P/>
Edit: I abandoned that project, but thank you for the help nonetheless.

#10 sorker3

  • New Members
  • 3 posts

Posted 26 July 2012 - 02:15 AM

View Posttiin57, on 14 July 2012 - 07:11 PM, said:

View Postconnor, on 28 April 2012 - 02:50 AM, said:

you need to add a command where you can see what you're turtle is seeing
I'm not sure if that's possible. You might install something like the CCTV mod, integrate it with rednet, and use that signal, but as far as I know, regular Computercraft does not support video of any sort. (I can't speak for CCsensors, though.)
Also, excellent work on this. I am working on something similar, and I will credit you for helping with a rednet code error. :)/>
Edit: I abandoned that project, but thank you for the help nonetheless.
Can't you use rednet broadcasting? Like the turtle broadcast back to you.
Exemple:
========================================================
turtle.back()
rednet.broadcast("Turtle moved back 'turtle.back()' ")
========================================================
Im not the best one on this, but hope you understund .... .P

#11 Tiin57

    Java Lunatic

  • Members
  • 1,412 posts
  • LocationIndiana, United States

Posted 29 July 2012 - 12:58 PM

Yes, but unless it was constantly turning and doing turtle.detect(), the turtle (and thus, the controller) would not be aware of the surroundings.

#12 Dolphindalt

  • New Members
  • 6 posts

Posted 13 August 2012 - 06:15 AM

Its not working :P/>
Its says

"bios:206: [string "startup"]:2: ')' exspected"

#13 CastleMan2000

  • Members
  • 195 posts
  • LocationThe trashcan where all Undertale trash is

Posted 29 August 2012 - 09:47 PM

First, which one? Master or slave? Second, is 'startup' what you named it or is that a separate program?

#14 CzerPL

  • New Members
  • 8 posts

Posted 27 October 2012 - 10:50 AM

i don't see what i'm doing. Can you do small console?

#15 ChunLing

  • Members
  • 2,027 posts

Posted 27 October 2012 - 02:31 PM

You can use CCInput or CCPortable, so you don't have to work with the console open (and aren't tied to a particular location). CCPortable has the big disadvantage of not using the normal key/char events, but it has a small screen (which can be edited to be transparent) for feedback. If you're able to program the control program I recommend it. CCInput doesn't put up a console, so you can see everything you're doing (but can't get feedback) and it provides the normal key and char events, so you can use it with other programs without modifying them.

#16 Kazimir

  • Members
  • 90 posts
  • Locationthat's no moon...

Posted 27 October 2012 - 03:26 PM

I added a bit of functions. In the terminal press the "TAB" for help, "Enter" for status.

Terminal

Turtle

#17 50505050G

  • New Members
  • 1 posts

Posted 25 December 2012 - 11:33 AM

Is there a list of values assigned to the keys? I wanted to try to figure out the code to become better at lua but I can't figure how they are numbered. I figured out the letters but everything else I can't.

#18 Kazimir

  • Members
  • 90 posts
  • Locationthat's no moon...

Posted 25 December 2012 - 11:19 PM

View Post50505050G, on 25 December 2012 - 11:33 AM, said:

Is there a list of values assigned to the keys? I wanted to try to figure out the code to become better at lua but I can't figure how they are numbered. I figured out the letters but everything else I can't.
It is written in the wiki http://computercraft.../Raw_key_events

#19 MonsterKiLL

  • Members
  • 3 posts

Posted 21 July 2013 - 05:55 AM

Hello. I want to add the turtle to go up and down. So I changed your code a bit, but it didn't work. Can you tell me what is wrong ?

Computer
function RCmaster()
while true do
local sEvent, param = os.pullEvent("key")
if(sEvent == "key") then
if(param == 200) then
rednet.broadcast("TS Forward")
elseif (param == 208) then
rednet.broadcast("TS Backward")
elseif (param == 203) then
rednet.broadcast("TS TurnLeft")
elseif (param == 205) then
rednet.broadcast("TS TurnRight")
elseif (param == 28) then
rednet.broadcast("TS PlaceBlock")
elseif (param == 72) then
rednet.broadcast("TS Up")
elseif (param == 80) then
rednet.broadcast("TS Down")
end
end
end
end
print("What side is your modem on?")
local modem = read()
rednet.open(modem)
term.clear()
textutils.slowPrint("TurtleControl Initiated.")
print ("Use arrow keys to move and Enter to place blocks.")
RCmaster()

Turtle
function RCslave()
while true do
local scrap, message = rednet.receive()
if message == "TS Forward" then
print("Forward")
if turtle.detect() == true then
turtle.dig()
end
turtle.forward()
elseif message == "TS Backward" then
print("Backward")
turtle.back()
elseif message == "TS TurnLeft" then
print("Turn Left")
turtle.turnLeft()
elseif message == "TS TurnRight" then
print("Turn Right")
turtle.turnRight()
elseif message == "TS PlaceBlock" then
if turtle.detect() == true then
print("Block Present")
else
print("Place Block")
turtle.place()
end
elseif message == "TS Up" then
print("Up")
elseif turtle.detectUp == true then
turtle.digUp
end
turtle.up()
elseif message == "TS Down" then
print("Down")
if turtle.detectDown() == true then
turtle.digDown()
end
turtle.down()
end
end
end
rednet.open("right")
textutils.slowPrint("TurtleReceive Initiated.")
RCslave()

Computer works fine, but turtle gives error. bios:338: [string "console"]:30: '=' expected

I never coded before, so I don't understand what is wrong.

#20 Dejected

  • Members
  • 48 posts
  • LocationPhiladelphia, Pennsylvania

Posted 22 July 2013 - 12:35 AM

This Is Nice Have You Updated It Recently?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users