Stanley Sathler Posted May 9, 2012 Share Posted May 9, 2012 Hi guys, I'm trying get all elements (gui-widgets) from a Window (like a getElementsByType()). I'm creating this code (resume): SATHLER_Button["btn_mute"] = guiCreateButton(170, 75, 100, 30, "Mute", false, ModPanelMainWindow) SATHLER_Button["btn_kick"] = guiCreateButton(275, 75, 100, 30, "Kick", false, ModPanelMainWindow) * Obs: I have many other buttons. It is just a part. I wanna set the font to all my buttons using: guiSetFont() I'm trying use a loop (in ipairs(), for example) to avoid much work. If I change the "btn_mute" and "btn_kick" (strings) to numbers (1 and 2), can I use: for i, v in ipairs(SATHLER_Label) do guiSetFont(SATHLER_Button[i], "default-bold-small") guiLabelSetColor(SATHLER_Button[i], 255, 0, 0) end But I'm not using numbers, I'm using strings to make easier identification. How can I set the font to all elements using a loop? Can I do it? Or to do it I'll use numbers (example: SATHLER_Button[1] and SATHLER_Button[2]) ? Thanks alot guys, Stanley Sathler. Link to comment
Guest Guest4401 Posted May 9, 2012 Share Posted May 9, 2012 Try that in a for loop. getElementsByType("gui-button") Link to comment
Jaysds1 Posted May 9, 2012 Share Posted May 9, 2012 (edited) try this: SATHLER_Button = {} SATHLER_Button["btn_mute"] = guiCreateButton(170, 75, 100, 30, "Mute", false) SATHLER_Button["btn_kick"] = guiCreateButton(275, 75, 100, 30, "Kick", false) for i, v in pairs(SATHLER_Button) do guiSetFont(v, "default-bold-small") end I've tested it and it works Edited May 9, 2012 by Guest Link to comment
Castillo Posted May 9, 2012 Share Posted May 9, 2012 SATHLER_Button = { } SATHLER_Button [ "btn_mute" ] = guiCreateButton(170, 75, 100, 30, "Mute", false) SATHLER_Button [ "btn_kick" ] = guiCreateButton(275, 75, 100, 30, "Kick", false) for name, button in pairs ( SATHLER_Button ) do guiSetFont ( button, "default-bold-small" ) end Link to comment
Stanley Sathler Posted May 9, 2012 Author Share Posted May 9, 2012 (edited) Karthik184, in this example don't work. But the information is useful for me, but maybe I'll need it later. - Jaysds, working now. I was using "ipairs()", and not "pairs()". Can you say the difference? - Solidsnake, thanks you too, man. Thanks all you guys, for the constant help =) Edited May 9, 2012 by Guest Link to comment
Castillo Posted May 9, 2012 Share Posted May 9, 2012 "ipairs" is used for indexed tables, yours isn't. Link to comment
Stanley Sathler Posted May 9, 2012 Author Share Posted May 9, 2012 Solidsnake, and what is a "indexed tables"? When I use numbers (e.g: Button[1])? Link to comment
Guest Guest4401 Posted May 9, 2012 Share Posted May 9, 2012 Solidsnake, and what is a "indexed tables"? When I use numbers (e.g: Button[1])? Yes, Someone asked the difference between them about it before, and people have given proper explanation too. Head on : viewtopic.php?f=91&t=42884 Link to comment
Stanley Sathler Posted May 9, 2012 Author Share Posted May 9, 2012 Oh damn, thank you so much for answer, Karthik. I understood perfectly. (: - Solidsnake and Jaysds, thanks alot too, homies. You're always helping me here. Link to comment
Jaysds1 Posted May 9, 2012 Share Posted May 9, 2012 no problem, just doing my job:lol: 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