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 ).
The Simon

Trouble with Lua

Recommended Posts

Hi!

I'm trying to do buttons in a OpenComputers addon OpenGlasses. But it seem to have problems with calling the element from the table. I am not very used to Lua and this is my first big project I'm working on in Lua.

local component = require("component")
local glasses = component.glasses
local buttons = {}

local function newButton(name,x,y,w,h,cR,cG,cB)
  buttons[name] = {
    rect = glasses.addRect(),
    pos = {x,y},
    size = {w,h},
    colo = {cR,cB,cG}
  }
  buttons[name][rect].setPosition(buttons[name][pos][1],buttons[name][pos][2]) --Here it says the value is null.
  buttons[name][rect].setSize(buttons[name][size][1],buttons[name][size][2])
  buttons[name][rect].setColor(buttons[name][colo][1],buttons[name][colo][2],buttons[name][colo][3]) --And probably here too...
end

newButton("box1",2,2,10,10,255,0,0)

 

It says the variable it's trying to reach is null for some reason. Any help would be appreciated.

ErrorLua1.png

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

×