Skip to content

Commit

Permalink
Blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverfeelin committed Aug 11, 2017
1 parent 04376f6 commit 3f0bb33
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
Binary file added interface/sip/recipe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 15 additions & 6 deletions interface/sip/sip.config
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,9 @@
"type": "button",
"base": "/interface/sip/print.png",
"hover": "/interface/sip/print.png?brightness=30",
"caption": "",
"fontSize": 7,
"wrapWidth": 80,
"hAnchor": "mid",
"zlevel": 20,
"pressedOffset": [0, -1],
"position": [212, 25],
"position": [202, 25],
"callback": "sip.callback.print"
},
"sipImagePrintAmount": {
Expand Down Expand Up @@ -162,6 +158,17 @@
"callback": "sip.callback.changeQuantity"
},

"buttonPrintBlueprint":{
"type": "button",
"base": "/interface/sip/recipe.png",
"hover": "/interface/sip/recipe.png?brightness=30",
"zlevel": 20,
"pressedOffset": [0, -1],
"disabled": true,
"position": [287, 25],
"callback": "sip.callback.printBlueprint"
},

"sipImageSearch": {
"type": "image",
"file": "/interface/sip/search.png",
Expand Down Expand Up @@ -1105,6 +1112,7 @@
"sip.callback.showType",
"sip.callback.selectItem",
"sip.callback.print",
"sip.callback.printBlueprint",
"sip.callback.changeQuantity",
"sip.callback.selectCategory",
"sip.callback.changeWeaponLevel",
Expand Down Expand Up @@ -1165,7 +1173,8 @@
"fire": 3,
"electric": 4
},
"labelClothingColor": "paneClothing.labelColor"
"labelClothingColor": "paneClothing.labelColor",
"blueprint": "buttonPrintBlueprint"
},
"knownCategories": {
"items": [
Expand Down
11 changes: 11 additions & 0 deletions scripts/sip_callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function sip.callback.selectItem()
local rarity = sip.item.rarity and sip.item.rarity:lower() or "common"
widget.setImage(sip.widgets.itemRarity, sip.rarityImages.flags[rarity])

-- Blueprint
widget.setButtonEnabled(sip.widgets.blueprint, sip_util.hasBlueprint(sip.item.name))

-- Item slot
sip.randomizeItem()
sip.showSpecifications(config)
Expand Down Expand Up @@ -131,6 +134,14 @@ function sip.callback.print()
sip.spawnItem(cfg.config, q)
end

--- Spawns a recipe for the current item, if the item supports a recipe.
function sip.callback.printBlueprint()
local item = sip.item
if item and item.name and sip_util.hasBlueprint(item.name) then
player.giveItem({name=item.name .. "-recipe", count=1})
end
end

--- Takes the item, or place an item to copy.
-- If no item is held, the item will be taken (without consuming it). This acts similar to print, but only (x1).
-- If an item is held, the selection is overwritten, allowing users to copy their existing items.
Expand Down
6 changes: 6 additions & 0 deletions scripts/sip_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ function sip_util.isLevelableWeapon(itemConfig)
return false
end

--- Returns a value indicating whether the item has an unlockable blueprint
function sip_util.hasBlueprint(itemName)
if type(itemName) ~= "string" then return false end
return not not root.itemConfig(itemName .. "-recipe")
end

--- Filters the item list by categories.
-- Categories are identified by name, and are case insensitive.
-- @param list Item table, as stored in the item dump.
Expand Down

0 comments on commit 3f0bb33

Please sign in to comment.