Jump to content

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


drk

Recommended Posts

Posted

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.

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

I created inside this:

addEventHandler("onClientResourceStart", g_RootE, 
function() 
-- array 
) 

I defined g_RootE = getResourceRootElement(getThisResource())

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted
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 '-'

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

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

Posted
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?

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

Posted

I have to create gui's out of table and the children gui elements inside the table?

Edit: And making a table global, like this?

local guiElements = { } 

Sorry for being noob :(

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

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