Page 1 of 1

[2.0.60] Event "on_player_placed_equipment" Firing Twice

Posted: Mon Jul 21, 2025 6:16 am
by NovaDrox
I am trying to develop a mod that adds custom equipment, which I am needing to detect upon it being placed in the grid for logic and such. The code I have below is just the bare basic of just detecting what equipment I put into a grid (armor, vehicle, etc), and for some reason it fires off once and displays everything correctly, but then it fires off the event again with just the first game.print statement only and not the other 2 print statements (see below code). I also saw that if I shift + click the equipment in, it fired the event once (perfect), but if I do it manually by click and placing it in the grid, it either fires the event 2 times or just once if spammed clicked a few times.

Code: Select all

local placed_event_counter = 0

script.on_event(defines.events.on_player_placed_equipment, function(event)
  local equipment = event.equipment
  placed_event_counter = placed_event_counter + 1 -- Always increment, as the event always fires.

  if equipment and equipment.valid then
    game.print("[Drone Companion] --- on_player_placed_equipment FIRED (" .. placed_event_counter .. " total fires) at tick " .. game.tick .. " ---")
    game.print("Name:" .. equipment.name)
    game.print(equipment)
  else 
    game.print("Is not valid or is nil")
  end
end)
In game chat/console:
[Drone Companion] --- on_player_placed_equipment FIRED (1 total fires) at tick 102872 ---
Name:fission-reactor-equipment
[LuaEquipment: fission-reactor-equipment (normal) at [0,0] in power-armor-mk2 (normal) itemNumber=1]
[Drone Companion] --- on_player_placed_equipment FIRED (2 total fires) at tick 102872 ---


Does anyone know what is happening with this double firing event? As this wasn't an issue before, but now it suddenly is in 2.0.60