Compact circuits


Miniaturize a whole logic network into a single entity to save place (similar to factorissimo but for signals).

Content
a month ago
1.1
7.42K
Circuit network

g Bug: Clicking multiple times on a processor traps you in the editor

1 year, 10 months ago

Great mod BTW, I've started using it more and more!

Sometimes, I might accidentally doubly click on a processor. When that happens, the mod enters the editor twice, and after I click on "Exit editor" I get stuck in there, with no way to get out of it (that I know of). E.g. with Space Exploration, I can normally use the Navigation Satellite Uplink (N) to exit editing, but when I'm stuck the game crashes if I use it:

The mod Space Exploration (0.6.90) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event space-exploration::se-remote-view (ID 259)
The mod Compakt circuits (1.0.14) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event compaktcircuit::on_player_changed_surface (ID 53)
__compaktcircuit__/scripts/editor.lua:1250: attempt to index local 'iopoint_info' (a nil value)
stack traceback:
    __compaktcircuit__/scripts/editor.lua:1250: in function 'save_packed_circuits'
    __compaktcircuit__/scripts/editor.lua:890: in function <__compaktcircuit__/scripts/editor.lua:872>
stack traceback:
    [C]: in function 'teleport'
    __space-exploration__/scripts/remote-view.lua:369: in function 'stop'
    __space-exploration__/scripts/remote-view.lua:688: in function 'toggle'
    __space-exploration__/scripts/remote-view.lua:754: in function 'callback'
    __space-exploration__/scripts/event.lua:15: in function <__space-exploration__/scripts/event.lua:13>

I tried to find a fix, and my simple solution is to add a guard when editing, so that we you can't enter the editor twice. Here is a diff that works for me:

***************
*** 376,377 ****
--- 376,382 ----

+     local vars = get_vars(player)
+     if vars.editing then
+       return
+     end
+     vars.editing = true
      local procinfo = get_procinfo(processor, true)
***************
*** 382,384 ****

-     local vars = get_vars(player)
      vars.procinfo = procinfo
--- 387,388 ----
***************
*** 437,438 ****
--- 441,443 ----
      player.teleport(origin_surface_position, origin_surface_name)
+     vars.editing = false
  end
***************
*** 896,897 ****
--- 901,903 ----
          end
+       vars.editing = false
      end
1 year, 10 months ago

I add code in the version 1.0.15
Thank for reporting

1 year, 9 months ago

Hi, sorry for the late reply.

Thanks for the fix, but I think it's not properly fixed.

You do the locking and unlocking within editor.edit_selected, but when you multiple-click on an editor, those clicks happen before entering editor.edit_selected, and each call to that function is done sequentially, not in parallel.

The correct fix would be to add the unlocking just before teleporting out or exiting the editor.

So you should move procinfo.locked = false from that function and into on_exit_editor and on_player_changed_surface:

***************
*** 581,587 ****
      procinfo.origin_surface_name = player.surface.name
      procinfo.origin_surface_position = player.position
      player.teleport({ x, y }, surface)
-     procinfo.locked = false
  end

  local function on_exit_editor(e)
--- 581,586 ----
***************
*** 593,598 ****
--- 592,598 ----
      local surface = player.surface
      local vars = get_vars(player)
      local procinfo = vars.procinfo
+     procinfo.locked = false

      vars.is_standard_exit = true

***************
*** 1086,1091 ****
--- 1086,1092 ----

          close_iopanel(player)
          close_editor_panel(player)
+         procinfo.locked = false

          player.opened = nil
          vars.procinfo = nil

New response