Author Topic: [MOD] All Production Chains  (Read 19076 times)

Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    398
    • View Profile
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
« Last Edit: July 04, 2019, 05:48:13 PM by Laserzwei »
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Gatt

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    45
    • View Profile
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



Splutty

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    258
    • View Profile
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

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 :)



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    398
    • View Profile
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

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.
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Splutty

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    258
    • View Profile
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..



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    398
    • View Profile
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)
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Splutty

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    258
    • View Profile
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.



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    398
    • View Profile
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.
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Splutty

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    258
    • View Profile
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 :)



Raio_Verusia

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    11
    • View Profile
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.



rzemic

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    5
    • View Profile
on: August 01, 2017, 03:36:14 PM
Hello,

Same situation here. Blank mine menu after update.



Hammelpilaw

  • Hero Member
  • *****
  • Status:
    Online
    Posts:
    556
    • View Profile
    • Scrap Yard - Avofactory
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.
Scrap Yard Galaxy
My mods and tools
My Workshop

If you find a bug in my mods please contact me.



rzemic

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    5
    • View Profile
on: August 01, 2017, 07:10:07 PM
Thanks man :) It worked .



Laserzwei

  • Sr. Member
  • ****
  • Status:
    Offline
    Posts:
    398
    • View Profile
on: August 07, 2017, 04:13:18 PM
update released to include corrected Zink-name
My Mod Collection
My Discord     screw google captcha
My Github
Questions?
> PM me here on the forums!



Azerik

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    47
    • View Profile
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.