Skip to content

Commit

Permalink
toned down the 0.12.32 upgrade button
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveMcW committed Jul 26, 2016
1 parent 1da2920 commit c3afdfd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 23 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 34 additions & 7 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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"})
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -463,16 +476,30 @@ 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
blueprint_to_file(player, stack, filename)
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
Expand Down
Binary file modified graphics/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 3 additions & 1 deletion locale/en/blueprint-string.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
28 changes: 14 additions & 14 deletions prototypes/style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down Expand Up @@ -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 =
Expand All @@ -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 =
Expand All @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down

0 comments on commit c3afdfd

Please sign in to comment.