Skip to content

Commit 9ccf5ad

Browse files
committed
Support GDIW recipes when mirroring blueprints.
1 parent b0b3052 commit 9ccf5ad

File tree

6 files changed

+64
-8
lines changed

6 files changed

+64
-8
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ incremented (this behavior can be changed in settings).
1111
corner or edge. This is useful if you can't fit a large blueprint entirely on screen and need to make it align
1212
against some existing structure -- i.e. for tiling solar layouts.
1313

14-
* Blueprint Mirror: Mirror a blueprint horizontally or vertically, correctly fixing most entities can be fixed.
14+
* Blueprint Mirror: Mirror a blueprint horizontally or vertically. This correctly fixes splitter orientation,
15+
and if [GDIW](https://mods.factorio.com/mod/GDIW) is installed it will also switch fluid recipes to their mirrored
16+
versions.
1517

1618
* Wireswap: Swap circuit wire colors within a blueprint.
1719

@@ -26,7 +28,7 @@ incremented (this behavior can be changed in settings).
2628
when that specific updater was created. There currently does not exist a way to associate data with a specific
2729
updater and still have it function as a selection tool.
2830

29-
* Blueprint Snap is unable to factor in the rotation setting due to
31+
* Blueprint Snap is unable to factor in the rotation setting due to
3032
[modding API limitations](https://forums.factorio.com/viewtopic.php?f=28&t=47087&start=80#p324060). Thus, snapping
3133
to the north edge of a blueprint will snap to the north edge of the blueprint in its native rotation -- not the
3234
current on-screen one. The functionality is still fully useable, it just may require a bit of "Which key do I
@@ -41,6 +43,9 @@ discussion page, and messages posted there will likely be ignored.**
4143

4244
## Changelog
4345

46+
### 0.2.5 (2018-10-18)
47+
* If [GDIW](https://mods.factorio.com/mod/GDIW) is installed, mirror recipes when mirroring blueprints.
48+
4449
### 0.2.4 (2018-10-16)
4550

4651
* Fix crash on case-sensitive filesystems (i.e. not Windows). Thanks to Omnifarious for the report.

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
---------------------------------------------------------------------------------------------------
2+
Version: 0.2.5
3+
Date: 18. 10. 2018
4+
Changes:
5+
- Mirroring blueprints will now mirror fluid recipes if GDIW (Gah! DarnItWater!) is installed.
6+
This means mirroring a refinery blueprint will not break fluid inputs if using that mod.
7+
This can be disabled on a per-player basis in mod settings.
8+
19
---------------------------------------------------------------------------------------------------
210
Version: 0.2.4
311
Date: 16. 10. 2018

info.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "BlueprintExtensions",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"title": "Blueprint Extensions",
55
"author": "Dewin",
66
"contact": "https://github.com/dewiniaid/BlueprintExtensions",
77
"homepage": "https://github.com/dewiniaid/BlueprintExensions",
88
"factorio_version": "0.16",
9-
"dependencies": ["base >= 0.16"],
9+
"dependencies": ["base >= 0.16", "? GDIW"],
1010
"description": "Adds tools for updating and placing blueprints."
1111
}

locale/en/locale.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ BlueprintExtensions_vertical-invert=Invert vertical axis when snapping
2727
BlueprintExtensions_version-increment=Increment version when updating blueprints (normal)
2828
BlueprintExtensions_alt-version-increment=Increment version when updating blueprints (alternate)
2929
BlueprintExtensions_show-buttons=Show buttons for blueprint flipping
30+
BlueprintExtensions_support-gdiw=Mirror GDIW recipes
3031

3132
[mod-setting-description]
3233
BlueprintExtensions_cardinal-center=ON: Snapping to an edge centers the blueprint on the opposite axis.\nOFF: Snapping to an edge does not move the blueprint on the opposite axis.\n\nSetting this to OFF means that snapping to North + snapping to East is the same effect as snapping to Northeast, useful if you have limited keybind space (e.g. no numpad).
3334
BlueprintExtensions_horizontal-invert=Snap to East/West moves that edge of the blueprint to under the cursor rather than aligning the blueprint to that edge.
3435
BlueprintExtensions_vertical-invert=Snap to North/South moves that edge of the blueprint to under the cursor rather than aligning the blueprint to that edge.
3536
BlueprintExtensions_version-increment=Blueprint Extensions can add a version number to blueprints it updates.\n\nOFF: Blueprint labels are always copied as-is.\n\nIF PRESENT: A blueprint label ending in "v.###" or "v###" will have the version number incremented.\n\nALWAYS: Like IF PRESENT, but "v.2" will be added to blueprint labels if no version number is present.\n\nThis setting only applies when using regular mouse drag to select the new blueprint area.
3637
BlueprintExtensions_alt-version-increment=Blueprint Extensions can add a version number to blueprints it updates.\n\nOFF: Blueprint labels are always copied as-is.\n\nIF PRESENT: A blueprint label ending in "v.###" or "v###" will have the version number incremented.\n\nALWAYS: Like IF PRESENT, but "v.2" will be added to blueprint labels if no version number is present.\n\nThis setting applies when using SHIFT + drag to select the new blueprint area.
37-
3838
BlueprintExtensions_show-buttons=Show GUI buttons for flipping blueprints. If disabled, blueprints can only be flipped by using the hotkey.\n\nThis setting is ignored if Blueprint Flipper and Turner is installed.
39-
39+
BlueprintExtensions_support-gdiw='Gah! DarnItWater!' is a mod that adds mirrored versions of recipes with fluid inputs/outputs. If this is enabled and GDIW is present, recipes in blueprints will be mirrored when the blueprint itself is mirrored.
4040

4141
[string-mod-setting]
4242
BlueprintExtensions_version-increment.off=off

modules/flip.lua

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ local Flip = {
4141
sides = {
4242
left = 'right',
4343
right = 'left'
44-
}
44+
},
4545
}
4646

4747
function Flip.setup_gui(player)
@@ -64,13 +64,27 @@ function Flip.check_for_other_mods()
6464
-- Flip.enabled = false
6565
if game.active_mods["Blueprint_Flip_Turn"] then
6666
game.print("[Blueprint Extensions] Blueprint Flipper and Turner is installed. Disabling our version of blueprint flipping.")
67-
game.print("Blueprint Extensions now includes some improved functionality when flipping blueprints, such as correctly flipping splitter priorities. To enable this functionality, disable Blueprint Flipper and Turner.")
67+
if game.active_mods["GDIW"] then
68+
game.print("Blueprint Extensions includes some improved functionality when flipping blueprints, such as correctly flipping splitter priorities and taking advantage of GDIW recipes. To enable this functionality, disable Blueprint Flipper and Turner.")
69+
else
70+
game.print("Blueprint Extensions includes some improved functionality when flipping blueprints, such as correctly flipping splitter priorities. To enable this functionality, disable Blueprint Flipper and Turner.")
71+
end
6872
Flip.enabled = false
6973
else
7074
Flip.enabled = true
7175
end
7276
end
7377

78+
--[[ GDIW reversals:
79+
Unmodified: BR or IR or OR
80+
IR: OR or none
81+
OR: IR or none
82+
BR: unmodified
83+
]]
84+
85+
local function _gdiw_recipe(recipe)
86+
return (game.recipe_prototypes[recipe]) and recipe or nil
87+
end
7488

7589

7690
function Flip.flip(player_index, translate)
@@ -85,6 +99,7 @@ function Flip.flip(player_index, translate)
8599
local proto, name, dir
86100
local axis = translate.axis
87101
local ents
102+
local support_gdiw = player.mod_settings["BlueprintExtensions_support-gdiw"].value
88103

89104
ents = bp.get_blueprint_entities()
90105
if ents then
@@ -127,6 +142,26 @@ function Flip.flip(player_index, translate)
127142
ent.output_priority = Flip.sides[ent.output_priority]
128143
end
129144

145+
-- Support GDIW
146+
if support_gdiw and ent.recipe then
147+
local t
148+
local _, _, recipe, mod = string.find(ent.recipe, "^(.*)%-GDIW%-([BIO])R$")
149+
if mod == 'B' then -- Both mirrored
150+
ent.recipe = recipe
151+
elseif mod == 'I' then -- Input mirrored
152+
ent.recipe = _gdiw_recipe(recipe .. '-GDIW-OR') or recipe
153+
elseif mod == 'O' then -- Output mirrored
154+
ent.recipe = _gdiw_recipe(recipe .. '-GDIW-IR') or recipe
155+
else -- Neither mirrored
156+
recipe = ent.recipe
157+
ent.recipe = (
158+
_gdiw_recipe(recipe .. '-GDIW-BR')
159+
or _gdiw_recipe(recipe .. '-GDIW-IR')
160+
or _gdiw_recipe(recipe .. '-GDIW-OR')
161+
or recipe
162+
)
163+
end
164+
end
130165
end
131166
bp.set_blueprint_entities(ents)
132167
end

settings.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ data:extend{
4343
order = 300,
4444
default_value = true,
4545
},
46+
{
47+
type = "bool-setting",
48+
name = "BlueprintExtensions_support-gdiw",
49+
setting_type = "runtime-per-user",
50+
order = 301,
51+
default_value = true,
52+
},
53+
4654
}
4755

4856

0 commit comments

Comments
 (0)