Posted 18 January 2016 - 01:12 PM
Hello experts, lately I have downloaded a program witch lets you remotely control a turtle. I have made a few tweaks to it and I've been trying to make the turtle excavate over wireless. 'Telling' the Turtle to run the program is easy, but it requires parameters. I've tried sending over a variable, but I don't think it's working, I'm not really sure how to send a variable actually but here's my code:
Computer:
Turtle:
Just to make sure I'm not taking all the credit, I downloaded code from here: http://www.computercraft.info/forums2/index.php?/topic/1373-remote-control-turtle-program/
I did make some tweeks like I said. Please help me! I'm quiet new to this thing! I'm very desparate. Please respond, thank you!
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 == 57) then
rednet.broadcast("TS Up")
elseif (param == 42) then
rednet.broadcast ("TS Down")
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 == 18) then
textutils.slowPrint ("Excavation size?")
local ExcavateSize = read()
rednet.broadcast ("TS Excavate (ExcavateSize)")
end
end
end
end
rednet.open("back")
term.clear()
textutils.slowPrint("TurtleControl Initiated.")
print ("Use arrow keys, space and Lshift 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 Up" then
print ("Upward")
turtle.up()
elseif message == "TS Down" then
print ("Downward")
turtle.down()
elseif message == "TS Excavate (ExcavateSize)" then
print ("Excavate (ExcavateSize)")
shell.run ("excavate")
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()
Just to make sure I'm not taking all the credit, I downloaded code from here: http://www.computercraft.info/forums2/index.php?/topic/1373-remote-control-turtle-program/
I did make some tweeks like I said. Please help me! I'm quiet new to this thing! I'm very desparate. Please respond, thank you!