In RCS-you should add an id check, but it is an good program.
Remote Control Turtle Program
Started by CastleMan2000, Apr 22 2012 12:05 AM
turtle computer wireless
22 replies to this topic
#21
Posted 16 August 2013 - 11:51 AM
#22
Posted 29 December 2013 - 01:49 PM
tytynguyen, on 27 April 2012 - 02:26 PM, said:
How did you know where the keys were?(Params) Is there a list somewhere?
50505050G, 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.
you can do it like that :
edit keys
--insert
while true do print(os.pullEvent()) end
--save
--exit
keys
its from some tutorial and i use it from time to time ...
Edited by Conan1981m, 31 December 2013 - 05:54 AM.
#23
Posted 21 July 2014 - 11:49 PM
MonsterKiLL, on 21 July 2013 - 05:55 AM, said:
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
Turtle
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.
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.
On line 29, you write 'turtle.digUp' without the parameters. Try 'turtle.digUp()'
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


This topic is locked









