How do I access the event when left clicking entity
How do I access the event when left clicking entity
I'm trying to add a function when a user left clicks on an entity and I am having trouble.
Anyone have any insights?
Anyone have any insights?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: How do I access the event when left clicking entity
https://lua-api.factorio.com/latest/
You probably want to look for on_gui_opened, since clicking an entity usually opens a GUI.
You can then look at the entity variable to test it's type and name to see if it's the entity you want.
You probably want to look for on_gui_opened, since clicking an entity usually opens a GUI.
You can then look at the entity variable to test it's type and name to see if it's the entity you want.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How do I access the event when left clicking entity
You should describe what you actually want to do. More experienced modders might know a better method to achieve what you want. Hooking all left-clicks sounds excessive unless you're trying to write some sort of debug tool ;).
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: How do I access the event when left clicking entity
Yeah... I mean, you could write your own event triggered by left click, and then when it triggers check to see if there's an entity selected. I'm not going to go into that though unless you come back and request it.
It's a bit more involved, and I can't spare that time right now.
It's a bit more involved, and I can't spare that time right now.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How do I access the event when left clicking entity
That's the wrong approach btw. But i don't want to write details about how to do it correctly unless OP gives a very good reason he actually needs that.bobingabout wrote:Yeah... I mean, you could write your own event triggered by left click, and then when it triggers check to see if there's an entity selected.
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: How do I access the event when left clicking entity
I never really was that up on the scripting side, back in the early days, scripting broke things, so one of the promises of my mod was that I'd try to solve everything without using multiplayer breaking or game slowdown scripting.eradicator wrote:That's the wrong approach btw. But i don't want to write details about how to do it correctly unless OP gives a very good reason he actually needs that.bobingabout wrote:Yeah... I mean, you could write your own event triggered by left click, and then when it triggers check to see if there's an entity selected.
and I've pretty much kept that promise, there is scripting in select places where it was required, but nothing that should break multiplayer or cause slow downs.
in any case, there are a lot of ways to do things, and some are better than others.
Re: How do I access the event when left clicking entity
bobingabout wrote:I never really was that up on the scripting side, back in the early days, scripting broke things, so one of the promises of my mod was that I'd try to solve everything without using multiplayer breaking or game slowdown scripting.eradicator wrote:That's the wrong approach btw. But i don't want to write details about how to do it correctly unless OP gives a very good reason he actually needs that.bobingabout wrote:Yeah... I mean, you could write your own event triggered by left click, and then when it triggers check to see if there's an entity selected.
and I've pretty much kept that promise, there is scripting in select places where it was required, but nothing that should break multiplayer or cause slow downs.
in any case, there are a lot of ways to do things, and some are better than others.
I stumbled into what you were talking about here, bob. I didn't realize custom inputs could have key sequence = mouse-button-n. I like that approach. I don't mind if I break multiplayer for now. I just want a working proof of concept.
Re: How do I access the event when left clicking entity
Thank you all for your replies!
I'm stoked. I think I can get my mod working how I want it (for now)!
I'm stoked. I think I can get my mod working how I want it (for now)!
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How do I access the event when left clicking entity
Gnarf. Please use a linked_game_control instead of an arbitrary mouse button if you're going that way...
(The wiki seems down so i can't post a link.)
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: How do I access the event when left clicking entity
https://wiki.factorio.com/Prototype/Cus ... me_control :)eradicator wrote: ↑Tue Sep 11, 2018 12:49 pmGnarf. Please use a linked_game_control instead of an arbitrary mouse button if you're going that way...
(The wiki seems down so i can't post a link.)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How do I access the event when left clicking entity
I still get a 404 on that.Bilka wrote: ↑Tue Sep 11, 2018 1:00 pmhttps://wiki.factorio.com/Prototype/Cus ... me_control :)eradicator wrote: ↑Tue Sep 11, 2018 12:49 pmGnarf. Please use a linked_game_control instead of an arbitrary mouse button if you're going that way...
(The wiki seems down so i can't post a link.)
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: How do I access the event when left clicking entity
ctrl + F5, restarting my browser, or using a private window have helped for that throughout today, though for me everything is working now.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: How do I access the event when left clicking entity
Refreshing did indeed work. Why is the wiki redirecting from wiki.factorio.com to wikix.factorio.com though?
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: How do I access the event when left clicking entity
they just updated the forum software, maybe they're experimenting with a wiki update too?