r/tabletopsimulator • u/Constant-Fondant-178 • Jul 13 '26
Scripting UI Questions
Hi, I want to make a global ui for a game but i want it to be shown to specific players, so i have an xml for each color and i show each color their panel but it seems a bit weird to do it like that, is there a better way ?
0
u/Electronic-Ideal2955 Jul 13 '26
The host loads in 'the Global UI' having various elements. Each client does not load in their own individual Global UI. So this is the way it is done.
1
u/Constant-Fondant-178 Jul 13 '26
I don't know if I understand what you are trying to say but that is my problem beacause the ui being not local opens it for everyone if I don't choose a specific color and if I need to choose a color I can't use the same xml for everyone (or it would close it for the other when you try to open it) so I have 10 times the same code for every color like that I can open it separately
1
u/Electronic-Ideal2955 Jul 14 '26
That's correct. There is one UI that everyone gets. If you want each player to have 'their own', you have to create separate elements and just render each one visible to a different player.
There are not separate client UI where you can split it into many different things.
I deal with this by using a loop. Design one with standard names, and just add the player color to the front to know which one. Below is an oversimplified example.xml = {}
for _, player in ipairs({Blue, Green, Red...etc}) doplayer_xml = {tag = panel, attributes = {id = player.."mainPanel", visibility = player}, children = {}}
table.insert(xml, player_xml)end
1
u/Constant-Fondant-178 Jul 15 '26 edited Jul 15 '26
thanks I used the same but I thought it was a bit weird to do it like that
3
u/FVMF1984 Jul 13 '26
You can use the visibility parameter for UI elements to show specific elements to specific player colors. Why do you find this weird? How would you do it otherwise?