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

    • Lizzy Trickster

      Latest Stable OpenComputers Version   11/26/16

      The latest released version of OpenComputers is version 1.7.1 for MC 1.7.10, 1.10.2, 1.11.2 & 1.12.1. See more information here! Beta/Dev builds can be found at the Jenkins Build Server (ci.cil.li)
    • Lizzy Trickster

      !!FORUM DOWNTIME!!   01/16/18

      On 2018-01-27 the forums will be going down at around 1100 GMT0 for up-to 5 hours to allow for hardware configuration changes on the system that hosts these forums as well as various updates to patch recently publicised CPU vulnerabilities. Apologies for the inconvenience that this will cause.  If you would like to keep up-to-date on the progress of the work, join our IRC channel (http://webchat.esper.net/?nick=&channels=oc) or our Discord ( https://discord.gg/0hVukoQ2KYifZFCA ).
  • 0
Caput

Failing to bind GPU to screen

Question

I am working on a project that uses 2 screens and one GPU per screen.  My code selects each component by its address.  But when I try to bind a gpu to a screen I get the error: attempt to call field 'bind' (a nil value).

local component = require("component")
local term = require("term")
local gpu = component.get("3085")
local screen = component.get("40c6")

gpu.bind(screen)

I have verified that the addresses are correct and I have tried to assign the components to their full addresses.  I'm sure my mistake is pretty simple.  Any help would be greatly appreciated.

Thanks in advance.

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 1

Your error is indeed pretty simple. The method component.get returns the full address of a component, which is a string, not an object(table) with methods. In OC it's called a component proxy. Try this out and feel free to ask more questions either in this thread or via PM.

local component = require("component")
local term = require("term")
local gpu_address = component.get("3085") -- # this returns the components full address from an abbreviated one
local screen_address = component.get("40c6")

local gpu = component.proxy( gpu_address ) -- # get a 'proxy' to the gpu component
gpu.bind( screen_address ) -- # call .bind from the proxy

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×