Jump to content

It's possible to create GUI elements in a table?


drk

Recommended Posts

It's possible to create GUI elements in a table and use that to set's visible/invisible all the elements like that?

local example = { 
theButton = guiCreateButton(234,567,123,394,"Start!",true), 
theWindow = guiCreateStaticImage(234,234,234,234,"images/window.png",false) 
} 
  

I think that array isn't right but it possible to create elements in a table like this?

I tried to make like this, but got nil.

Link to comment
If the table is created outside any function, you will most likely get nil. Make the table global first and then create the elements in a function which is called by an event, like onClientResourceStart.

table.insert? .-.

Like this?

local example = { } 
local guiElements = { 
           [1] =  'example = guiCreateWindow(-------------)', 
           [2] =  'exampletw = guiCreateButton(--------------)' 
} 
  
function createElements() 
          for i, elements in ipairs(guiElements) do 
             table.insert(example, elements) 
     end 
end 
addEventHandler('onClientResourceStart', resourceRoot, createElements) 

Sorry for noob lua '-'

Link to comment

No, more like this

local window = guiCreateWindow ( ... ) 
local guiElements = { 
     -- Here we store the window element into the table you want 
    window = window, 
  
     -- Here we use window as the last argument so the button and label will be a child of the window. 
    button = guiCreateButton ( ..., window ), 
    label = guiCreateLabel ( ..., window ) 
  
    -- Moar elements. But keep in mind, you cannot use and element created here to another root. 
    -- So for example, you cannot create a tab panel and give the tab panel items in the table. 
} 
  

Link to comment
No, more like this
local window = guiCreateWindow ( ... ) 
local guiElements = { 
     -- Here we store the window element into the table you want 
    window = window, 
  
     -- Here we use window as the last argument so the button and label will be a child of the window. 
    button = guiCreateButton ( ..., window ), 
    label = guiCreateLabel ( ..., window ) 
  
    -- Moar elements. But keep in mind, you cannot use and element created here to another root. 
    -- So for example, you cannot create a tab panel and give the tab panel items in the table. 
} 
  

Ah xD Then, I have to create the GUI elements like yours and add elements like you said ( items on the tab panel ) out of the table, right?

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...