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 :)