diff --git a/README.md b/README.md index 59d2dd8..4462274 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,9 @@ This mod has strict error checking, so bad strings will not crash your game or m ####Changelog +Version 3.1.1 +- Toned down the 0.12.32 upgrade button + Version 3.1.0 - Added blueprint book support - Added label support diff --git a/control.lua b/control.lua index bf9715e..e2355f0 100644 --- a/control.lua +++ b/control.lua @@ -97,9 +97,6 @@ function holding_book(player) end function find_empty_blueprint(player, no_crafting) - local main = player.get_inventory(defines.inventory.player_main) - local quickbar = player.get_inventory(defines.inventory.player_quickbar) - if (holding_blueprint(player)) then if (player.cursor_stack.is_blueprint_setup()) then player.cursor_stack.set_blueprint_entities(nil) @@ -109,6 +106,9 @@ function find_empty_blueprint(player, no_crafting) return player.cursor_stack end + local main = player.get_inventory(defines.inventory.player_main) + local quickbar = player.get_inventory(defines.inventory.player_quickbar) + local stacks = filter(quickbar, "blueprint") for i, stack in pairs(filter(main, "blueprint")) do stacks[#quickbar+i] = stack @@ -244,6 +244,11 @@ function load_blueprint(player) local book = nil if (not blueprint_format.book) then -- Blueprint + if (holding_book(player)) then + player.print({"need-blueprint"}) + return + end + blueprint = find_empty_blueprint(player) if (not blueprint) then player.print({"no-empty-blueprint"}) @@ -257,6 +262,11 @@ function load_blueprint(player) return end + if (holding_blueprint(player)) then + player.print({"need-blueprint-book"}) + return + end + local page_count = 0 for _, page in pairs(blueprint_format.book) do page_count = page_count + 1 @@ -332,6 +342,9 @@ function load_blueprint(player) if (i == 1) then error = load_blueprint_data(active[1], page) else + if (i - 1 > #main) then + break + end error = load_blueprint_data(main[i-1], page) end if (error and error[1] ~= "unknown-format") then @@ -453,7 +466,7 @@ function save_all(player) for position, stack in pairs(filter(quickbar, "blueprint")) do if (stack.is_blueprint_setup()) then - local filename = "toolbar-"..position + local filename = "toolbar-" .. position if (stack.label) then filename = stack.label end @@ -463,7 +476,7 @@ function save_all(player) for position, stack in pairs(filter(main, "blueprint")) do if (stack.is_blueprint_setup()) then - local filename = "inventory-"..position + local filename = "inventory-" .. position if (stack.label) then filename = stack.label end @@ -471,8 +484,22 @@ function save_all(player) end end - -- TODO: Add blueprint books - + for position, stack in pairs(filter(quickbar, "blueprint-book")) do + local filename = "toolbar-" .. position + if (stack.label) then + filename = stack.label + end + book_to_file(player, stack, filename) + end + + for position, stack in pairs(filter(main, "blueprint-book")) do + local filename = "inventory-" .. position + if (stack.label) then + filename = stack.label + end + book_to_file(player, stack, filename) + end + if (blueprints_saved > 0) then player.print({"blueprints-saved", blueprints_saved}) else diff --git a/graphics/gui.png b/graphics/gui.png index a5eba1e..fa1bac1 100644 Binary files a/graphics/gui.png and b/graphics/gui.png differ diff --git a/info.json b/info.json index 244a71e..868ccb2 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "blueprint-string", - "version": "3.1.0", + "version": "3.1.1", "title": "Blueprint String", "author": "DaveMcW", "description": "Converts text strings into blueprints", diff --git a/locale/en/blueprint-string.cfg b/locale/en/blueprint-string.cfg index 4261427..ab8fdce 100644 --- a/locale/en/blueprint-string.cfg +++ b/locale/en/blueprint-string.cfg @@ -12,4 +12,6 @@ no-filename=Please enter a file name for this blueprint. no-blueprint-in-hand=Please click this button while holding a blueprint. blueprint-api-error=Blueprint error: __1__ blueprint-icon-error=Blueprint icon error: __1__ -need-advanced-circuit=You need __1__ advanced circuit. \ No newline at end of file +need-advanced-circuit=You need __1__ advanced circuit. +need-blueprint=You need a blueprint to load that. +need-blueprint-book=You need a blueprint book to load that. diff --git a/prototypes/style.lua b/prototypes/style.lua index 016cd89..1dda734 100644 --- a/prototypes/style.lua +++ b/prototypes/style.lua @@ -75,8 +75,8 @@ data.raw["gui-style"].default["blueprintstring_button_main"] = priority = "extra-high-no-scale", width = 36, height = 36, - x = 36, - y = 0, + x = 0, + y = 36, } }, clicked_graphical_set = @@ -87,8 +87,8 @@ data.raw["gui-style"].default["blueprintstring_button_main"] = filename = "__blueprint-string__/graphics/gui.png", width = 36, height = 36, - x = 36, - y = 0, + x = 0, + y = 36, } }, left_click_sound = @@ -126,8 +126,8 @@ data.raw["gui-style"].default["blueprintstring_button_load"] = priority = "extra-high-no-scale", width = 36, height = 36, - x = 108, - y = 0, + x = 72, + y = 36, } }, clicked_graphical_set = @@ -138,8 +138,8 @@ data.raw["gui-style"].default["blueprintstring_button_load"] = filename = "__blueprint-string__/graphics/gui.png", width = 36, height = 36, - x = 108, - y = 0, + x = 72, + y = 36, } }, left_click_sound = @@ -164,8 +164,8 @@ data.raw["gui-style"].default["blueprintstring_button_saveas"] = priority = "extra-high-no-scale", width = 36, height = 36, - x = 0, - y = 36, + x = 36, + y = 0, } }, hovered_graphical_set = @@ -215,8 +215,8 @@ data.raw["gui-style"].default["blueprintstring_button_saveall"] = priority = "extra-high-no-scale", width = 36, height = 36, - x = 72, - y = 36, + x = 108, + y = 0, } }, hovered_graphical_set = @@ -280,7 +280,7 @@ data.raw["gui-style"].default["blueprintstring_button_upgrade"] = width = 36, height = 36, x = 144, - y = 0, + y = 36, } }, clicked_graphical_set = @@ -292,7 +292,7 @@ data.raw["gui-style"].default["blueprintstring_button_upgrade"] = width = 36, height = 36, x = 144, - y = 0, + y = 36, } }, left_click_sound =