[Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 1077
Joined: Fri Nov 06, 2015 7:41 pm
Contact:

[Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by Deadlock989 » Wed Aug 14, 2019 1:42 pm

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 *

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3250
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by eradicator » Wed Aug 14, 2019 1:55 pm

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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 3748
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by Klonan » Wed Aug 14, 2019 2:50 pm

eradicator wrote:
Wed Aug 14, 2019 1:55 pm
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.
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.

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

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3250
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by eradicator » Wed Aug 14, 2019 3:17 pm

Klonan wrote:
Wed Aug 14, 2019 2:50 pm
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
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: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 3748
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by Klonan » Wed Aug 14, 2019 3:26 pm

eradicator wrote:
Wed Aug 14, 2019 3:17 pm
but adding a generic empty(!) gui to every simple entity is a bad idea.
It would be trivial to have it optional with a simple bool in the prototype

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3250
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by eradicator » Wed Aug 14, 2019 3:38 pm

Klonan wrote:
Wed Aug 14, 2019 3:26 pm
eradicator wrote:
Wed Aug 14, 2019 3:17 pm
but adding a generic empty(!) gui to every simple entity is a bad idea.
It would be trivial to have it optional with a simple bool in the prototype
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).
Author of: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 3748
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by Klonan » Wed Aug 14, 2019 5:20 pm

eradicator wrote:
Wed Aug 14, 2019 3:38 pm
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).
Sure, but what mod is adding a simple-entity but only wanting to use it in a scenario?

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:
Image

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

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 1077
Joined: Fri Nov 06, 2015 7:41 pm
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by Deadlock989 » Wed Aug 14, 2019 11:18 pm

Klonan wrote:
Wed Aug 14, 2019 5:20 pm
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:
Image

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
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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3250
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by eradicator » Thu Aug 15, 2019 1:15 am

Klonan wrote:
Wed Aug 14, 2019 5:20 pm
eradicator wrote:
Wed Aug 14, 2019 3:38 pm
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).
Sure, but what mod is adding a simple-entity but only wanting to use it in a scenario?
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 pm
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:
Image

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
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.
Deadlock989 wrote:
Wed Aug 14, 2019 11:18 pm
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.
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.
Author of: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 1448
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by BlueTemplar » Thu Aug 15, 2019 1:56 pm

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).
What happened to stdlib ?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 3250
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by eradicator » Fri Aug 16, 2019 7:42 am

BlueTemplar wrote:
Thu Aug 15, 2019 1:56 pm
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).
What happened to stdlib ?
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.)
Author of: Hand Crank Generator, Screenshot Hotkey 2.0
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

slippycheeze
Filter Inserter
Filter Inserter
Posts: 436
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: [Request] on_gui_opened event (or similar) for SimpleEntityWithForce

Post by slippycheeze » Fri Aug 16, 2019 6:04 pm

BlueTemplar wrote:
Thu Aug 15, 2019 1:56 pm
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).
What happened to stdlib ?
Several developers have strongly negative views on it, which is not the most encouraging factor in support of a "common" library.

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.

Post Reply

Return to “Modding interface requests”

Who is online

Users browsing this forum: No registered users