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

Can't access components

Question

I was trying to make a computer program to control a BigReactor turbine (I'll use a microcontroller after I figure this out). I know that the computer port acts as a component, so first of all, to increase the convenience of access of the computer port, I wrote

local turbine = component.proxy(component.get("5e7"))

That was the very first line of the program; 5e7 is the shortened address of the computer port. There is a bunch more code at the bottom that does the actual regulating, but when I run the program, it spits out this error message:

/home/turbine_control:1: attempt to index global 'component' (a nil value):
stack traceback:
	/home/turbine_control:1: in main chunk:
    (...tail calls...)
    [C]: in function 'xpcall'
    machine:751: in function 'xpcall'
    /lib/process.lua:94: in function </lib/process.lua:90>

Greatly confused, I read the message. I interpreted it as in line one of my program, turbine_control, I am accessing the undefined variable 'component'. I don't know what this completely means, and I even checked the process.lua function and coming out with no idea what was going on. I can call the function in the interactive lua prompt with no problem, but in a program, it doesn't let me.

What's going on, and how can I fix this?

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

For a computer you have to do

local component = require("component")

In the lua interpreter you don't have to require stuff like you do in scripts

For a microcontroller... well you don't get require there so you'll have to do it lower level and I'm not sure how that works :P

Link to post
Share on other sites
  • 0
On 2/19/2017 at 9:02 PM, Michiyo said:

For a computer you have to do


local component = require("component")

In the lua interpreter you don't have to require stuff like you do in scripts

For a microcontroller... well you don't get require there so you'll have to do it lower level and I'm not sure how that works :P

In eeprom code the component table is never removed from global table so it's fine to use, and his original code should work on a microcontroller since he doesn't use any of the component api additions added by openos.

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.