Add Recipe:addIndicatorIcon()
This commit is contained in:
parent
48325fd78d
commit
e6b2bbe154
2 changed files with 23 additions and 1 deletions
|
|
@ -51,7 +51,7 @@ function Item:merge(data)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets the weight of the item calculated from given count per rocket.
|
--- Sets the weight of the item calculated from given count per rocket
|
||||||
--- @param count number The amount of items that fit into a rocket
|
--- @param count number The amount of items that fit into a rocket
|
||||||
function Item:itemsPerRocket(count)
|
function Item:itemsPerRocket(count)
|
||||||
self.prototype.weight = (1000 / count) * kg
|
self.prototype.weight = (1000 / count) * kg
|
||||||
|
|
|
||||||
|
|
@ -226,4 +226,26 @@ function Recipe:clone(name)
|
||||||
return Recipe:new(clone)
|
return Recipe:new(clone)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Adds a small icon in the corner of the regular item
|
||||||
|
--- It currently assumes an icon_size of 64
|
||||||
|
--- @param icon string The filename of the icon
|
||||||
|
--- @param position string The position of the icon. One of ["top-left", "top-right", "bottom-left", "bottom-right"]. Defaults to "bottom-right".
|
||||||
|
function Recipe:addIndicatorIcon(icon, position)
|
||||||
|
local icons = self.prototype.icons or {}
|
||||||
|
local mainIcon = icons[1] or self.prototype.icon or nil
|
||||||
|
if not mainIcon then
|
||||||
|
local result = self.prototype.results[1]
|
||||||
|
local resultItem = data.raw[result.type][result.name]
|
||||||
|
icons = resultItem.icons or {{ icon = resultItem.icon }}
|
||||||
|
end
|
||||||
|
local shift = { 8, 8 }
|
||||||
|
if position == "top-left" then shift = { -8, -8 } end
|
||||||
|
if position == "top-right" then shift = { 8, -8 } end
|
||||||
|
if position == "bottom-left" then shift = { -8, 8 } end
|
||||||
|
table.insert(icons, { icon = icon, scale = 0.25, shift = shift })
|
||||||
|
self.prototype.icons = icons
|
||||||
|
log(serpent.block(self.prototype.icons))
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
return Recipe
|
return Recipe
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue