I'm trying to create a program that will make a robot return to its 'home coordinates' no matter where it is in the world.
What I intend to do is to create a function that moves one step per call. As long as the current coordinates are not equal to the home coordinates, it will keep calling the 'move' function recursively. (I'm still relatively new to this mod, but I've done a bit or programming before... ^^)
I haven't taken into account about the direction that the robot is facing, Ill keep the direction constant while testing, and will work on that later...
For now, this is my code:
local robot = require("robot")
//these are the 'home coordinates'
x=-23
y=63
z=142
function move(
curX = debug.getX()
curY = debug.getY()
curZ = debug.getZ()
if curX = x and curY = y and curZ = z then
return
elseif curX < x then
robot.forward()
elseif curX > x then
robot back()
elseif curY < y then
robot.down()
elseif curY > y then
robot.up()
elseif curZ < z then
robot.left()
elseif curZ > z then
robot.right()
return move
end
)
move()
This probably looks like lousy programming, but I'm still trying to learn Lua, I'm more used to Java programming ^^.
Anyways, my problem is that when I try to run this, it keeps giving me and error saying:
return:7: ')' expected near '='
(return is the name of the script)
Could anyone help correct this error and any other errors in this script please?
Much appreciated!!!
Ash :3
PS: Also, if you have any ideas as to how to go about programming the part which takes the robot's direction into account, then by all means please share :3
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Link to post
Share on other sites