This commit is contained in:
Brevven 2023-02-11 23:43:01 -08:00
parent 8262d149c0
commit df3063bec4
2 changed files with 42 additions and 2 deletions

23
control-util.lua Normal file
View file

@ -0,0 +1,23 @@
local me = require("me")
local util = {}
util.me = me
function decode(data)
if type(data) == "string" then return data end
local str = {}
for i = 2, #data do
str[i-1] = decode(data[i])
end
return table.concat(str, "")
end
function util.get_list()
local p = game.item_prototypes[me.name.."-list"]
if p then
data = p.localised_description
return decode(data)
end
end
return util

View file

@ -1,7 +1,6 @@
-- WARNING WARNING WARNING
-- This file will be overwritten in mod zipfiles, edit bzlib/data-util.lua
-- WARNING WARNING WARNING
--
local me = require("me")
local util = {}
@ -943,6 +942,23 @@ function util.set_item_subgroup(item, subgroup, options)
end
end
function util.add_icon(recipe_name, icon, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe_name] then
me.add_modified(recipe_name)
if not (data.raw.recipe[recipe_name].icons and #(data.raw.recipe[recipe_name].icons) > 0) then
data.raw.recipe[recipe_name].icons = {{
icon=data.raw.recipe[recipe_name].icon,
icon_size=data.raw.recipe[recipe_name].icon_size,
icon_mipmaps=data.raw.recipe[recipe_name].icon_mipmaps,
}}
data.raw.recipe[recipe_name].icon = nil
data.raw.recipe[recipe_name].icon_size = nil
end
table.insert(data.raw.recipe[recipe_name].icons, icon)
end
end
-- Set recipe icons
function util.set_icons(recipe_name, icons, options)
if not should_force(options) and bypass(recipe_name) then return end
@ -993,7 +1009,8 @@ function util.add_crafting_category(entity_type, entity, category)
end
end
function util.add_to_ingredient(recipe, ingredient, amount)
function util.add_to_ingredient(recipe, ingredient, amount, options)
if not should_force(options) and bypass(recipe_name) then return end
if data.raw.recipe[recipe] then
add_to_ingredient(data.raw.recipe[recipe], ingredient, amount)
add_to_ingredient(data.raw.recipe[recipe].normal, ingredient, amount)