Avorion Forum

General => Mods => Topic started by: Laserzwei on March 06, 2017, 02:39:03 PM

Title: [MOD] All Production Chains
Post by: Laserzwei on March 06, 2017, 02:39:03 PM
The current game is missing 2 (supply-)factories that prevent you from building fully independent Productionchains:

1) Diamonds
2) Gems*

This small addon adds
A different way of getting Biogas:
Bio Gas Fermenter
40xPlant -> 4xBio Gas + 10xWater + garbage: 1xToxic Waste

Version M
1) Diamond Mine

Version S
1)Diamond Factory
2xEnergy Cell + 2xCoal -> 2xDiamond

*Gems are not provided.

You can only install one Version at a time!

From Avorion 0.23 on, this mod will be continued in the workshop

S (https://steamcommunity.com/sharedfiles/filedetails/?id=1692693432)
M (https://steamcommunity.com/sharedfiles/filedetails/?id=1692693709)
Since 0.23+ became the main gameversion, there is no download here.

Version History
Spoiler: show

-- 1.4 for beta 0.21 [2019-02-26]
  - renamed modfile to productionChains
  - added names for special factories (vanilla)
-- 1.3 for 0.20.x [2018-12-04]
  - anti-grav -> antigrav
  - removed 2 double Noble metal mines (vanilla)
-- 1.2
   - double silicon removed
   - using vanilla Raw Oil and Coal production
   - adjusted Diamond production
-- 1.1
  - 0.15 economy update compatibility
-- 1.0
  - Cink->Zinc(0.12)
-- 0.99
  - release


Installation: like any other mod drop the content of the zip file into your /Avorion/ installation folder. By default Version S is selected.
To swtich to Version M you have to uncomment line 130 and comment line 131 out:

Code: [Select]
if not pcall(require, "mods/extraminesM/scripts/lib/productionsindex") then print("Failed to load extraminesM") end
--if not pcall(require, "mods/extraminesS/scripts/lib/productionsindex") then print("Failed to load extraminesS") end
There should only be 2 if at the end of the file.

Files
/data/scripts/lib/productionsindex.lua

Uninstall: just replace /data/scripts/lib/productionsindex.lua with the Vanilla one.
Already build Player/NPC stations will KEEP the mod's Production.

License
Public Domain (https://en.wikipedia.org/wiki/Public_domain)
Title: Re: [MOD] All Production Chains
Post by: Gatt on March 06, 2017, 04:43:27 PM
Definitely going to download this when i get home.  This should fill in the gaps until the devs add their planned planetary stations to buy these things.  Thanks for the mod
Title: Re: [MOD] All Production Chains
Post by: Splutty on March 14, 2017, 11:56:54 PM
I've been thinking about this same problem. The issue is that Raw Oil and Coal from an asteroid are silly, since both are products from bio degradation. So unless the asteroid is from an exploded Earth type planet, they're not going to have either.

So what I thought was to make a Coal Compressor type factory that takes Carbon and makes it into Coal.

For Oil, we can use bio oils, but that wouldn't make sense for a lot of things like Plastic factories, so I added some things for Plastic, based on: https://en.wikipedia.org/wiki/Polyamide_11 (https://en.wikipedia.org/wiki/Polyamide_11)

In goodindex.lua:
Code: [Select]
goods["Castor Bean"] = {name="Castor Bean", plural="Castor Beans", description="Beans mostly used in the production of Polyamide 11 bioplastics.", icon="data/textures/icons/coffee-beans.png", price=321, size=0.2, level=5, importance=0, illegal=false, dangerous=false, }
In productionsindex.lua:
Code: [Select]
table.insert(productions, {factory="${good} Manufacturer ${size}", ingredients={{name="Castor Bean", amount=1, optional=0}, {name="Energy Cell", amount=1, optional=1}}, results={{name="Plastic", amount=5}}, garbages={}})
table.insert(productions, {factory="${good} Farm ${size}", ingredients={{name="Energy Cell", amount=1, optional=1}, {name="Water", amount=10, optional=0}}, results={{name="Castor Bean", amount=12}}, garbages={{name="Oxygen", amount=1}}})

I've just added a Coal Mine for now :)
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on March 15, 2017, 10:27:45 AM
I've been thinking about this same problem. The issue is that Raw Oil and Coal from an asteroid are silly, since both are products from bio degradation. So unless the asteroid is from an exploded Earth type planet, they're not going to have either.

So what I thought was to make a Coal Compressor type factory that takes Carbon and makes it into Coal.

For Oil, we can use bio oils, but that wouldn't make sense for a lot of things like Plastic factories, so I added some things for Plastic, based on: https://en.wikipedia.org/wiki/Polyamide_11 (https://en.wikipedia.org/wiki/Polyamide_11)

In goodindex.lua:
Code: [Select]
goods["Castor Bean"] = {name="Castor Bean", plural="Castor Beans", description="Beans mostly used in the production of Polyamide 11 bioplastics.", icon="data/textures/icons/coffee-beans.png", price=321, size=0.2, level=5, importance=0, illegal=false, dangerous=false, }
In productionsindex.lua:
Code: [Select]
table.insert(productions, {factory="${good} Manufacturer ${size}", ingredients={{name="Castor Bean", amount=1, optional=0}, {name="Energy Cell", amount=1, optional=1}}, results={{name="Plastic", amount=5}}, garbages={}})
table.insert(productions, {factory="${good} Farm ${size}", ingredients={{name="Energy Cell", amount=1, optional=1}, {name="Water", amount=10, optional=0}}, results={{name="Castor Bean", amount=12}}, garbages={{name="Oxygen", amount=1}}})

I've just added a Coal Mine for now :)
I have no plans to change the current setup. If you think that your changes are worth to be used by other players, then pack them into a mod and publish it in a seperate new Topic.
Title: Re: [MOD] All Production Chains
Post by: Splutty on March 15, 2017, 07:29:29 PM
Hmm. We might want to make a thread with all these factory additions, not specifically one mod, just what people could add or change.

Right now I'm too busy building stuff, though!

Edit: On a different note, have you been able to figure out how the price for a factory/mine is being calculated? My bean farm is costing tons of money to build..
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on March 15, 2017, 08:15:54 PM
from tradingmanager.lua
buying:
Code: [Select]
-- empty stock -> higher price
    local factor = getNumGoods(goodName) / getMaxStock(good.size) -- 0 to 1 where 1 is 'full stock'
    factor = 1 - factor -- 1 to 0 where 0 is 'full stock'
    factor = factor * 0.4 -- 0.4 to 0
    factor = factor + 0.8 -- 1.2 to 0.8; 'no goods' to 'full'

    local relationFactor = 1
    if sellingFaction then
        local sellerIndex = nil
        if type(sellingFaction) == "number" then
            sellerIndex = sellingFaction
        else
            sellerIndex = sellingFaction.index
        end

        if sellerIndex then
            local relations = Faction():getRelations(sellerIndex)

            if relations < -10000 then
                -- bad relations: faction pays less for the goods
                -- 10% to 100% from -100.000 to -10.000
                relationFactor = lerp(relations, -100000, -10000, 0.1, 1.0)
            elseif relations >= 50000 then
                -- very good relations: factions pays MORE for the goods
                -- 100% to 120% from 80.000 to 100.000
                relationFactor = lerp(relations, 80000, 100000, 1.0, 1.15)
            end

            if Faction().index == sellerIndex then relationFactor = 0 end
        end
    end

    return round(good.price * relationFactor * factor * buyPriceFactor)

selling:
Code: [Select]
local factor = getNumGoods(goodName) / getMaxStock(good.size) -- 0 to 1 where 1 is 'full stock'
    factor = 1 - factor -- 1 to 0 where 0 is 'full stock'
    factor = factor * 0.4 -- 0.4 to 0
    factor = factor + 0.8 -- 1.2 to 0.8; 'no goods' to 'full'


    local relationFactor = 1
    if buyingFaction then
        local sellerIndex = nil
        if type(buyingFaction) == "number" then
            sellerIndex = buyingFaction
        else
            sellerIndex = buyingFaction.index
        end

        if sellerIndex then
            local relations = Faction():getRelations(sellerIndex)

            if relations < -10000 then
                -- bad relations: faction wants more for the goods
                -- 200% to 100% from -100.000 to -10.000
                relationFactor = lerp(relations, -100000, -10000, 2.0, 1.0)
            elseif relations > 30000 then
                -- good relations: factions start giving player better prices
                -- 100% to 80% from 30.000 to 90.000
                relationFactor = lerp(relations, 30000, 90000, 1.0, 0.8)
            end

            if Faction().index == sellerIndex then relationFactor = 0 end
        end

    end

    return round(good.price * relationFactor * factor * sellPriceFactor)
Title: Re: [MOD] All Production Chains
Post by: Splutty on March 16, 2017, 03:13:37 AM
That's the buying of the goods for NPC factories and such. What I was looking for was the actual price when you build a factory.

I'll continue looking if I ever stop building stuff... >< Money isn't really a serious issue either way.

Edit: Thanks for those code snippets, though, I'm going to have to look into those as well if I want to finish my little trader code.
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on March 16, 2017, 09:13:09 AM
price variance broken down is roughly price*0.5*relationfactor for full stock and price*1.5*relationfactor for empty stocks.

building a factory is defined in stationfounder.lua and Minefounder.lua:

Code: [Select]
local diff = resultValue - ingredientValue

    local costs = 3000000 -- 3 mio minimum for a factory
    costs = costs + diff * 4500
where resultValue is the accumulated Value (good.price) of produced goods and ingredientValue is the accumulated Value of all ingredients.
Title: Re: [MOD] All Production Chains
Post by: Splutty on March 16, 2017, 02:42:33 PM
price variance broken down is roughly price*0.5*relationfactor for full stock and price*1.5*relationfactor for empty stocks.

building a factory is defined in stationfounder.lua and Minefounder.lua:

Code: [Select]
local diff = resultValue - ingredientValue

    local costs = 3000000 -- 3 mio minimum for a factory
    costs = costs + diff * 4500
where resultValue is the accumulated Value (good.price) of produced goods and ingredientValue is the accumulated Value of all ingredients.

Yep. I found it and adjusted the price of my beans to a more reasonable level. I'm still working my way through all the scripting and documentation, but I'll get there, sooner or later!

Thanks for the help :)
Title: Re: [MOD] All Production Chains
Post by: Raio_Verusia on August 01, 2017, 12:50:04 PM
As of the most recent updates, I'm not sure why but I installed this and the found a mine menu's completely blank. It has no mine options what-so-ever. Mod conflict? Maaaaybe? But I removed this mod and restored the original productionsindex.lua back in it's place and the mines show up again.
Title: Re: [MOD] All Production Chains
Post by: rzemic on August 01, 2017, 03:36:14 PM
Hello,

Same situation here. Blank mine menu after update.
Title: Re: [MOD] All Production Chains
Post by: Hammelpilaw on August 01, 2017, 05:24:24 PM
Hello,

Same situation here. Blank mine menu after update.

It is beacause of the fixed spelling of zinc, mod needs to be updated.
But you can also easily do by yourself until mod gets updated:

Open the modfile with any texteditor like notepad and replace all "Cink" entries by "Zinc", then it will work again.
Title: Re: [MOD] All Production Chains
Post by: rzemic on August 01, 2017, 07:10:07 PM
Thanks man :) It worked .
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on August 07, 2017, 04:13:18 PM
update released to include corrected Zink-name
Title: Re: [MOD] All Production Chains
Post by: Azerik on October 11, 2017, 12:19:16 AM
Forgive me the noobish questions, this is the first mod I'm thinking of applying to the server I run.

Is that productionindex file one that gets updated much?  Would it only get updated when stations are added to the game? 

I'm technically adept, but never really done this sort of thing precisely.  The last thing I want to do is skrag the server, or be stuck waiting for a mod to be updated before I can run a new patch.
Title: Re: [MOD] All Production Chains
Post by: Shrooblord on October 11, 2017, 01:20:12 AM
Well I guess that depends a little on how you plan to update your server. If you want to keep it up-to-date always, then I advise you to keep a copy of your most recent version of the Steam\...\Avorion\data folder and always make a copy before you apply a new patch, then diffcheck (https://www.diffchecker.com/) the newly patched files against your older copy, and see if any files were affected that are being altered / interacted with by your mods.

If so, you can read in the diffcheck what exactly changed, and try to make an informed decision on whether or not the update would break the mods, and if you don't trust it, just hold back on the update (i.e. "patch" your game back down using the older copy you preserved) and ask around on these fora whether the mod authors think the update will have a negative impact on the way the mod functions.

I know that all sounds rather obtuse and like a lot of work to have to do each time there's an update, and you're right. It's why I'm currently feverishly trying to create a mod manager to remedy that and do all of that for you, and why we'll be super happy once modding gets integrated into the Steam Workshop like the devs say they plan on doing at some point, and the installation of mods becomes a much more streamlined process.
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on October 11, 2017, 08:31:55 AM
Forgive me the noobish questions, this is the first mod I'm thinking of applying to the server I run.

Is that productionindex file one that gets updated much?  Would it only get updated when stations are added to the game? 

I'm technically adept, but never really done this sort of thing precisely.  The last thing I want to do is skrag the server, or be stuck waiting for a mod to be updated before I can run a new patch.
Since I released this mod, the file was never changed. This is highly unlikely to change and even if it did, you should still be able to use the modded file.
Title: Re: [MOD] All Production Chains
Post by: Hammelpilaw on October 16, 2017, 06:10:43 PM
Since I released this mod, the file was never changed. This is highly unlikely to change and even if it did, you should still be able to use the modded file.

*smartassmode on* Cink > Zinc *smartassmode off*  :P

But its true, this file usely never changes.
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on October 16, 2017, 07:04:30 PM
Since I released this mod, the file was never changed. This is highly unlikely to change and even if it did, you should still be able to use the modded file.

*smartassmode on* Cink > Zinc *smartassmode off*  :P

But its true, this file usely never changes.
darn forgot about it :D
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on November 14, 2017, 11:14:58 PM
updated to 1.1
- 1.1
  0.15 economy update compatibility
follow the new install instructions
Title: Re: [MOD] All Production Chains
Post by: Nachtu on December 18, 2017, 03:33:34 PM
Can't seem to find a production source for Gems in the game.

Jewelry production chain seems a relatively sweet mid tier chain, and it needs Gems/Diamonds. This mod covers Diamons, and that's great!

Can you maybe add Gems too?  ::)

Edit: actually the whole chain might need some additional work, since there's no place for Jewelry to be sold except random Trading Posts. This is a problem with some other production chains as well I believe.
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on December 04, 2018, 03:53:26 PM
updated
-- 1.3 for 0.20.x [2018-12-04]
  - anti-grav -> antigrav
  - removed 2 double Noble metal mines (vanilla)
Title: Re: [MOD] All Production Chains
Post by: Serge-KV87 on February 23, 2019, 02:50:55 PM
Not working for me. In any of the modes....
Title: Re: [MOD] All Production Chains
Post by: Laserzwei on February 26, 2019, 07:27:53 PM
updated for 0.21 beta
-- 1.4 for beta 0.21 [2019-02-26]
  - renamed modfile to productionChains
  - added names for special factories (vanilla)