link
This commit is contained in:
parent
dd5770a2e6
commit
b331383ac3
2 changed files with 60 additions and 5 deletions
13
Makefile
13
Makefile
|
|
@ -8,20 +8,27 @@
|
||||||
|
|
||||||
.PHONY: copy lint-changelog install
|
.PHONY: copy lint-changelog install
|
||||||
|
|
||||||
|
libdir = "../bzlib"
|
||||||
|
libfiles = $(shell ls $(libdir)/*.lua | grep -o '[^/]*.lua')
|
||||||
pwd = $(shell pwd)
|
pwd = $(shell pwd)
|
||||||
v = $(shell basename "$(pwd)")_$(shell jq -r .version info.json)
|
v = $(shell basename "$(pwd)")_$(shell jq -r .version info.json)
|
||||||
|
|
||||||
copy:
|
link:
|
||||||
|
for f in $(libfiles) ; do \
|
||||||
|
echo "using $(libdir)/$$f" ;\
|
||||||
|
cp $(libdir)/$$f .; \
|
||||||
|
done;
|
||||||
|
|
||||||
|
copy: link
|
||||||
rm -rf ../$(v)
|
rm -rf ../$(v)
|
||||||
mkdir -p ../$(v)
|
mkdir -p ../$(v)
|
||||||
cp -rf * ../$(v)
|
cp -rf * ../$(v)
|
||||||
rm -f ../$(v).zip
|
rm -f ../$(v).zip
|
||||||
cd ..; zip -9 -r -y $(v).zip $(v) -x "*.xcf" -x "*.git*" -x "*.bak" -x "*.blend*"
|
cd ..; zip -9 -r -y $(v).zip $(v) -x "*.xcf" -x "*.git*" -x "*.bak"
|
||||||
|
|
||||||
install: lint-changelog copy
|
install: lint-changelog copy
|
||||||
cp -f ../$(v).zip ../../mods/
|
cp -f ../$(v).zip ../../mods/
|
||||||
|
|
||||||
|
|
||||||
lint-changelog: copy
|
lint-changelog: copy
|
||||||
python3 ../da-changelog-tools_0.0.14/changelog-checker.py --changelog ../$(v).zip
|
python3 ../da-changelog-tools_0.0.14/changelog-checker.py --changelog ../$(v).zip
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,16 @@
|
||||||
|
-- WARNING - this file will be overwritten, edit bzlib/data-util.lua
|
||||||
|
|
||||||
local me = require("me")
|
local me = require("me")
|
||||||
local util = {}
|
local util = {}
|
||||||
|
|
||||||
util.me = me
|
util.me = me
|
||||||
|
util.get_setting = util.me.get_setting
|
||||||
|
|
||||||
|
function util.fe_plus(sub)
|
||||||
|
if mods["FactorioExtended-Plus-"..sub] then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function util.get_stack_size(default)
|
function util.get_stack_size(default)
|
||||||
if mods["Krastorio2"] then
|
if mods["Krastorio2"] then
|
||||||
|
|
@ -154,7 +163,6 @@ function remove_ingredient(recipe, old)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Replace an amount of an ingredient in a recipe. Keep at least 1 of old.
|
-- Replace an amount of an ingredient in a recipe. Keep at least 1 of old.
|
||||||
function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount)
|
function util.replace_some_ingredient(recipe_name, old, old_amount, new, new_amount)
|
||||||
if me.bypass[recipe_name] then return end
|
if me.bypass[recipe_name] then return end
|
||||||
|
|
@ -239,6 +247,46 @@ function multiply_recipe(recipe, multiple)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns true if a recipe has an ingredient
|
||||||
|
function util.has_ingredient(recipe_name, ingredient)
|
||||||
|
return data.raw.recipe[recipe_name] and (
|
||||||
|
has_ingredient(data.raw.recipe[recipe_name], ingredient) or
|
||||||
|
has_ingredient(data.raw.recipe[recipe_name].normal, ingredient))
|
||||||
|
end
|
||||||
|
|
||||||
|
function has_ingredient(recipe, ingredient)
|
||||||
|
if recipe ~= nil and recipe.ingredients ~= nil then
|
||||||
|
for i, existing in pairs(recipe.ingredients) do
|
||||||
|
if existing[1] == ingredient or existing.name == ingredient then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Replace one product with another in a recipe
|
||||||
|
function util.replace_product(recipe_name, old, new)
|
||||||
|
if data.raw.recipe[recipe_name] then
|
||||||
|
replace_product(data.raw.recipe[recipe_name], old, new)
|
||||||
|
replace_product(data.raw.recipe[recipe_name].normal, old, new)
|
||||||
|
replace_product(data.raw.recipe[recipe_name].expensive, old, new)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function replace_product(recipe, old, new)
|
||||||
|
if recipe ~= nil and recipe.results ~= nil then
|
||||||
|
if recipe.result == old then
|
||||||
|
recipe.results = new
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for i, result in pairs(recipe.results) do
|
||||||
|
if result.name == old then result.name = new end
|
||||||
|
if result[1] == old then result[1] = new end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Remove an element of type t and name from data.raw
|
-- Remove an element of type t and name from data.raw
|
||||||
function util.remove_raw(t, name)
|
function util.remove_raw(t, name)
|
||||||
if data.raw[t][name] then
|
if data.raw[t][name] then
|
||||||
|
|
@ -290,7 +338,7 @@ function util.set_to_founding(recipe)
|
||||||
util.set_subgroup(recipe, "foundry-intermediate")
|
util.set_subgroup(recipe, "foundry-intermediate")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Addc crafting category to an entity
|
-- Add crafting category to an entity
|
||||||
function util.add_crafting_category(entity_type, entity, category)
|
function util.add_crafting_category(entity_type, entity, category)
|
||||||
if data.raw[entity_type][entity] then
|
if data.raw[entity_type][entity] then
|
||||||
for i, existing in pairs(data.raw[entity_type][entity].crafting_categories) do
|
for i, existing in pairs(data.raw[entity_type][entity].crafting_categories) do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue