Circuit Wire Poles


Adds small poles for circuit wire connections.

Content
7 months ago
1.1 - 2.0
358
Circuit network

g Wire connection failure after cursor change

3 months ago
(updated 3 months ago)

Hello,

Thanks for making this mod! I've been tinkering with it a bit for my personal use and I found a bug where a new circuit connection will fail to attach if the wire is grabbed via hotkey while hovering over the pole. The underlying cause is that the cursor-wire check only happens after the selection change event, but not after a cursor change. I fixed this locally by adding a new function which handles the event on_player_cursor_stack_changed. Note that the function is_player_holding_wire just wraps around the conditional you have in the create_viewer_entity function.

function viewer.on_player_cursor_stack_changed(event)
  local player = game.get_player(event.player_index)
  local selected = player.selected
  if selected == nil then
    return
  end
  local holding_wire = viewer.is_player_holding_wire(player)
  if holding_wire and selected.name == "circuit-wire-pole-viewer" then
    viewer.clear_viewer_entity(player)
  elseif not holding_wire and selected.name == "circuit-wire-pole" then
    viewer.create_viewer_entity(player)
  end
end

Hopefully this is of some use to you :)

3 months ago

Also, I just realized, you could probably avoid adding a new function and just add another handler to control.lua:

script.on_event(defines.events.on_player_cursor_stack_changed, viewer.on_selected_entity_changed)

New response