[Request] on_gui_opened event (or similar) for SimpleEntityWithForce
- Deadlock989
- Smart Inserter
- Posts: 2529
- Joined: Fri Nov 06, 2015 7:41 pm
[Request] on_gui_opened event (or similar) for SimpleEntityWithForce
Getting a GUI out of a S.E.W.F. is a bit cumbersome at present - you can do it with shenanigans, but no-one likes shenanigans.
It would be great (and apparently popular) if we could catch a simple click on a S.E.W.F and open a mod gui.
* Bambi eyes *
It would be great (and apparently popular) if we could catch a simple click on a S.E.W.F and open a mod gui.
* Bambi eyes *
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
I've always used a custom-input linked_control="open-gui" with "if player.selected== then" for this, and never thought much about it as i need the linked_control for so many different things anyway. So at that point you might as well ask for a generic on_input_action event which then tells you which input-action was triggered (and would make linked_control obsolete). But i thought the point of linked_control was to not have to have an event for everything, but only for things that a mod cares about.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
Yes, but then all mods have to repeat the same code of adding a hotkey, setting up the event receiving for all of that hotkey, etc.eradicator wrote: ↑Wed Aug 14, 2019 1:55 pmI've always used a custom-input linked_control="open-gui" with "if player.selected== then" for this, and never thought much about it as i need the linked_control for so many different things anyway. So at that point you might as well ask for a generic on_input_action event which then tells you which input-action was triggered (and would make linked_control obsolete). But i thought the point of linked_control was to not have to have an event for everything, but only for things that a mod cares about.
I think it would be nice to have, just click on the entity, and it will show a simple GUI, and if the modder wants, it can be overriden by checking on_gui_opened
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
I'm totally for making custom guis easier (guess who wrote the request for linked_control in the first place ;)), but adding a generic empty(!) gui to every simple entity is a bad idea. It would force every mod that doesn't want a gui (which i'd think are the majority) to add extra code to close the empty gui. That's just shifting the hackiness somewhere else, not removing it. If there was a community accepted "main library" mod it would be trivial to add the hotkey to that mod, but sadly the factorio community hasn't agreed on such a thing yet. And there are far more common "everyone is reinventing the wheel" problems than this (just look at stdlib).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
It would be trivial to have it optional with a simple bool in the prototypeeradicator wrote: ↑Wed Aug 14, 2019 3:17 pmbut adding a generic empty(!) gui to every simple entity is a bad idea.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
Contrary to a data-stage solution an event based solution would work in scenarios though, and would be independant of entity type. (If you're already hellbound on replacing linked_control for this usecase you might as well make the new thing not less useful).Klonan wrote: ↑Wed Aug 14, 2019 3:26 pmIt would be trivial to have it optional with a simple bool in the prototypeeradicator wrote: ↑Wed Aug 14, 2019 3:17 pmbut adding a generic empty(!) gui to every simple entity is a bad idea.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
Sure, but what mod is adding a simple-entity but only wanting to use it in a scenario?eradicator wrote: ↑Wed Aug 14, 2019 3:38 pmContrary to a data-stage solution an event based solution would work in scenarios though, and would be independant of entity type. (If you're already hellbound on replacing linked_control for this usecase you might as well make the new thing not less useful).
What I am saying is, the simple-entity prototype would have a flag `gui_enabled = true`, and then it will show a simple GUI when clicked, like the almost empty accumulator widget:
Then in scripting, you can check the on_gui_opened event to see if it was this specific simple entity, and if so, open your own GUI
- Deadlock989
- Smart Inserter
- Posts: 2529
- Joined: Fri Nov 06, 2015 7:41 pm
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
Would work for me. The linked control thing works, but has pain-in-the-neck consequences to look out for such as fast-replace, checking it's within reach etc. The player.opened interception thing in on_gui_opened would work just like every other entity that has a gui. Simples.Klonan wrote: ↑Wed Aug 14, 2019 5:20 pmWhat I am saying is, the simple-entity prototype would have a flag `gui_enabled = true`, and then it will show a simple GUI when clicked, like the almost empty accumulator widget:
Then in scripting, you can check the on_gui_opened event to see if it was this specific simple entity, and if so, open your own GUI
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
It would work for non-simple-entity, it would work for allowing opening of guis beyond the enforced "reach" of the character if a scenario so desires. And it would work for any entities that the scenario didn't add itself. I simply think it's the more *flexible* solution.Klonan wrote: ↑Wed Aug 14, 2019 5:20 pmSure, but what mod is adding a simple-entity but only wanting to use it in a scenario?eradicator wrote: ↑Wed Aug 14, 2019 3:38 pmContrary to a data-stage solution an event based solution would work in scenarios though, and would be independant of entity type. (If you're already hellbound on replacing linked_control for this usecase you might as well make the new thing not less useful).
What i'm saying is that this is adding a "garbage" gui element whichs only purpose is to be destroyed by the mod during the subsequent event. If that isn't an ugly hack then my definition of "ugly" must be outdated. Might as well *just* call the event without creating garbage.Klonan wrote: ↑Wed Aug 14, 2019 5:20 pmWhat I am saying is, the simple-entity prototype would have a flag `gui_enabled = true`, and then it will show a simple GUI when clicked, like the almost empty accumulator widget:
Then in scripting, you can check the on_gui_opened event to see if it was this specific simple entity, and if so, open your own GUI
The reach thing is a feature to me that allows me to have custom logic for it. Haven't had to deal with fast-replaceable simple entities yet, but i see that that could be annoying.Deadlock989 wrote: ↑Wed Aug 14, 2019 11:18 pmThe linked control thing works, but has pain-in-the-neck consequences to look out for such as fast-replace, checking it's within reach etc. The player.opened interception thing in on_gui_opened would work just like every other entity that has a gui. Simples.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
- BlueTemplar
- Smart Inserter
- Posts: 2421
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
What happened to stdlib ?eradicator wrote: ↑Wed Aug 14, 2019 3:17 pm[...]
If there was a community accepted "main library" mod it would be trivial to add the hotkey to that mod, but sadly the factorio community hasn't agreed on such a thing yet. And there are far more common "everyone is reinventing the wheel" problems than this (just look at stdlib).
BobDiggity (mod-scenario-pack)
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
I was thinking more on the level of Minecraft Forge. I.e. a library *everybody* uses. Stdlib is - as far as i can tell - mostly used by modding beginners, and all the experienced modders use their own libraries. (And before 0.17 cross-mod-require it was also a pain to use.)BlueTemplar wrote: ↑Thu Aug 15, 2019 1:56 pmWhat happened to stdlib ?eradicator wrote: ↑Wed Aug 14, 2019 3:17 pm[...]
If there was a community accepted "main library" mod it would be trivial to add the hotkey to that mod, but sadly the factorio community hasn't agreed on such a thing yet. And there are far more common "everyone is reinventing the wheel" problems than this (just look at stdlib).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
-
- Filter Inserter
- Posts: 587
- Joined: Sun Jun 09, 2019 10:40 pm
- Contact:
Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce
Several developers have strongly negative views on it, which is not the most encouraging factor in support of a "common" library.BlueTemplar wrote: ↑Thu Aug 15, 2019 1:56 pmWhat happened to stdlib ?eradicator wrote: ↑Wed Aug 14, 2019 3:17 pm[...]
If there was a community accepted "main library" mod it would be trivial to add the hotkey to that mod, but sadly the factorio community hasn't agreed on such a thing yet. And there are far more common "everyone is reinventing the wheel" problems than this (just look at stdlib).
That said, I'd suggest that a single library that does everything is a bad plan, and a much better one would be a "common" library that did the one specific thing. That way it is able to be focused, doesn't need serve every need, and doesn't have the challenge of designing to be everything for everyone.
Truth be told, most "standard" libraries end up being worked around as much as helpful, unless they are "standard" in the sense of "they *ARE* the API". Better to have a larger number of more focused libraries, each solving a more specific problem, but doing it well.