Jump to content




Wireless Turtle Help


1 reply to this topic

#1 habnef3

  • Members
  • 3 posts

Posted 23 August 2015 - 03:29 AM

Hi, I'm having trouble with making programs that let me execute commands wireless from a computer to a turtle.

I have the following program for the computer
Spoiler

and this one is for the turtle.

Spoiler

When ran the main computer seems the be working fine, but the turtle just shows a blank line and then ends.
All help is appreciated.

#2 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 23 August 2015 - 05:52 AM

I think you swapped the two pieces of code.
But I believe I see the problem:

The turtle might have something like this:
rednet.open("right")

term.write("Enter Command: ")
local cmd = read() --# 'local' makes the variable only part of this program. Its good practice. 'read()' is likely the same as 'io.read()' but slightly shorter

rednet.broadcast( cmd )

The problem is in your computer code
It should look like this:
rednet.open("right")

local id , msg = rednet.recieve() --# Assigns the id of the sender and the msg to these local variables

shell.run( msg ) --# HUGE security flaw - runs any command it gets! But ok for experimenting

You might notice that you have to run the program on the turtle and the computer everytime you want this to work.
You can solve this problem with a loop:
http://www.lua.org/pil/4.3.2.html





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users