click event

Place to get help with not working mods / modding interface.
Post Reply
Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

click event

Post by Bizobinator »

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?

SilverB1rd
Inserter
Inserter
Posts: 47
Joined: Fri Mar 17, 2017 9:19 pm
Contact:

Re: click event

Post by SilverB1rd »

if you look in the factorio documentation for the defines.events
/Factorio/doc-html/defines.html#defines.events
it does not list an event specifically for clicks.

if your trying to capture the player building something there is

defines.events.on_built_entity
defines.events.on_put_item

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: click event

Post by Rseding91 »

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.
If you want to get ahold of me I'm almost always on Discord.

Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: click event

Post by Supercheese »

Bizobinator wrote:Is there an event that fires whenever a player clicks?
Nope, there is no event for this.
Bizobinator wrote:Or, even better, when a player clicks with a given item in their selection hand?
There is, however, an event for this: http://lua-api.factorio.com/latest/even ... n_put_item

Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

Re: click event

Post by Bizobinator »

Supercheese wrote:
Bizobinator wrote:Is there an event that fires whenever a player clicks?
Nope, there is no event for this.
Bizobinator wrote:Or, even better, when a player clicks with a given item in their selection hand?
There is, however, an event for this: http://lua-api.factorio.com/latest/even ... n_put_item

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
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: click event

Post by Supercheese »

Bizobinator 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)?
Yes: https://github.com/Suprcheese/Orbital-I ... #L386-L397

Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

Re: click event

Post by Bizobinator »

Supercheese wrote:
Bizobinator 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)?
Yes: https://github.com/Suprcheese/Orbital-I ... #L386-L397
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

Supercheese
Filter Inserter
Filter Inserter
Posts: 841
Joined: Mon Sep 14, 2015 7:40 am
Contact:

Re: click event

Post by Supercheese »

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
Sure, go for it! I'm always happy to see folks get inspired and launch into Factorio modding. :)

Post Reply

Return to “Modding help”