commit 0731c231c79c4d16fb7872e05959d5570c08fb8e Author: Brevven Date: Sun Jul 18 17:54:09 2021 -0700 initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cc3e245 --- /dev/null +++ b/LICENSE @@ -0,0 +1,427 @@ +Attribution-ShareAlike 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution-ShareAlike 4.0 International Public +License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution-ShareAlike 4.0 International Public License ("Public +License"). To the extent this Public License may be interpreted as a +contract, You are granted the Licensed Rights in consideration of Your +acceptance of these terms and conditions, and the Licensor grants You +such rights in consideration of benefits the Licensor receives from +making the Licensed Material available under these terms and +conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. BY-SA Compatible License means a license listed at + creativecommons.org/compatiblelicenses, approved by Creative + Commons as essentially the equivalent of this Public License. + + d. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + e. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + f. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + g. License Elements means the license attributes listed in the name + of a Creative Commons Public License. The License Elements of this + Public License are Attribution and ShareAlike. + + h. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + i. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + j. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + k. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + l. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + m. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. Additional offer from the Licensor -- Adapted Material. + Every recipient of Adapted Material from You + automatically receives an offer from the Licensor to + exercise the Licensed Rights in the Adapted Material + under the conditions of the Adapter's License You apply. + + c. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + b. ShareAlike. + + In addition to the conditions in Section 3(a), if You Share + Adapted Material You produce, the following conditions also apply. + + 1. The Adapter's License You apply must be a Creative Commons + license with the same License Elements, this version or + later, or a BY-SA Compatible License. + + 2. You must include the text of, or the URI or hyperlink to, the + Adapter's License You apply. You may satisfy this condition + in any reasonable manner based on the medium, means, and + context in which You Share Adapted Material. + + 3. You may not offer or impose any additional or different terms + or conditions on, or apply any Effective Technological + Measures to, Adapted Material that restrict exercise of the + rights granted under the Adapter's License You apply. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material, + + including for purposes of Section 3(b); and + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5d2a96c --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +# General makefile for factorio mods. +# +# Presumes the development work is done in a /dev// +# directory where this makefile resides. This directory must be parallel to +# the /mods/ directory where mods are installed. Run `make +# install` from dev/ to install the mod as a zip file. That zip file +# should also be ready to upload to the mod portal + +.PHONY: copy lint-changelog install + +pwd = $(shell pwd) +v = $(shell basename "$(pwd)")_$(shell jq -r .version info.json) + +copy: + rm -rf ../$(v) + mkdir -p ../$(v) + cp -rf * ../$(v) + rm -f ../$(v).zip + cd ..; zip -9 -r -y $(v).zip $(v) -x "*.xcf" -x "*.git*" -x "*.bak" -x "*.blend*" + +install: lint-changelog copy + cp -f ../$(v).zip ../../mods/ + + +lint-changelog: copy + python3 ../da-changelog-tools_0.0.14/changelog-checker.py --changelog ../$(v).zip + +zorro: + python3 ../da-changelog-tools_0.0.14/changelog-checker.py --zorro --changelog ../$(v).zip + diff --git a/README.md b/README.md new file mode 100644 index 0000000..63ee6c1 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# Foundry + +[factorio mod page](https://mods.factorio.com/mod/bzfoundry) + +## Version History +See changelog.txt + +## License + +This work is released under a CC license instead of MIT. Contact me on github if you have questions. + +Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) +See LICENSE + +## Created by + +- [brevven](https://mods.factorio.com/user/brevven) (code, design, graphics) diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..22607de --- /dev/null +++ b/changelog.txt @@ -0,0 +1,5 @@ +--------------------------------------------------------------------------------------------------- +Version: 0.0.1 +Date: 2021-07-17 + Features: + - New foundry building, coke (optional), updated recipes diff --git a/data-updates.lua b/data-updates.lua new file mode 100644 index 0000000..9540177 --- /dev/null +++ b/data-updates.lua @@ -0,0 +1 @@ +require("foundry-updates") diff --git a/data-util.lua b/data-util.lua new file mode 100644 index 0000000..5512c84 --- /dev/null +++ b/data-util.lua @@ -0,0 +1,325 @@ +local util = {} + +util.name = "bzfoundry" + +function util.smelt() + return util.get_setting("bzfoundry-smelt") +end + +function util.carbon() + return util.get_setting("bzfoundry-hydrocarbon") +end + +function util.carbonrecipe() + local carbon = util.carbon() + if carbon == "coke" then + return "coke" + elseif carbon == "solid-fuel" then + return "solid-fuel-from-coal" + end + return nil +end + +function util.get_setting(name) + if settings.startup[name] == nil then + return nil + end + return settings.startup[name].value +end + + +local bypass = {} +if util.get_setting(util.name.."-recipe-bypass") then + for recipe in string.gmatch(util.get_setting(util.name.."-recipe-bypass"), '[^",%s]+') do + bypass[recipe] = true + end +end + +function util.get_stack_size(default) + if mods["Krastorio2"] then + size = tonumber(krastorio.general.getSafeSettingValue("kr-stack-size")) + return size or default + end + return default +end + +-- check if a table contains a sought value +function util.contains(table, sought) + for i, value in pairs(table) do + if value == sought then + return true + end + end + return false +end + +-- Add a prerequisite to a given technology +function util.add_prerequisite(technology_name, prerequisite) + technology = data.raw.technology[technology_name] + if technology and data.raw.technology[prerequisite] then + if technology.prerequisites then + table.insert(technology.prerequisites, prerequisite) + else + technology.prerequisites = {prerequisite} + end + end +end + +-- Remove a prerequisite from a given technology +function util.remove_prerequisite(technology_name, prerequisite) + technology = data.raw.technology[technology_name] + local index = -1 + if technology and data.raw.technology[prerequisite] then + for i, prereq in pairs(technology.prerequisites) do + if prereq == prerequisite then + index = i + break + end + end + if index > -1 then + table.remove(technology.prerequisites, index) + end + end +end + +-- Add an effect to a given technology +function util.add_effect(technology_name, effect) + technology = data.raw.technology[technology_name] + if technology then + table.insert(technology.effects, effect) + end +end + +-- Set technology ingredients +function util.set_tech_recipe(technology_name, ingredients) + technology = data.raw.technology[technology_name] + if technology then + technology.unit.ingredients = ingredients + end +end + +-- Add a given quantity of ingredient to a given recipe +function util.add_ingredient(recipe_name, ingredient, quantity) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] and data.raw.item[ingredient] then + add_ingredient(data.raw.recipe[recipe_name], ingredient, quantity) + add_ingredient(data.raw.recipe[recipe_name].normal, ingredient, quantity) + add_ingredient(data.raw.recipe[recipe_name].expensive, ingredient, quantity) + end +end + +function add_ingredient(recipe, ingredient, quantity) + 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 + log("Not adding "..ingredient.." -- duplicate") + return + end + end + table.insert(recipe.ingredients, {ingredient, quantity}) + end +end + +-- Add a given quantity of product to a given recipe. +-- Only works for recipes with multiple products +function util.add_product(recipe_name, product) + if data.raw.recipe[recipe_name] and data.raw.item[product] then + add_product(data.raw.recipe[recipe_name], product) + add_product(data.raw.recipe[recipe_name].normal, product) + add_product(data.raw.recipe[recipe_name].expensive, product) + end +end + +function add_product(recipe, product) + if recipe ~= nil and recipe.results ~= nil then + table.insert(recipe.results, product) + end +end + +-- Replace one ingredient with another in a recipe +function util.replace_ingredient(recipe_name, old, new) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] and data.raw.item[new] then + replace_ingredient(data.raw.recipe[recipe_name], old, new) + replace_ingredient(data.raw.recipe[recipe_name].normal, old, new) + replace_ingredient(data.raw.recipe[recipe_name].expensive, old, new) + end +end + +function replace_ingredient(recipe, old, new) + if recipe ~= nil and recipe.ingredients ~= nil then + for i, existing in pairs(recipe.ingredients) do + if existing[1] == new or existing.name == new then + log("Not adding "..new.." -- duplicate") + return + end + end + for i, ingredient in pairs(recipe.ingredients) do + if ingredient.name == old then ingredient.name = new end + if ingredient[1] == old then ingredient[1] = new end + end + end +end + +-- Remove an ingredient from a recipe +function util.remove_ingredient(recipe_name, old) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] then + remove_ingredient(data.raw.recipe[recipe_name], old) + remove_ingredient(data.raw.recipe[recipe_name].normal, old) + remove_ingredient(data.raw.recipe[recipe_name].expensive, old) + end +end + +function remove_ingredient(recipe, old) + index = -1 + if recipe ~= nil and recipe.ingredients ~= nil then + for i, ingredient in pairs(recipe.ingredients) do + if ingredient.name == old or ingredient[1] == old then + index = i + break + end + end + if index > -1 then + table.remove(recipe.ingredients, index) + end + end +end + + +-- 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) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] and data.raw.item[new] then + replace_some_ingredient(data.raw.recipe[recipe_name], old, old_amount, new, new_amount) + replace_some_ingredient(data.raw.recipe[recipe_name].normal, old, old_amount, new, new_amount) + replace_some_ingredient(data.raw.recipe[recipe_name].expensive, old, old_amount, new, new_amount) + end +end + +function replace_some_ingredient(recipe, old, old_amount, new, new_amount) + if recipe ~= nil and recipe.ingredients ~= nil then + for i, existing in pairs(recipe.ingredients) do + if existing[1] == new or existing.name == new then + log("Not adding "..new.." -- duplicate") + return + end + end + for i, ingredient in pairs(recipe.ingredients) do + -- For final fixes + if ingredient.name == old then + ingredient.amount = math.max(1, ingredient.amount - old_amount) + end + -- For updates + if ingredient[1] == old then + ingredient[2] = math.max(1, ingredient[2] - old_amount) + end + end + add_ingredient(recipe, new, new_amount) + end +end + +-- multiply the cost, energy, and results of a recipe by a multiple +function util.multiply_recipe(recipe_name, multiple) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] then + multiply_recipe(data.raw.recipe[recipe_name], multiple) + multiply_recipe(data.raw.recipe[recipe_name].normal, multiple) + multiply_recipe(data.raw.recipe[recipe_name].expensive, multiple) + end +end + +function multiply_recipe(recipe, multiple) + if recipe then + if recipe.energy_required then + recipe.energy_required = recipe.energy_required * multiple + end + if recipe.result_count then + recipe.result_count = recipe.result_count * multiple + end + if recipe.results then + for i, result in pairs(recipe.results) do + if result.name then + if result.amount then + result.amount = result.amount * multiple + end + if result.amount_min ~= nil then + result.amount_min = result.amount_min * multiple + result.amount_max = result.amount_max * multiple + end + if result.catalyst_amount then + result.catalyst_amount = result.catalyst_amount * multiple + end + end + if result[1] then + result[2] = result[2] * multiple + end + end + end + if not recipe.results and not recipe.result_count then + -- implicit one item result + recipe.result_count = multiple + end + if recipe.ingredients then + for i, ingredient in pairs(recipe.ingredients) do + if ingredient.name then + ingredient.amount = ingredient.amount * multiple + end + if ingredient[1] then + ingredient[2] = ingredient[2] * multiple + end + end + end + end +end + +-- Remove an element of type t and name from data.raw +function util.remove_raw(t, name) + for i, elem in pairs(data.raw[t]) do + if elem.name == name then + data.raw[t][i] = nil + break + end + end +end + +-- Multiply energy required +function util.multiply_time(recipe, factor) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] then + multiply_time(data.raw.recipe[recipe_name], factor) + multiply_time(data.raw.recipe[recipe_name].normal, factor) + multiply_time(data.raw.recipe[recipe_name].expensive, factor) + end +end + +function multiply_time(recipe, factor) + if recipe then + if recipe.energy_required then + recipe.energy_required = recipe.energy_required * factor + end + end +end + +-- Set recipe category +function util.set_category(recipe, category) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe] then + data.raw.recipe[recipe].category = category + end +end + +-- Set recipe category +function util.set_subgroup(recipe, subgroup) + if bypass[recipe_name] then return end + if data.raw.recipe[recipe] then + data.raw.recipe[recipe].subgroup = subgroup + end +end + +function util.set_to_founding(recipe) + util.set_category(recipe, "founding") + util.set_subgroup(recipe, "foundry-intermediate") +end + +return util diff --git a/data.lua b/data.lua new file mode 100644 index 0000000..82f8662 --- /dev/null +++ b/data.lua @@ -0,0 +1,4 @@ +require("prototypes/coke") +require("prototypes/foundry") +require("prototypes/entity/foundry") +require("prototypes/entity/electric-foundry") diff --git a/foundry-updates.lua b/foundry-updates.lua new file mode 100644 index 0000000..9b6d60f --- /dev/null +++ b/foundry-updates.lua @@ -0,0 +1,14 @@ +local util = require("data-util") + +util.set_to_founding("steel-plate") +util.replace_some_ingredient("steel-plate", "iron-plate", 1, util.carbon(), 1) +util.multiply_time("stee-plate", 4/5) +util.add_prerequisite("steel-processing", "foundry") + +util.set_to_founding("tungsten-carbide") +util.add_ingredient("tungsten-carbide", util.carbon(), 1) + +util.set_to_founding("silicon") +util.add_ingredient("silicon", util.carbon(), 1) + +util.set_to_founding("cermet") diff --git a/graphics/entity/electric-foundry-glow.png b/graphics/entity/electric-foundry-glow.png new file mode 100644 index 0000000..cada06d Binary files /dev/null and b/graphics/entity/electric-foundry-glow.png differ diff --git a/graphics/entity/electric-foundry-glow.xcf b/graphics/entity/electric-foundry-glow.xcf new file mode 100644 index 0000000..50e36e3 Binary files /dev/null and b/graphics/entity/electric-foundry-glow.xcf differ diff --git a/graphics/entity/electric-foundry.png b/graphics/entity/electric-foundry.png new file mode 100644 index 0000000..29447ef Binary files /dev/null and b/graphics/entity/electric-foundry.png differ diff --git a/graphics/entity/electric-foundry.xcf b/graphics/entity/electric-foundry.xcf new file mode 100644 index 0000000..ac61109 Binary files /dev/null and b/graphics/entity/electric-foundry.xcf differ diff --git a/graphics/entity/foundry.png b/graphics/entity/foundry.png new file mode 100644 index 0000000..ae391eb Binary files /dev/null and b/graphics/entity/foundry.png differ diff --git a/graphics/entity/foundry.xcf b/graphics/entity/foundry.xcf new file mode 100644 index 0000000..25b4b75 Binary files /dev/null and b/graphics/entity/foundry.xcf differ diff --git a/graphics/entity/hr-electric-foundry-1.png b/graphics/entity/hr-electric-foundry-1.png new file mode 100644 index 0000000..18e9d1b Binary files /dev/null and b/graphics/entity/hr-electric-foundry-1.png differ diff --git a/graphics/entity/hr-electric-foundry-2.png b/graphics/entity/hr-electric-foundry-2.png new file mode 100644 index 0000000..237e82d Binary files /dev/null and b/graphics/entity/hr-electric-foundry-2.png differ diff --git a/graphics/entity/hr-electric-foundry-3.png b/graphics/entity/hr-electric-foundry-3.png new file mode 100644 index 0000000..c6ddb8e Binary files /dev/null and b/graphics/entity/hr-electric-foundry-3.png differ diff --git a/graphics/entity/hr-electric-foundry-4.png b/graphics/entity/hr-electric-foundry-4.png new file mode 100644 index 0000000..b4fa48a Binary files /dev/null and b/graphics/entity/hr-electric-foundry-4.png differ diff --git a/graphics/entity/hr-electric-foundry-animation.png b/graphics/entity/hr-electric-foundry-animation.png new file mode 100644 index 0000000..0b05c3d Binary files /dev/null and b/graphics/entity/hr-electric-foundry-animation.png differ diff --git a/graphics/entity/hr-electric-foundry.png b/graphics/entity/hr-electric-foundry.png new file mode 100644 index 0000000..2b4490c Binary files /dev/null and b/graphics/entity/hr-electric-foundry.png differ diff --git a/graphics/entity/hr-foundry.png b/graphics/entity/hr-foundry.png new file mode 100644 index 0000000..6aec925 Binary files /dev/null and b/graphics/entity/hr-foundry.png differ diff --git a/graphics/icons/coke-1.png b/graphics/icons/coke-1.png new file mode 100644 index 0000000..aaa6e30 Binary files /dev/null and b/graphics/icons/coke-1.png differ diff --git a/graphics/icons/coke-1.xcf b/graphics/icons/coke-1.xcf new file mode 100644 index 0000000..0443197 Binary files /dev/null and b/graphics/icons/coke-1.xcf differ diff --git a/graphics/icons/coke-2.png b/graphics/icons/coke-2.png new file mode 100644 index 0000000..be74612 Binary files /dev/null and b/graphics/icons/coke-2.png differ diff --git a/graphics/icons/coke-2.xcf b/graphics/icons/coke-2.xcf new file mode 100644 index 0000000..19dc06e Binary files /dev/null and b/graphics/icons/coke-2.xcf differ diff --git a/graphics/icons/coke-3.png b/graphics/icons/coke-3.png new file mode 100644 index 0000000..15615e7 Binary files /dev/null and b/graphics/icons/coke-3.png differ diff --git a/graphics/icons/coke-3.xcf b/graphics/icons/coke-3.xcf new file mode 100644 index 0000000..97bf908 Binary files /dev/null and b/graphics/icons/coke-3.xcf differ diff --git a/graphics/icons/coke-icon.png b/graphics/icons/coke-icon.png new file mode 100644 index 0000000..2f353d7 Binary files /dev/null and b/graphics/icons/coke-icon.png differ diff --git a/graphics/icons/coke-icon.xcf b/graphics/icons/coke-icon.xcf new file mode 100644 index 0000000..e214b78 Binary files /dev/null and b/graphics/icons/coke-icon.xcf differ diff --git a/graphics/icons/coke.png b/graphics/icons/coke.png new file mode 100644 index 0000000..97e1354 Binary files /dev/null and b/graphics/icons/coke.png differ diff --git a/graphics/icons/coke.xcf b/graphics/icons/coke.xcf new file mode 100644 index 0000000..55e8d08 Binary files /dev/null and b/graphics/icons/coke.xcf differ diff --git a/graphics/icons/electric-foundry-tech.xcf b/graphics/icons/electric-foundry-tech.xcf new file mode 100644 index 0000000..19658d4 Binary files /dev/null and b/graphics/icons/electric-foundry-tech.xcf differ diff --git a/graphics/icons/electric-foundry.png b/graphics/icons/electric-foundry.png new file mode 100644 index 0000000..d08236d Binary files /dev/null and b/graphics/icons/electric-foundry.png differ diff --git a/graphics/icons/electric-foundry.xcf b/graphics/icons/electric-foundry.xcf new file mode 100644 index 0000000..d08b5bd Binary files /dev/null and b/graphics/icons/electric-foundry.xcf differ diff --git a/graphics/icons/foundry.png b/graphics/icons/foundry.png new file mode 100644 index 0000000..a743f2d Binary files /dev/null and b/graphics/icons/foundry.png differ diff --git a/graphics/icons/foundry.xcf b/graphics/icons/foundry.xcf new file mode 100644 index 0000000..5f5e755 Binary files /dev/null and b/graphics/icons/foundry.xcf differ diff --git a/graphics/icons/technology/electric-foundry.png b/graphics/icons/technology/electric-foundry.png new file mode 100644 index 0000000..604f0cb Binary files /dev/null and b/graphics/icons/technology/electric-foundry.png differ diff --git a/graphics/icons/technology/foundry.png b/graphics/icons/technology/foundry.png new file mode 100644 index 0000000..ddc8673 Binary files /dev/null and b/graphics/icons/technology/foundry.png differ diff --git a/graphics/icons/technology/foundry.xcf b/graphics/icons/technology/foundry.xcf new file mode 100644 index 0000000..3c2d594 Binary files /dev/null and b/graphics/icons/technology/foundry.xcf differ diff --git a/info.json b/info.json new file mode 100644 index 0000000..a8890a6 --- /dev/null +++ b/info.json @@ -0,0 +1,18 @@ +{ + "name": "bzfoundry", + "version": "0.0.1", + "factorio_version": "1.1", + "title": "Foundry", + "author": "Brevven", + "contact": "", + "homepage": "", + "dependencies": [ + "? space-exploration", + "? bzsilicon", + "? bztungsten", + "? bzzirconium", + "base >= 1.1.0" + ], + "description": "Adds a foundry building for making alloys, etc." +} + diff --git a/locale/en/foundry.cfg b/locale/en/foundry.cfg new file mode 100644 index 0000000..41cf8df --- /dev/null +++ b/locale/en/foundry.cfg @@ -0,0 +1,36 @@ +[entity-name] +foundry=__ITEM__foundry__ +electric-foundry=__ITEM__electric-foundry__ + +[item-name] +foundry=Foundry +electric-foundry=Electric foundry +coke=Coke + +[item-description] +foundry=For melting and casting metals, can also heat up other things. +electric-foundry=For melting and casting metals, can also heat up other things. +coke=A pure fuel and source of carbon. + +[recipe-name] +solid-fuel-from-coal=Solid fuel from coal. + +[recipe-description] +solid-fuel-from-coal=Make solid fuel from coal, a wasteful process. + +[technology-name] +foundry=__ITEM__foundry__ +electric-foundry=__ITEM__electric-foundry__ + +[technology-description] +foundry=Use heat for founding, coking, etc. + +[mod-setting-name] +bzfoundry-recipe-bypass=Bypass recipes +bzfoundry-smelt=Foundry can smelt +bzfoundry-hydrocarbon=Hydrocarbon for founding + +[mod-setting-description] +bzfoundry-recipe-bypass=Skip modifying these recipes (comma-separated list). +bzfoundry-smelt=If true, the foundry building can also handle raw ore smelting. +bzfoundry-hydrocarbon=Which hydrocarbon to use for founding. The foundry building is also used for coking.\nIf [color=cyan]coke[/color], a coke item and recipe is added, if needed.\nIf [color=cyan]solid fuel[/color], an early but inefficient recipe is added.\nIf [color=cyan]coal[/color], that is used.\nIf [color=cyan]none[/color] no hydrocarbon is used in founding (not recommended). diff --git a/prototypes/coke.lua b/prototypes/coke.lua new file mode 100644 index 0000000..2f4d0a6 --- /dev/null +++ b/prototypes/coke.lua @@ -0,0 +1,47 @@ +local util = require("data-util") + + +if util.carbon() == "coke" and not data.raw.item["coke"] then +data:extend({ + { + type = "item", + name = "coke", + icon = "__bzfoundry__/graphics/icons/coke-icon.png", + icon_size = 128, + pictures = { + {size = 128, filename = "__bzfoundry__/graphics/icons/coke.png", scale = 0.125}, + {size = 128, filename = "__bzfoundry__/graphics/icons/coke-1.png", scale = 0.125}, + {size = 128, filename = "__bzfoundry__/graphics/icons/coke-2.png", scale = 0.125}, + {size = 128, filename = "__bzfoundry__/graphics/icons/coke-3.png", scale = 0.125}, + }, + fuel_category = "chemical", + fuel_value = "10MJ", + fuel_acceleration_multiplier = 1.2, + fuel_top_speed_multiplier = 1, + subgroup = "raw-material", + order = "c[coke]", + stack_size = 50 + }, + { + type = "recipe", + name = "coke", + result = "coke", + category = "founding", + ingredients = {{"coal", 2}}, + energy_required = 3.2, + enabled=false, + }, +}) +elseif util.carbon() == "solid-fuel" then +data:extend({ + { + type = "recipe", + name = "solid-fuel-from-coal", + result = "solid-fuel", + category = "founding", + ingredients = {{"coal", 4}}, + energy_required = 3.2, + enabled=false, + }, +}) +end diff --git a/prototypes/entity/electric-foundry.lua b/prototypes/entity/electric-foundry.lua new file mode 100644 index 0000000..698ca2d --- /dev/null +++ b/prototypes/entity/electric-foundry.lua @@ -0,0 +1,159 @@ +require("util") +local futil = require("data-util") + +data:extend({ + { + type = "assembling-machine", + name = "electric-foundry", + fast_replaceable_group = "foundry", + icon = "__bzfoundry__/graphics/icons/foundry.png", + icon_size = 64, + flags = {"placeable-neutral", "placeable-player", "player-creation"}, + minable = {mining_time = 0.2, result = "electric-foundry"}, + max_health = 300, + corpse = "medium-small-remnants", + vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, + working_sound = + { + sound = { filename = "__base__/sound/electric-furnace.ogg" } + }, + resistances = + { + { + type = "fire", + percent = 100 + } + }, + collision_box = {{-1.7, -1.7}, {1.7, 1.7}}, + selection_box = {{-2, -2}, {2, 2}}, + crafting_categories = {"founding", futil.smelt() and "smelting" or nil}, + energy_usage = "90kW", + crafting_speed = 4, + energy_source = + { + type = "electric", + fuel_category = "chemical", + effectivity = 1, + emissions_per_minute = 2, + usage_priority = "secondary-input", + }, + module_specification = + { + module_slots = 3, + module_info_icon_shift = {0, 0.8} + }, + allowed_effects = {"consumption", "speed", "productivity", "pollution"}, + animation = + { + layers = + { + { + -- TODO make a non-hr version + filename = "__bzfoundry__/graphics/entity/hr-electric-foundry.png", + priority = "high", + width = 280, + height = 239, + frame_count = 1, + shift = util.by_pixel(8, 4), + scale = 0.5, + hr_version = + { + filename = "__bzfoundry__/graphics/entity/hr-electric-foundry.png", + priority = "high", + width = 280, + height = 239, + frame_count = 1, + shift = util.by_pixel(8, 4), + scale = 0.5, + } + }, + } + }, + working_visualisations = + { + { + north_position = {0.0, 0.0}, + east_position = {0.0, 0.0}, + south_position = {0.0, 0.0}, + west_position = {0.0, 0.0}, + animation = + { + filename = "__bzfoundry__/graphics/entity/hr-electric-foundry-animation.png", + priority = "extra-high", + animation_speed = 0.05, + line_length = 4, + width = 280, + height = 239, + frame_count = 4, + axially_symmetrical = false, + direction_count = 1, + shift = util.by_pixel(8, 4), + scale = 0.5, + hr_version = + { + filename = "__bzfoundry__/graphics/entity/hr-electric-foundry-animation.png", + priority = "extra-high", + animation_speed = 0.05, + line_length = 4, + width = 280, + height = 239, + frame_count = 4, + axially_symmetrical = false, + direction_count = 1, + shift = util.by_pixel(8, 4), + scale = 0.5, + } + }, + }, + { + fadeout = true, + draw_as_light = true, + effect = "flicker", + animation = + { + filename = "__bzfoundry__/graphics/entity/electric-foundry-glow.png", + priority = "extra-high", + width = 25, + height = 29, + frame_count = 1, + shift = util.by_pixel(0, 36), + } + }, + { + draw_as_light = true, + draw_as_sprite = false, + fadeout = true, + effect = "flicker", + animation = + { + filename = "__base__/graphics/entity/steel-furnace/steel-furnace-ground-light.png", + priority = "high", + line_length = 1, + draw_as_sprite = false, + width = 78, + height = 64, + frame_count = 1, + direction_count = 1, + shift = util.by_pixel(0, 72), + blend_mode = "additive", + hr_version = + { + filename = "__base__/graphics/entity/steel-furnace/hr-steel-furnace-ground-light.png", + priority = "high", + line_length = 1, + draw_as_sprite = false, + width = 152, + height = 126, + frame_count = 1, + direction_count = 1, + shift = util.by_pixel(1, 72), + blend_mode = "additive", + scale = 0.5, + } + }, + }, + }, + + }, + +}) diff --git a/prototypes/entity/foundry.lua b/prototypes/entity/foundry.lua new file mode 100644 index 0000000..ab0bbb2 --- /dev/null +++ b/prototypes/entity/foundry.lua @@ -0,0 +1,112 @@ +require("util") +local futil = require("data-util") + +data:extend({ + { + type = "assembling-machine", + name = "foundry", + fast_replaceable_group = "foundry", + icon = "__bzfoundry__/graphics/icons/foundry.png", + icon_size = 64, + flags = {"placeable-neutral", "placeable-player", "player-creation"}, + minable = {mining_time = 0.2, result = "foundry"}, + max_health = 300, + corpse = "medium-small-remnants", + vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 }, + working_sound = + { + sound = { filename = "__base__/sound/furnace.ogg" } + }, + resistances = + { + { + type = "fire", + percent = 100 + } + }, + collision_box = {{-1.7, -1.7}, {1.7, 1.7}}, + selection_box = {{-2, -2}, {2, 2}}, + crafting_categories = {"founding", futil.smelt() and "smelting" or nil}, + energy_usage = "90kW", + crafting_speed = 4, + energy_source = + { + type = "burner", + fuel_category = "chemical", + effectivity = 1, + emissions_per_minute = 8, + fuel_inventory_size = 1, + smoke = + { + { + name = "smoke", + frequency = 20, + position = {1, -1.7}, + starting_vertical_speed = 0.1, + starting_frame_deviation = 60 + } + } + }, + animation = + { + layers = + { + { + filename = "__bzfoundry__/graphics/entity/foundry.png", + priority = "high", + width = 140, + height = 120, + frame_count = 1, + shift = util.by_pixel(8, 4), + hr_version = + { + filename = "__bzfoundry__/graphics/entity/hr-foundry.png", + priority = "high", + width = 280, + height = 239, + frame_count = 1, + shift = util.by_pixel(8, 4), + scale = 0.5 + } + }, + } + }, + working_visualisations = + { + { + north_position = {0.0, 0.0}, + east_position = {0.0, 0.0}, + south_position = {0.0, 0.0}, + west_position = {0.0, 0.0}, + animation = + { + filename = "__base__/graphics/entity/stone-furnace/hr-stone-furnace-fire.png", + priority = "extra-high", + line_length = 8, + width = 41, + height = 100, + frame_count = 48, + axially_symmetrical = false, + direction_count = 1, + shift = util.by_pixel(-1, 9), + scale=1.1, + hr_version = + { + filename = "__base__/graphics/entity/stone-furnace/hr-stone-furnace-fire.png", + priority = "extra-high", + line_length = 8, + width = 41, + height = 100, + frame_count = 48, + axially_symmetrical = false, + direction_count = 1, + shift = util.by_pixel(-1, 9), + scale=1.1, + } + }, + } + }, + + }, + +}) diff --git a/prototypes/foundry.lua b/prototypes/foundry.lua new file mode 100644 index 0000000..6bc126d --- /dev/null +++ b/prototypes/foundry.lua @@ -0,0 +1,97 @@ +local util = require("data-util") + +data:extend({ + { type = "recipe-category", name = "founding"}, + { type = "item-subgroup", name = "founding-machines", group = "production"}, + { type = "item-subgroup", name = "foundry-intermediate", group = "intermediate-products"}, +}) + +data:extend({ + { + type = "item", + name = "foundry", + icon = "__bzfoundry__/graphics/icons/foundry.png", + icon_size = 64, + subgroup = "founding-machines", + order = "z[foundry]", + place_result = "foundry", + stack_size = 50 + }, + { + type = "recipe", + name = "foundry", + result = "foundry", + enabled = false, + ingredients = { + {"stone-brick", 10}, + {"iron-plate", 10}, + {"copper-plate", 5}, + (data.raw.item["silica"] and data.raw.technology["silica-processing"] and {"silica", 20} or nil), + }, + }, + { + type = "technology", + name = "foundry", + icon_size = 256, + icon = "__bzfoundry__/graphics/icons/technology/foundry.png", + prerequisites = {"automation"}, + effects = { + {type = "unlock-recipe", recipe = "foundry"}, + util.carbonrecipe() and {type = "unlock-recipe", recipe = util.carbonrecipe()}, + }, + unit = { + count = 25, + ingredients = {{"automation-science-pack", 1}}, + time = 10, + }, + order = "foundry", + }, + +}) +util.add_prerequisite("foundry", "silica-processing") + +data:extend({ + { + type = "item", + name = "electric-foundry", + icon = "__bzfoundry__/graphics/icons/electric-foundry.png", + icon_size = 128, + subgroup = "founding-machines", + order = "z[foundryelectric]", + place_result = "electric-foundry", + stack_size = 50 + }, + { + type = "recipe", + name = "electric-foundry", + result = "electric-foundry", + enabled = false, + ingredients = { + {"foundry", 1}, + {"steel-plate", 10}, + {"advanced-circuit", 4}, + (data.raw.item["zirconia"] and {"zirconia", 10} or {"stone-brick", 10}), + (data.raw.item["tungsten-plate"] and {"tungsten-plate", 5} or nil), + }, + }, + { + type = "technology", + name = "electric-foundry", + icon_size = 256, + icon = "__bzfoundry__/graphics/icons/technology/electric-foundry.png", + prerequisites = {"automation-3"}, + effects = { + {type = "unlock-recipe", recipe = "electric-foundry"}, + }, + unit = { + count = 200, + ingredients = {{"automation-science-pack", 1}, + {"logistic-science-pack", 1}, + {"chemical-science-pack", 1}, + {"production-science-pack", 1}}, + time = 45, + }, + order = "foundry", + }, + +}) diff --git a/settings.lua b/settings.lua new file mode 100644 index 0000000..3200b9a --- /dev/null +++ b/settings.lua @@ -0,0 +1,22 @@ +data:extend({ + { + type = "string-setting", + name = "bzfoundry-recipe-bypass", + setting_type = "startup", + default_value = "", + allow_blank = true, + }, + { + type = "string-setting", + name = "bzfoundry-hydrocarbon", + setting_type = "startup", + allowed_values = {"coke", "solid-fuel", "coal", "none"}, + default_value = "coke", + }, + { + type = "bool-setting", + name = "bzfoundry-smelt", + setting_type = "startup", + default_value = false, + }, +})