Skip to content

Commit

Permalink
Fix default keybindings for mirroring blueprints. (SHIFT + V and SHIF…
Browse files Browse the repository at this point in the history
…T + v are not the same thing.), and add blueprint nudging now that the desired keybindings are actually possible.
  • Loading branch information
dewiniaid committed Feb 27, 2019
1 parent d300414 commit 4d253fb
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ discussion page, and messages posted there will likely be ignored.**

## Changelog

### 0.3.1 (2019-02-26)
* Fix default keybinds for mirroring
* 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.)


### 0.3.0 (2019-02-26)
* Update for Factorio 0.17
* Overhaul buttons for blueprint flipping to a more sane implementation.
Expand Down
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---------------------------------------------------------------------------------------------------
Version: 0.3.1
Date: 26. 02. 2019
Changes:
- Fix default keybinds for mirroring
- 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.)

---------------------------------------------------------------------------------------------------
Version: 0.3.0
Date: 26. 02. 2019
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BlueprintExtensions",
"version": "0.3.0",
"version": "0.3.1",
"title": "Blueprint Extensions",
"author": "Dewin",
"contact": "https://github.com/dewiniaid/BlueprintExtensions",
Expand Down
17 changes: 17 additions & 0 deletions locale/en/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ BlueprintExtensions_snap-ne=Snap to NE corner
BlueprintExtensions_snap-sw=Snap to SW corner
BlueprintExtensions_snap-se=Snap to SE corner
BlueprintExtensions_snap-center=Center blueprint

BlueprintExtensions_nudge-n=Nudge blueprint north
BlueprintExtensions_nudge-e=Nudge blueprint east
BlueprintExtensions_nudge-s=Nudge blueprint south
BlueprintExtensions_nudge-w=Nudge blueprint west
BlueprintExtensions_nudge-nw=Nudge blueprint NW
BlueprintExtensions_nudge-ne=Nudge blueprint NE
BlueprintExtensions_nudge-sw=Nudge blueprint SW
BlueprintExtensions_nudge-se=Nudge blueprint SE

BlueprintExtensions_clone-blueprint=Update blueprint

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

[controls-description]
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.
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
BlueprintExtensions_wireswap=Make red circuit wires green and vice versa.



[mod-setting-name]
BlueprintExtensions_cardinal-center=Snap to edge centers blueprint first
BlueprintExtensions_horizontal-invert=Invert horizontal axis when snapping
Expand Down
1 change: 0 additions & 1 deletion modules/rotate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ end

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

39 changes: 37 additions & 2 deletions modules/snap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ local Snap = {
["BlueprintExtensions_snap-sw"] = {1, 0},
["BlueprintExtensions_snap-se"] = {0, 0},
},
NUDGE_EVENTS = {
["BlueprintExtensions_nudge-n"] = {0, -1},
["BlueprintExtensions_nudge-s"] = {0, 1},
["BlueprintExtensions_nudge-w"] = {-1, 0},
["BlueprintExtensions_nudge-e"] = {1, 0},
["BlueprintExtensions_nudge-nw"] = {-1, -1},
["BlueprintExtensions_nudge-ne"] = { 1, -1},
["BlueprintExtensions_nudge-sw"] = {-1, 1},
["BlueprintExtensions_nudge-se"] = { 1, 1},
},
ALIGNMENT_OVERRIDES = {
['straight-rail'] = 2,
['curved-rail'] = 2,
Expand Down Expand Up @@ -41,8 +51,17 @@ function Snap.on_event(event)
return nil
end

local player_settings = player.mod_settings

if not Snap.EVENTS[event.input_name] then
if Snap.NUDGE_EVENTS[event.input_name] then
local xdir, ydir = table.unpack(Snap.NUDGE_EVENTS[event.input_name])
return Snap.nudge_blueprint(bp, xdir, ydir)
end
-- Should be unreachable
return
end

local player_settings = player.mod_settings
local center = (player_settings["BlueprintExtensions_cardinal-center"].value and 0.5) or nil
local xdir, ydir = table.unpack(Snap.EVENTS[event.input_name])
if xdir == nil then
Expand Down Expand Up @@ -177,9 +196,25 @@ function Snap.align_blueprint(bp, xdir, ydir)
end


function Snap.nudge_blueprint(bp, xdir, ydir)
local align = 1

for _, entity in pairs(bp.get_blueprint_entities() or {}) do
align = max(align, Snap.ALIGNMENT_OVERRIDES[entity.name] or align)
end

xdir = xdir * align
ydir = ydir * align

return Snap.offset_blueprint(bp, xdir, ydir)
end


for k,_ in pairs(Snap.EVENTS) do
script.on_event(k, Snap.on_event)
end

for k,_ in pairs(Snap.NUDGE_EVENTS) do
script.on_event(k, Snap.on_event)
end

return Snap
65 changes: 63 additions & 2 deletions prototypes/inputs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ data:extend({
{
type = "custom-input",
name = "BlueprintExtensions_flip-h",
key_sequence = "SHIFT + x",
key_sequence = "SHIFT + X",
order = 'a-a'
},
{
type = "custom-input",
name = "BlueprintExtensions_flip-v",
key_sequence = "SHIFT + v",
key_sequence = "SHIFT + V",
order = 'a-b'
},
{
Expand Down Expand Up @@ -67,6 +67,67 @@ data:extend({
key_sequence = "PAD 5",
order = 'f-a',
},
{
type = "custom-input",
name = "BlueprintExtensions_flip-h",
key_sequence = "SHIFT + X",
order = 'a-a'
},
{
type = "custom-input",
name = "BlueprintExtensions_flip-v",
key_sequence = "SHIFT + V",
order = 'a-b'
},
{
type = "custom-input",
name = "BlueprintExtensions_nudge-n",
key_sequence = "SHIFT + PAD 8",
order = 'd-a',
},
{
type = "custom-input",
name = "BlueprintExtensions_nudge-e",
key_sequence = "SHIFT + PAD 6",
order = 'd-b',
},
{
type = "custom-input",
name = "BlueprintExtensions_nudge-s",
key_sequence = "SHIFT + PAD 2",
order = 'd-c',
},
{
type = "custom-input",
name = "BlueprintExtensions_nudge-w",
key_sequence = "SHIFT + PAD 4",
order = 'd-d',
},

{
type = "custom-input",
name = "BlueprintExtensions_nudge-nw",
key_sequence = "SHIFT + PAD 7",
order = 'e-a',
},
{
type = "custom-input",
name = "BlueprintExtensions_nudge-ne",
key_sequence = "SHIFT + PAD 9",
order = 'e-b',
},
{
type = "custom-input",
name = "BlueprintExtensions_nudge-sw",
key_sequence = "SHIFT + PAD 1",
order = 'e-c',
},
{
type = "custom-input",
name = "BlueprintExtensions_nudge-se",
key_sequence = "SHIFT + PAD 3",
order = 'e-d',
},
{
type = "custom-input",
name = "BlueprintExtensions_clone-blueprint",
Expand Down

0 comments on commit 4d253fb

Please sign in to comment.