syn0nym Posted April 30, 2022 Share Posted April 30, 2022 So, i have a little problem about gui gridlist, i write a gridlist code and it run like this. https://ibb.co/n8T02cn local screenX, screenY = guiGetScreenSize() local table1 = {1, 2, 3, 4, 5} local table2 = {"Lorem ipsum dolor sit amet", "consectetur adipiscing elit", "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", "Ut enim ad minim veniam"} local gui = {} local windowX, windowY = 500, 300 gui["window"] = guiCreateWindow( (screenX/ 2) - (windowX/2), (screenY/2) - (windowY/2), windowX, windowY, "WINDOW", false) guiSetVisible (gui["window"], false ) gui["gridlist"] = guiCreateGridList ((windowX/2) - (450/2), 70, 450, 190, false, gui["window"]) gui["id-column"] = guiGridListAddColumn (gui["gridlist"], "ID", 0.1) gui["test-column"] = guiGridListAddColumn (gui["gridlist"], "Test", 0.8) for key, values in ipairs (table1) do for key1, values1 in ipairs (table2) do gui["rows"] = guiGridListAddRow (gui["gridlist"], values, values1) end end function startGUI () if guiGetVisible (gui["window"]) then guiSetVisible (gui["window"], false) showCursor (false) else guiSetVisible (gui["window"], true) showCursor (true) end end bindKey ("F3", "down", startGUI) it may some bug, i want to make the id dont same, example column 1 row 1 only return 1 id and lorem ipsum and forward. Please Help me & Sorry for bad english. Link to comment
Scripting Moderators Sarrum Posted May 1, 2022 Scripting Moderators Share Posted May 1, 2022 . You can do it this way: local tableSize = #table2 for key, values in ipairs (table1) do for key1, values1 in ipairs (table2) do gui["rows"] = guiGridListAddRow (gui["gridlist"], key1 + (values - 1) * tableSize, values1) end end You may also avoid using the first table if the goal is to repeat the loop several times: local tableSize = #table2 for i = 1, 5 do for key1, values1 in ipairs (table2) do gui["rows"] = guiGridListAddRow (gui["gridlist"], key1 + (i - 1) * tableSize, values1) end end 1 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