No. A shared resource can be arbitarily altered without my knowledge or consent. I am forced to share it with people i don't even know. That's exactly what GUI is. An exclusive resource is controlled soley by me and i am guaranteed that nobody messes around with it. "Good practice" is an afterthought that you can not rely on.Creidhne wrote: βThu Aug 27, 2020 11:26 amIf you trully consider the GUIs as a shared resource, then it heavily contradicts with your 1st statement (which is pretty much the definition of an exclusive resource).eradicator wrote: βWed Aug 26, 2020 7:59 pm Manipulating the *inside* of other mods guis is ofc broken.
TL;DR: The easiest method to deal with it is to properly check existance and .valid before you try to use a shared resource (gui, rendering, inventory, etc).
That might be true. But what if my gui is *also* really important? What if the player dies during the scenarios surface switching menu and i need to display a respawn window now? I think i'll just switch everything to gui.screen.
Please stop putting words in my mouth. I am talking soley about gui.center. Clearing anything else is broken.
Changing the *content* of a gui is broken and might even be malicious. No argument there. If somebody were to resize your window there wouldn't even *be* a way to detect that.
Oh but btw, when you create a new element in gui.center, do you actually check that gui.center is empty? Because if you blindly create new stuff there you might leave *both* mods in a broken state when elements are getting pushed off the screen. And that problem is even more fun when idiots start putting *invisible* stuff in gui.center where you have no idea when it becomes visible again.
Thinking about it again gui.center is probably a relic of the past and gui.screen should be used instead because there's no fighting for screen positions there, worst that happens is that stuff overlaps.
Ye know, that would solve soo many problems. It would even make it possible to reorder top/left buttons by calling delete/create on them. But it's not really realistic, the community hasn't even managed to decided on a common modding framework. Everybody just does their own stuff. And it would only help if any other interaction with other mods guis would simultaenously be blocked - and that's basically a rewrite of the gui system. Aaand if the devs wanted to do that why did they design it as a shared resource in the first place.
I don't know how your mods work. If you properly handle player.opened you're likely not affected at all. If you don't then your mod is likely broken anyway.
Also the topic isn't really about you - or me. It's about @OP wanting to not have his mod crash. And the only way to get that is to properly check existance of the root gui element. There's currently 12 on_gui_* events, so that's at maximum 12 calls to a one-line check function. Probably much less because if your gui doesn't exist anymore you don't get events for it anyway (unless your event.element check is utterly broken too). So, it's either this or running around crying that other mods are evil and spamming incompatibilities and medieval public shaming and dealing with users complaining when yet another mod breaks yours. It's an uphill battle you can't win.
Maybe you've only dealt with GUI modding so far, but this shit happens everyday with entities. There's tons of mods that don't properly raise destroy/revive and it's easier to make your own mod more resiliant than to try and track down and convince everybody of "the right way". And devs are ignoring it because changing the defaults to destroy{raise=true} etc "could break some mods".