Detect when modules changed

Place to get help with not working mods / modding interface.
User avatar
mat1k
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Sat Dec 22, 2018 8:48 am
Contact:

Detect when modules changed

Post by mat1k »

I'm trying to find a way to detect when a player adds, removes, or changes the modules in a drill or assembling machine.

Is there an event that triggers for this? or a way to work around to check modules after gui closed?
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Detect when modules changed

Post by DaveMcW »

Code: Select all

script.on_event(defines.events.on_gui_closed, function(event)
  if not event.entity then return end
  local module_slots = event.entity.prototype.module_inventory_size
  if not module_slots or module_slots == 0 then return end
  
  game.print("modules were potentially edited")  
end)
I don't think there is a way to detect a Ctrl+click. Or a construction robot module delivery.
User avatar
mat1k
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Sat Dec 22, 2018 8:48 am
Contact:

Re: Detect when modules changed

Post by mat1k »

DaveMcW wrote: Sat Jul 20, 2019 11:15 am

Code: Select all

script.on_event(defines.events.on_gui_closed, function(event)
  if not event.entity then return end
  local module_slots = event.entity.prototype.module_inventory_size
  if not module_slots or module_slots == 0 then return end
  
  game.print("modules were potentially edited")  
end)
I don't think there is a way to detect a Ctrl+click. Or a construction robot module delivery.
Ctrl-click triggers the on_player_fast_transferred event
Post Reply

Return to “Modding help”