How should I write it?global.inserter_guis[player.index] = player.gui.relative.add{
type = "frame",
caption = { "aaaaa" },
anchor = {................ },
{................}
}
player.gui.relative["?????"].destroy()
How should I write it?global.inserter_guis[player.index] = player.gui.relative.add{
type = "frame",
caption = { "aaaaa" },
anchor = {................ },
{................}
}
I haven't used player.gui.relative yet, but usually you could do something likesdgmlj wrote: ↑Thu May 19, 2022 3:16 amI want to close the GUI of other mods in my mod and replace it with my GUI, but his GUI doesn't have "name", so how can I close it? He wrote:How should I write it?global.inserter_guis[player.index] = player.gui.relative.add{
type = "frame",
caption = { "aaaaa" },
anchor = {................ },
{................}
}
player.gui.relative["?????"].destroy()
Code: Select all
for e, element in pairs(player.gui.top.children) do
game.print("Name of element "..e..": ".. element.name)
end
Never ever do that! Why do you think you're entitled to DESTROY some other mod's GUI? You can hide it, by making it invisible, but you shouldn't destroy it:player.gui.relative["?????"].destroy()
Code: Select all
for p, player in pairs(game.players) do
for e, element in pairs(player.gui.top.children) do
element.visible = false
end
end
Thank you. According to your method, it succeeded.Pi-C wrote: ↑Thu May 19, 2022 6:17 amI haven't used player.gui.relative yet, but usually you could do something likesdgmlj wrote: ↑Thu May 19, 2022 3:16 amI want to close the GUI of other mods in my mod and replace it with my GUI, but his GUI doesn't have "name", so how can I close it? He wrote:How should I write it?global.inserter_guis[player.index] = player.gui.relative.add{
type = "frame",
caption = { "aaaaa" },
anchor = {................ },
{................}
}
player.gui.relative["?????"].destroy()
Code: Select all
for e, element in pairs(player.gui.top.children) do game.print("Name of element "..e..": ".. element.name) end
Never ever do that! Why do you think you're entitled to DESTROY some other mod's GUI? You can hide it, by making it invisible, but you shouldn't destroy it:player.gui.relative["?????"].destroy()
Code: Select all
for p, player in pairs(game.players) do for e, element in pairs(player.gui.top.children) do element.visible = false end end