Stanley Sathler Posted May 9, 2012 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. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Guest Guest4401 Posted May 9, 2012 Posted May 9, 2012 Try that in a for loop. getElementsByType("gui-button")
Jaysds1 Posted May 9, 2012 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 My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted May 9, 2012 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Stanley Sathler Posted May 9, 2012 Author 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 Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Castillo Posted May 9, 2012 Posted May 9, 2012 "ipairs" is used for indexed tables, yours isn't. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Stanley Sathler Posted May 9, 2012 Author Posted May 9, 2012 Solidsnake, and what is a "indexed tables"? When I use numbers (e.g: Button[1])? Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Guest Guest4401 Posted May 9, 2012 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
Stanley Sathler Posted May 9, 2012 Author 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. Software Engineer & Entrepreneur • Running Lustrel and VilarikA • Highly engaged on open source community
Castillo Posted May 9, 2012 Posted May 9, 2012 You're welcome . San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted May 9, 2012 Posted May 9, 2012 no problem, just doing my job:lol: My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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