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

Wireless Control

Started by kolya5544, 27 February 2017 - 05:42 PM
kolya5544 #1
Posted 27 February 2017 - 06:42 PM
I am noob in it and in this forum, but, can you try my program? It's wireless control under your turtle using your pocket phone!
Commands to download:
pastebin run 97n4FipP (TURTLE)
pastebin run eqAH4hvL (POCKET)
Medium button - refuel (16 slot)
Gray buttons - UP and DOWN
other buttons - forward, back, turnLeft, turnRight
Debug mode was enabled on turtle, and you can disable it
fishermedders #2
Posted 28 February 2017 - 02:12 AM
Your paste for the file 'controller' is private, see here.
Otherwise, the Turtle Client looks good - Just for future reference, it's nice to make your code look nice by indenting.

e.g

if command == 'up' then
  turtle.up()
end

I would also recommend the use of 'elseif', because there can only be one case per received rednet message, so you really don't need to check for all of them.

e.g

if command == 'up' then
  turtle.up()
elseif command == 'down' then
  turtle.down()
elseif command == 'forward' then
  turtle.forward()
elseif command == 'back' then
  turtle.back()
elseif command == 'left' then
  turtle.turnLeft()
elseif command == 'right' then
  turtle.turnRight()
elseif command == 'fuel' then
  turtle.select(16)
  turtle.refuel()
end

Another thing that would make/break this program (if it had the controller) is the ability to dig & place (with up varieties), and select (maybe clicking the button and then entering the slot number).

Also, where you have

id, command = rednet.receive()
I would recommend checking to see if the commands are coming from your pocket computer, like so.

--Run program 'id' on Pocket Computer to get id number.
id, command = rednet.receive()
if id == 1337 then -- This checks the received id to make sure you can only send commands.
  if command == "up" then
    turtle.up()
  elseif command == "other commands" then
    --etc
  end
end
This is useful because if someone else is receiving messages, they can broadcast these same commands and then potentially control your turtle.

Otherwise it looks good keep working on this homie :)/>.
kolya5544 #3
Posted 28 February 2017 - 05:21 AM
Oops, it will be public now. Also, thank you for advices, and i know about ElseIf. Now about a ID checking, i will try to create password or anything like this