Skip to content

Commit 4d253fb

Browse files
committed
Fix default keybindings for mirroring blueprints. (SHIFT + V and SHIFT + v are not the same thing.), and add blueprint nudging now that the desired keybindings are actually possible.
1 parent d300414 commit 4d253fb

File tree

7 files changed

+131
-6
lines changed

7 files changed

+131
-6
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ discussion page, and messages posted there will likely be ignored.**
4343

4444
## Changelog
4545

46+
### 0.3.1 (2019-02-26)
47+
* Fix default keybinds for mirroring
48+
* Add blueprint nudging. SHIFT + arrow-on-numpad will 'nudge' a blueprint 1 tile in the selected direction. (Blueprints with rails will be nudged 2 tiles.)
49+
50+
4651
### 0.3.0 (2019-02-26)
4752
* Update for Factorio 0.17
4853
* Overhaul buttons for blueprint flipping to a more sane implementation.

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
---------------------------------------------------------------------------------------------------
2+
Version: 0.3.1
3+
Date: 26. 02. 2019
4+
Changes:
5+
- Fix default keybinds for mirroring
6+
- Add blueprint nudging. SHIFT + arrow-on-numpad will 'nudge' a blueprint 1 tile in the selected direction.
7+
(Blueprints with rails will be nudged 2 tiles.)
8+
19
---------------------------------------------------------------------------------------------------
210
Version: 0.3.0
311
Date: 26. 02. 2019

info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "BlueprintExtensions",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"title": "Blueprint Extensions",
55
"author": "Dewin",
66
"contact": "https://github.com/dewiniaid/BlueprintExtensions",

locale/en/locale.cfg

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ BlueprintExtensions_snap-ne=Snap to NE corner
1111
BlueprintExtensions_snap-sw=Snap to SW corner
1212
BlueprintExtensions_snap-se=Snap to SE corner
1313
BlueprintExtensions_snap-center=Center blueprint
14+
15+
BlueprintExtensions_nudge-n=Nudge blueprint north
16+
BlueprintExtensions_nudge-e=Nudge blueprint east
17+
BlueprintExtensions_nudge-s=Nudge blueprint south
18+
BlueprintExtensions_nudge-w=Nudge blueprint west
19+
BlueprintExtensions_nudge-nw=Nudge blueprint NW
20+
BlueprintExtensions_nudge-ne=Nudge blueprint NE
21+
BlueprintExtensions_nudge-sw=Nudge blueprint SW
22+
BlueprintExtensions_nudge-se=Nudge blueprint SE
23+
1424
BlueprintExtensions_clone-blueprint=Update blueprint
1525

1626
BlueprintExtensions_flip-h=Flip blueprint horizontally
@@ -19,6 +29,13 @@ BlueprintExtensions_flip-v=Flip blueprint vertically
1929
BlueprintExtensions_wireswap=Swap circuit wire colors
2030
BlueprintExtensions_rotate-clockwise=Rotate blueprint in-place
2131

32+
[controls-description]
33+
BlueprintExtensions_rotate-clockwise=Rotates the actual blueprint, rather than simply your chosen placement of it. This is useful if you want a set of related blueprints to line up in the correct direction.
34+
BlueprintExtensions_clone-blueprint=Creates a blueprint cloning tool that allows you to make a new blueprint using the same name and icons as the selected one.BlueprintExtensions_clone-blueprint=Update blueprint
35+
BlueprintExtensions_wireswap=Make red circuit wires green and vice versa.
36+
37+
38+
2239
[mod-setting-name]
2340
BlueprintExtensions_cardinal-center=Snap to edge centers blueprint first
2441
BlueprintExtensions_horizontal-invert=Invert horizontal axis when snapping

modules/rotate.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ end
3333

3434
script.on_event("BlueprintExtensions_rotate-clockwise", function(event) return Rotate.rotate(event.player_index) end)
3535
return Rotate
36-

