hi i have a problem i have been trying to figure out for a few days now and i am drawing up a blank. I have to code below which i have to admit is not my own.
i have this saved as move.lua
local robot = require('robot')local component = require('component')local move ={}local commands ={}
commands['f']= robot.forward
commands['b']= robot.back
commands['u']= robot.up
commands['d']= robot.down
commands['tl']= robot.turnLeft
commands['tr']= robot.turnRight
commands['ta']= robot.turnAround
commands['s']= robot.swing
commands['sd']= robot.swingDown
commands['su']= robot.swingUp
commands['p']= robot.place
commands['pd']= robot.placeDown
commands['pu']= robot.placeUp
commands['dr']= robot.drop
commands['dru']= robot.dropUp
commands['drd']= robot.dropDown
commands['su']= robot.suck
commands['sud']= robot.suckDown
commands['suu']= robot.suckUp
commands['us']= robot.use
commands['usu']= robot.useUp
commands['usd']= robot.useDown
--if component.piston then-- commands['p']=component.piston.push--end--if component.inventory_controller then-- commands['e']=component.inventory_controller.equip--endfunction move.act(act)local status, reason, c
c = commands[act]if c then
status, reason = c()returnelse
print("Not found".. act)endifnot status thenendendfunction move.move(path)--path = ('f2,r,f1,b') for word in string.gmatch(path,'([^,]+)')dolocal num = string.match(word,'%d+')or1local word = string.match(word,'[^%d]+')for i=1,num do
move.act(word)endendend
if i pass the instructions to move the robot at the end of this script then it moves but when i try passing instructions to move the robot via a different script like below then i get an error
attempt to index a local 'move' ( a nil value)
the code i am using to pass the information is this
local move = require("move")for i=1,10do
move.move('f')end
move.move('b10')
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.
hi i have a problem i have been trying to figure out for a few days now and i am drawing up a blank. I have to code below which i have to admit is not my own.
i have this saved as move.lua
if i pass the instructions to move the robot at the end of this script then it moves but when i try passing instructions to move the robot via a different script like below then i get an error
attempt to index a local 'move' ( a nil value)
the code i am using to pass the information is this
anybody got any ideas.
thanks in advance
Link to post
Share on other sites