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

Remote controlled turtle program

Started by Mackan90096, 05 March 2013 - 06:29 PM
Mackan90096 #1
Posted 05 March 2013 - 07:29 PM
Hi! I just finished Up My remote control turtle script.
You control it from an advanced computer.

The turtles script: pastebin get 1aqgwBgi startup

The controllers (computers) : pastebin get MctmJCHA startup

The functionalities:
Go forward
Go backwards
Turn left and right
Go Up and down
And dig

Pictures and stuff Will come.

Post your thoughts and suggestions and that stuff in The comments Please.


Edit:
To do list:
Add turtle.place() stuff
Add More turtle.dig() stuff
Add a thing for turtle to put items in chest(s) and get Theme back from there.
Add a thing for turtle to refuel,


Edit 2:
Im planning on rewriting the selection screen(s). With that i mean making categories instead of everything in just one place making it hard to have all the functionallities readable and selectable.
44shades44 #2
Posted 13 March 2013 - 09:01 PM
Hi there, My Firefox is being silleh, and i can't access your links, But here's my remote control program, it includes:
- Movement in each direction (up, down, left, right, forward, back)(With or without mining)
- Mining without moving in each direction (up, down, forward)
- Refuelling
- Placing Blocks Forward, Up and Down
- Attacking

I plan to include the use of Computer IDs so that more than 1 can be operational at a time.
A few other features are planned such as:
Smaller code, this one is getting large and repetative
Smarter refuelling, by scrolling through the inventory until it reaches something it can refuel through

here it is:

Computer code:
Spoilerterm.clear()
term.setCursorPos(1,1)
function RCmaster()
while true do
local sEvent, param = os.pullEvent("key")
if(sEvent == "key") then
if(param == 200) then
rednet.broadcast("RC MF")
elseif (param == 208) then
rednet.broadcast("RC B")
elseif (param == 203) then
rednet.broadcast("RC TL")
elseif (param == 205) then
rednet.broadcast("RC TR")
elseif (param == 28) then
rednet.broadcast("RC PF")
elseif (param == 72) then
rednet.broadcast("RC MU")
elseif (param == 80) then
rednet.broadcast("RC MD")
elseif (param == 17) then
rednet.broadcast("RC F")
elseif (param == 31) then
rednet.broadcast("RC B")
elseif (param == 30) then
rednet.broadcast("RC TL")
elseif (param == 32) then
rednet.broadcast("RC TR")
elseif (param == 71) then
rednet.broadcast("RC U")
elseif (param == 79) then
rednet.broadcast("RC D")
elseif (param == 57) then
rednet.broadcast("RC A")
elseif (param == 23) then
rednet.broadcast("RC DF")
elseif (param == 73) then
rednet.broadcast("RC DU")
elseif (param == 81) then
rednet.broadcast("RC DD")
elseif (param == 22) then
rednet.broadcast("RC PU")
elseif (param == 50) then
rednet.broadcast("RC PD")
elseif (param == 37) then
rednet.broadcast("RC RF")
end
end
end
end
print("What side is your modem on?")
local modem = read()
rednet.open(modem)
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("TurtleControl Initiated.")
print("Controls:")
print("")
print("Up arrow: Mine and move forward")
print("Down arrow: Move backwards")
print("Left/Right arrows: Turn Left/Right")
print("8/2: Mine and move Up/Down")
print("Placing Blocks:")
print("Enter: Place a block Front")
print("U/M: Place a block Up/Down")
print("Movement Commands (slightly faster):")
print("WASD: Forward, Left, Backward, Right")
print("7/1: Up/Down")
print("Mining Commands (Just mine, don't move:")
print("i: Mine front")
print("9/3: Mine Up/Down")
print("Spacebar: Attack!!")
print("K: Refuel (put Fuel in slot 1)")
RCmaster()

Turtle code:
Spoilerrednet.open("right")
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("TurtleReceive Initiated.")
function RCslave()
while true do
local scrap, message = rednet.receive()
if message == "RC MF" then
print ("Mine and Move Forward")
if turtle.detect() == true then
turtle.dig()
end
turtle.forward()
elseif message == "RC B" then
print ("Move Backward")
turtle.back()
elseif message == "RC TL" then
print ("Turn Left")
turtle.turnLeft()
elseif message == "RC TR" then
print ("Turn Right")
turtle.turnRight()
elseif message == "RC PF" then
if turtle.detect() == true then
print("Failed Place Block Front: Block Present")
else
print("Place Block Front")
turtle.place()
end
elseif message == "RC PU" then
if turtle.detectUp() == true then
print("Failed Place Block Up: Block Present")
else
print("Place Block Up")
turtle.placeUp()
end
elseif message == "RC PD" then
if turtle.detectDown() == true then
print("Failed Place Block Down: Block Present")
else
print("Place Block Down")
turtle.placeDown()
end
elseif message == "RC MU" then
print("Mine and Move Up")
if turtle.detectUp() == true then
turtle.digUp()
end
turtle.up()
elseif message == "RC MD" then
print("Mine and Move Down")
if turtle.detectDown() == true then
turtle.digDown()
end
turtle.down()
elseif message == "RC F" then
if turtle.detect() == true then
print("Move Forward Failed")
else
print("Move Forward")
turtle.forward()
end
elseif message == "RC U" then
if turtle.detectUp() == true then
print("Move Up Failed")
else
print("Move Up")
turtle.up()
end
elseif message == "RC D" then
if turtle.detectDown() == true then
print("Move Down Failed")
else
print("Move Down")
turtle.down()
end
elseif message == "RC A" then
print("ATTACK!!!")
turtle.attack()
elseif message == "RC DF" then
print("Mine Forward")
turtle.dig()
elseif message == "RC DU" then
print("Mine Up")
turtle.digUp()
elseif message == "RC DD" then
print("Mine Down")
turtle.digDown()
elseif message == "RC RF" then
print("Attempting Refuel")
if turtle.getFuelLevel() == 0 then
turtle.refuel(1)
if turtle.getFuelLevel() == 0 then
print("Refuel Failed: No fuel in first slot")
else
print("Refuel Success")
end
else
print("Refuel Failed: Turtle has fuel")
end
end
end
end
RCslave()

Hope you like it :D/>

also, spoilers dont include indenting, but i'm sure you can figure it out ;)/>

Edit1:
It would also be cool to use turtle.detect() to make a visual minimap on the screen, if you know how, that'd be great :D/>

Edit2:
i think im an idiot. Those code links arent websites, i need to do that ingame…
Kryptanyte #3
Posted 13 March 2013 - 10:34 PM
Edit1:
It would also be cool to use turtle.detect() to make a visual minimap on the screen, if you know how, that'd be great :D/>

That can be arranged. Maybe I could work on that after Sudoku?
44shades44 #4
Posted 13 March 2013 - 10:44 PM
Edit1:
It would also be cool to use turtle.detect() to make a visual minimap on the screen, if you know how, that'd be great :D/>

That can be arranged. Maybe I could work on that after Sudoku?

That'd Be great, i just added ID specifics to my code , i'll finish elimating bugs, the post the new one.
44shades44 #5
Posted 13 March 2013 - 10:47 PM
Should i start my own topic with my RC turtle?
Kryptanyte #6
Posted 13 March 2013 - 10:57 PM
Should i start my own topic with my RC turtle?

Probably would be the best Idea
44shades44 #7
Posted 13 March 2013 - 11:31 PM
"You cannot start a new topic" :S