modules/snap.lua

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ local Snap = {
1414
["BlueprintExtensions_snap-sw"] = {1, 0},
1515
["BlueprintExtensions_snap-se"] = {0, 0},
1616
},
17+
NUDGE_EVENTS = {
18+
["BlueprintExtensions_nudge-n"] = {0, -1},
19+
["BlueprintExtensions_nudge-s"] = {0, 1},
20+
["BlueprintExtensions_nudge-w"] = {-1, 0},
21+
["BlueprintExtensions_nudge-e"] = {1, 0},
22+
["BlueprintExtensions_nudge-nw"] = {-1, -1},
23+
["BlueprintExtensions_nudge-ne"] = { 1, -1},
24+
["BlueprintExtensions_nudge-sw"] = {-1, 1},
25+
["BlueprintExtensions_nudge-se"] = { 1, 1},
26+
},
1727
ALIGNMENT_OVERRIDES = {
1828
['straight-rail'] = 2,
1929
['curved-rail'] = 2,
@@ -41,8 +51,17 @@ function Snap.on_event(event)
4151
return nil
4252
end
4353

44-
local player_settings = player.mod_settings
4554

55+
if not Snap.EVENTS[event.input_name] then
56+
if Snap.NUDGE_EVENTS[event.input_name] then
57+
local xdir, ydir = table.unpack(Snap.NUDGE_EVENTS[event.input_name])
58+
return Snap.nudge_blueprint(bp, xdir, ydir)
59+
end
60+
-- Should be unreachable
61+
return
62+
end
63+
64+
local player_settings = player.mod_settings
4665
local center = (player_settings["BlueprintExtensions_cardinal-center"].value and 0.5) or nil
4766
local xdir, ydir = table.unpack(Snap.EVENTS[event.input_name])
4867
if xdir == nil then
@@ -177,9 +196,25 @@ function Snap.align_blueprint(bp, xdir, ydir)
177196
end
178197

179198

199+
function Snap.nudge_blueprint(bp, xdir, ydir)
200+
local align = 1
201+
202+
for _, entity in pairs(bp.get_blueprint_entities() or {}) do
203+
align = max(align, Snap.ALIGNMENT_OVERRIDES[entity.name] or align)
204+
end
205+
206+
xdir = xdir * align
207+
ydir = ydir * align
208+
209+
return Snap.offset_blueprint(bp, xdir, ydir)
210+
end
211+
212+
180213
for k,_ in pairs(Snap.EVENTS) do
181214
script.on_event(k, Snap.on_event)
182215
end
183-
216+
for k,_ in pairs(Snap.NUDGE_EVENTS) do
217+
script.on_event(k, Snap.on_event)
218+
end
184219

185220
return Snap

prototypes/inputs.lua

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ data:extend({
33
{
44
type = "custom-input",
55
name = "BlueprintExtensions_flip-h",
6-
key_sequence = "SHIFT + x",
6+
key_sequence = "SHIFT + X",
77
order = 'a-a'
88
},
99
{
1010
type = "custom-input",
1111
name = "BlueprintExtensions_flip-v",
12-
key_sequence = "SHIFT + v",
12+
key_sequence = "SHIFT + V",
1313
order = 'a-b'
1414
},
1515
{
@@ -67,6 +67,67 @@ data:extend({
6767
key_sequence = "PAD 5",
6868
order = 'f-a',
6969
},
70+
{
71+
type = "custom-input",
72+
name = "BlueprintExtensions_flip-h",
73+
key_sequence = "SHIFT + X",
74+
order = 'a-a'
75+
},
76+
{
77+
type = "custom-input",
78+
name = "BlueprintExtensions_flip-v",
79+
key_sequence = "SHIFT + V",
80+
order = 'a-b'
81+
},
82+
{
83+
type = "custom-input",
84+
name = "BlueprintExtensions_nudge-n",
85+
key_sequence = "SHIFT + PAD 8",
86+
order = 'd-a',
87+
},
88+
{
89+
type = "custom-input",
90+
name = "BlueprintExtensions_nudge-e",
91+
key_sequence = "SHIFT + PAD 6",
92+
order = 'd-b',
93+
},
94+
{
95+
type = "custom-input",
96+
name = "BlueprintExtensions_nudge-s",
97+
key_sequence = "SHIFT + PAD 2",
98+
order = 'd-c',
99+
},
100+
{
101+
type = "custom-input",
102+
name = "BlueprintExtensions_nudge-w",
103+
key_sequence = "SHIFT + PAD 4",
104+
order = 'd-d',
105+
},
106+
107+
{
108+
type = "custom-input",
109+
name = "BlueprintExtensions_nudge-nw",
110+
key_sequence = "SHIFT + PAD 7",
111+
order = 'e-a',
112+
},
113+
{
114+
type = "custom-input",
115+
name = "BlueprintExtensions_nudge-ne",
116+
key_sequence = "SHIFT + PAD 9",
117+
order = 'e-b',
118+
},
119+
{
120+
type = "custom-input",
121+
name = "BlueprintExtensions_nudge-sw",
122+
key_sequence = "SHIFT + PAD 1",
123+
order = 'e-c',
124+
},
125+
{
126+
type = "custom-input",
127+
name = "BlueprintExtensions_nudge-se",
128+
key_sequence = "SHIFT + PAD 3",
129+
order = 'e-d',
130+
},
70131
{
71132
type = "custom-input",
72133
name = "BlueprintExtensions_clone-blueprint",

0 commit comments

Comments
 (0)