drk Posted January 22, 2012 Share Posted January 22, 2012 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
50p Posted January 22, 2012 Share Posted January 22, 2012 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. Link to comment
drk Posted January 22, 2012 Author Share Posted January 22, 2012 I created inside this: addEventHandler("onClientResourceStart", g_RootE, function() -- array ) I defined g_RootE = getResourceRootElement(getThisResource()) Link to comment
Deltanic Posted January 22, 2012 Share Posted January 22, 2012 Use "resourceRoot" instead of "getResourceRootElement(getThisResource())". resourceRoot is a predefined variable doing just that. Link to comment
50p Posted January 22, 2012 Share Posted January 22, 2012 Well, check the guiCreate.. function parameters. If relative is true, x, y, width and height must be values between 0 and 1. Link to comment
drk Posted January 23, 2012 Author Share Posted January 23, 2012 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
Deltanic Posted January 25, 2012 Share Posted January 25, 2012 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
drk Posted January 25, 2012 Author Share Posted January 25, 2012 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 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
drk Posted January 27, 2012 Author Share Posted January 27, 2012 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now