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

Robot Programming Problem

Question

I'm attempting to write my first programs for a robot, but I'm running into a wall (figuratively). I wrote the following test script and saved it on a floppy:

for i=0,10 do
  robot.forward()
end

for i=0,10 do
  robot.back()
end

The floppy is mounted in the robot, but whenever I attempt to execute it, I receive this error:

/mnt/fa8/robot_sandbox.lua:2: attempt to index global 'robot' (a nil value)

If I run it manually after running lua directly, it runs fine. What am I missing? Do I need an import of some sort in the script?

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I want to elaborate on this answer a bit, because I guess we will get questions like this more often:

 

You have to require any library that is not mentioned on the page about standard libraries. The lua prompt tries to require libraries for you, so you won't have to do it yourself, this makes for easier testing. 

So if you have a similar problem with a different library, do with your library what pcman312 did for robot, because that is the correct way to load a library. 

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.

Guest
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.

Loading...

×
×
  • Create New...

Important Information

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