Quick Swap

by Geritos

This mod allows you to swap your quickbar "filters" along the Y axis.

Tweaks
2 years ago
1.1
239

b Swapping corrupts blueprint shortcuts

2 years ago

Hello,

First of all, thanks for releasing this nifty little mod, it is really nice to have all the quick bar slots at a fingertip in this manner :)

You might already be aware of this, but unfortunately swapping the positions of blueprints does not work, and either leaves "bogus" blueprints in the quick bar slots (in case of inventory blueprints), or removes them completely from the quick bar altogether (in case of player/game library blueprints).

After fiddling around a bit with the code, I do have a patch that could fix it, but the caveat is that it is impossible to currently detect whether some slot contains a blueprint from the library, so the patch tries to "work-around" this issue by simply refusing to swap anything that might be an empty field or a blueprint.

Would you be interested into incorporating such a patch? If interested, I could also try to implement this as one or two mod options and make the behaviour configurable.

diff --git a/control.lua b/control.lua
index 76ec555..7081118 100644
--- a/control.lua
+++ b/control.lua
@@ -22,7 +22,15 @@ end

 --copy 5 filters from start location to target.
 function Copy(quick_bar_copy, set_quick_bar_slot, start, target)
+    local source_slot
+    local target_slot
+
     for i = 0, 4 do
-        set_quick_bar_slot(target + i, quick_bar_copy[start + i])
+        source_slot = quick_bar_copy[start+i]
+        target_slot = quick_bar_copy[target+i]
+
+        if source_slot ~= nil and source_slot.name ~= "blueprint" and target_slot ~= nil and target_slot.name ~= "blueprint" then
+            set_quick_bar_slot(target + i, quick_bar_copy[start + i])
+        end
     end
-end
\ No newline at end of file
+end

Best regards,
Branko

P.S.
As a side-note, would you be interested in setting-up project on some Git repository hosting forge for eventual future pull requests?

2 years ago

Hello Branko, thank you for your feedback,

regarding the undesired behavior - yes, I am aware of it and yes, I tried to fix it (the solutions were always "incomplete", even as in your case). I also looked that you addressed the problem yourself and created your own mod. So the question is whether it's worth fixing it at all, since it will just create another mod that you already made.

Regardless, I'm glad you were inspired and made your own mod and also that you now understand why it can't be fixed perfectly.

As for the Git repository, I have no problem with setting it up and will add it as a source once it is ready.

Best wishes,
Geritos.

P.S..
I deeply apologize for the late response, I haven't played Factorio for a while and I don't visit the mod portal often.

2 years ago

Hello Geritos,

Thank you for responding, and don't worry about the late reply, better late than never :)

And thank you for implementing this nifty mod - I have recently been looking at various quality-of-life improvements, and sometimes it is surprising how some even smaller changes can make a big difference in usability. :)

I have only become a bit more active with modding recently, and usually I try to contribute patches as opposed to forking, but it's been kinda hit-and-miss. Normally I try to see how active people are on portal/forums/Github and contacting before deciding to fork or reimplement something - kinda don't like it when there's three or four different mods created as mere continuation. I was actually considering to propose a start of some kind of umbrella/collective community that would try to maintain mods under Free licenses - just in cases when people get tired of Factorio, but we'll see if I get the energy to suggest something like that :)

My implementation has a couple more options/features, so most likely I will let it sit around at this point. However, should you set-up a Github repository, I will still gladly submit the above patch (or just feel free to apply it yourself, of course). Your implementation has a big advantage in terms of simplicity (I might have added too many features, but I'm also kinda playing around with modding at the moment as well).

Best regards,
Branko

New response