drk Posted January 22, 2012 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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
50p Posted January 22, 2012 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
drk Posted January 22, 2012 Author Posted January 22, 2012 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
botanist Posted January 22, 2012 Posted January 22, 2012 Use "resourceRoot" instead of "getResourceRootElement(getThisResource())". resourceRoot is a predefined variable doing just that. Handling editor | Modloader
50p Posted January 22, 2012 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
drk Posted January 23, 2012 Author 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 '-' EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted January 24, 2012 Author Posted January 24, 2012 Anyone? .-. EPT Team Server Development: 0% Learning C++ | C++ is amazing
botanist Posted January 25, 2012 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. } Handling editor | Modloader
drk Posted January 25, 2012 Author 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? EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted January 25, 2012 Author Posted January 25, 2012 Thanks D: EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted January 27, 2012 Author 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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted January 27, 2012 Author Posted January 27, 2012 No one helps? EPT Team Server Development: 0% Learning C++ | C++ is amazing
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