click event
-
- Fast Inserter
- Posts: 193
- Joined: Fri May 06, 2016 10:35 pm
- Contact:
click event
Is there an event that fires whenever a player clicks? Or, even better, when a player clicks with a given item in their selection hand?
-
- Inserter
- Posts: 47
- Joined: Fri Mar 17, 2017 9:19 pm
- Contact:
Re: click event
if you look in the factorio documentation for the defines.events
if your trying to capture the player building something there is
defines.events.on_built_entity
defines.events.on_put_item
it does not list an event specifically for clicks./Factorio/doc-html/defines.html#defines.events
if your trying to capture the player building something there is
defines.events.on_built_entity
defines.events.on_put_item
Re: click event
Factorio doesn't generate events for clicks that do nothing as that wastes CPU time and would increase the network load in multplayer.
Only events that actually trigger some game action are processed and result in some event being fired.
Only events that actually trigger some game action are processed and result in some event being fired.
If you want to get ahold of me I'm almost always on Discord.
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: click event
Nope, there is no event for this.Bizobinator wrote:Is there an event that fires whenever a player clicks?
There is, however, an event for this: http://lua-api.factorio.com/latest/even ... n_put_itemBizobinator wrote:Or, even better, when a player clicks with a given item in their selection hand?
-
- Fast Inserter
- Posts: 193
- Joined: Fri May 06, 2016 10:35 pm
- Contact:
Re: click event
Supercheese wrote:Nope, there is no event for this.Bizobinator wrote:Is there an event that fires whenever a player clicks?
There is, however, an event for this: http://lua-api.factorio.com/latest/even ... n_put_itemBizobinator wrote:Or, even better, when a player clicks with a given item in their selection hand?
Yeah. I've read a bit of the code in a different mod. So, with that event, is it possible to, in between the starting to place & the entity being created, to have some code that stops the entity placement (& thus keeps the item in hand)?
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: click event
Yes: https://github.com/Suprcheese/Orbital-I ... #L386-L397Bizobinator wrote:Yeah. I've read a bit of the code in a different mod. So, with that event, is it possible to, in between the starting to place & the entity being created, to have some code that stops the entity placement (& thus keeps the item in hand)?
-
- Fast Inserter
- Posts: 193
- Joined: Fri May 06, 2016 10:35 pm
- Contact:
Re: click event
Excellent! Yay!Supercheese wrote:Yes: https://github.com/Suprcheese/Orbital-I ... #L386-L397Bizobinator wrote:Yeah. I've read a bit of the code in a different mod. So, with that event, is it possible to, in between the starting to place & the entity being created, to have some code that stops the entity placement (& thus keeps the item in hand)?
Supercheese, do you mind if I use your code for playing a sound too?
Hehehehehe, you have no idea what you've just unleashed xD
-
- Filter Inserter
- Posts: 841
- Joined: Mon Sep 14, 2015 7:40 am
- Contact:
Re: click event
Sure, go for it! I'm always happy to see folks get inspired and launch into Factorio modding.Bizobinator wrote:Excellent! Yay!
Supercheese, do you mind if I use your code for playing a sound too?
Hehehehehe, you have no idea what you've just unleashed xD