diff --git a/README.md b/README.md index 0771afd..bd07b11 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/changelog.txt b/changelog.txt index 1bbd5f3..152bc9c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/info.json b/info.json index defc490..1692c8b 100644 --- a/info.json +++ b/info.json @@ -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", diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg index 2c25263..26b86a0 100644 --- a/locale/en/locale.cfg +++ b/locale/en/locale.cfg @@ -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 @@ -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 diff --git a/modules/rotate.lua b/modules/rotate.lua index bd9a592..4aabcdc 100644 --- a/modules/rotate.lua +++ b/modules/rotate.lua @@ -33,4 +33,3 @@ end script.on_event("BlueprintExtensions_rotate-clockwise", function(event) return Rotate.rotate(event.player_index) end) return Rotate - \ No newline at end of file diff --git a/modules/snap.lua b/modules/snap.lua index 8ddba67..39d4ad2 100644 --- a/modules/snap.lua +++ b/modules/snap.lua @@ -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, @@ -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 @@ -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 diff --git a/prototypes/inputs.lua b/prototypes/inputs.lua index 73fa188..ceae248 100644 --- a/prototypes/inputs.lua +++ b/prototypes/inputs.lua @@ -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' }, { @@ -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",