Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
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

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
Reply to this topic...

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