Hammelpilaw Posted January 13, 2018 Share Posted January 13, 2018 Player owned stations have negative upgrade costs when their price is below 3 millions (like potato factory). Maybe set a min price of 3mio for all stations, that would also help for modded stations wich may be even cheaper. Link to comment Share on other sites More sharing options...
Rinart73 Posted January 13, 2018 Share Posted January 13, 2018 This happens not because of factory price, but because of how getFactoryUpgradeCost function works (productions.lua). function getFactoryUpgradeCost(production, size) -- calculate the difference between the value of ingredients and results local ingredientValue = 0 local resultValue = 0 for _, ingredient in pairs(production.ingredients) do local good = goods[ingredient.name] ingredientValue = ingredientValue + good.price * ingredient.amount end for _, result in pairs(production.results) do local good = goods[result.name] resultValue = resultValue + good.price * result.amount end local diff = resultValue - ingredientValue local costs = diff * 1000 * size return costs end While we have following in productionsindex.lua: table.insert(productions, {factory="${good} Farm ${size}", ingredients={{name="Energy Cell", amount=6, optional=1}, {name="Water", amount=30, optional=0}}, results={{name="Potato", amount=35}}, garbages={{name="Oxygen", amount=8}}}) So, basically we have following values: ingredientValue = 300 + 600 = 900 resultValue = 840 diff = -60 costs = -60 * 1000 * size Is optional ingredient even a thing? How it works? Anyway, thats because this happens. Link to comment Share on other sites More sharing options...
Hammelpilaw Posted January 13, 2018 Author Share Posted January 13, 2018 Oh yes I see. However, to me it seems this part could be improved. A station can theoreticly have negative prices for creating and updating. Both should be fixed, not just the upgrade cost. It could be like this (untested): function getDiff(production) -- calculate the difference between the value of ingredients and results local ingredientValue = 0 local resultValue = 0 for _, ingredient in pairs(production.ingredients) do local good = goods[ingredient.name] ingredientValue = ingredientValue + good.price * ingredient.amount end for _, result in pairs(production.results) do local good = goods[result.name] resultValue = resultValue + good.price * result.amount end return resultValue - ingredientValue end function getFactoryCost(production) local diff = getDiff(production) if diff < 0 then diff = 0 end local costs = 3000000 -- 3 mio minimum for a factory costs = costs + diff * 4500 return costs end function getFactoryUpgradeCost(production, size) local diff = getDiff(production) if diff < 1 then diff = 1 end local costs = diff * 1000 * size return costs end Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now