Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0

Keep getting error when running


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
--if component.inventory_controller then
--	commands['e']=component.inventory_controller.equip
function move.act(act)
	local status, reason, c
	c = commands[act]
	if c then
		status, reason = c()
		print("Not found" .. act)
	if not status then
function move.move(path)
	--path = ('f2,r,f1,b') 
	for word in string.gmatch(path, '([^,]+)') do
		local num = string.match(word, '%d+') or 1
		local word = string.match(word, '[^%d]+')
		for i=1,num do

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,10 do


anybody got any ideas.

thanks in advance

Share this post

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
2 hours ago, payonel said:

you need to return your library object from your library file, i.e. add "return move" at the end of "move.lua"

thanks. could not see for looking. 

Share this post

Link to post
Share on other sites

Join the conversation

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.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.