Calculation of Commodity Prices in v1.8+
Posted: Mon Jun 03, 2019 2:22 pm
OK, my journey to this question started with an error logged for the In System Trader OXP by Dr.Tripsa
http://wiki.alioth.net/index.php/In_System_Trader
[script.javaScript.exception.ooliteDefined]: ***** JavaScript exception (In_System_Trader 1.4): Error:
Station.setMarketPrice: Invalid arguments ("Alien Items", NaN) -- expected Unrecognised commodity type.
I figured out the error easily enough (old code for price adjustments, based on the pre-1.81 Commodities structure) but I'm having less success finding a solution.
I've read the Market Scripts page
http://wiki.alioth.net/index.php/Oolite ... et_Scripts
and followed the link at the bottom of that page
viewtopic.php?f=4&t=17621#p239979
I've also looked at the ...market.js code in about a dozen OXPs that have been updated for v1.8+ but these all work by recreating the function of the old <= v1.7 code.
This seems like an unsatisfactory solution, not only because it effectively rolls Oolite back the old days, but also because it will not work for non-legacy commodities added by other OXPs.
So here's my question:
Is there an example of the New updateLocalCommodityDefinition code, i.e. using the New trade-goods.plist values: price_average, price_economic and price_random?
I've read the trade-goods.plist page
http://wiki.alioth.net/index.php/Trade-goods.plist
and I understand the use of price_average and price_random values, but the documentation for price_economic is less clear:
price_economic
I'm assuming this is all dealt with somewhere in the Oolite source code, and I'd be happy just to lift that bit of code, but I don't know how to get my hands on it.
This is my first post, so apologies if it's in the wrong place, or has already been dealt with - I've searched this forum for similar posts but I can only find this one:
viewtopic.php?f=4&t=3243&p=258017&hilit ... ic#p258017
which includes a question about how prices are calculated but that doesn't seem to have been answered.
http://wiki.alioth.net/index.php/In_System_Trader
[script.javaScript.exception.ooliteDefined]: ***** JavaScript exception (In_System_Trader 1.4): Error:
Station.setMarketPrice: Invalid arguments ("Alien Items", NaN) -- expected Unrecognised commodity type.
I figured out the error easily enough (old code for price adjustments, based on the pre-1.81 Commodities structure) but I'm having less success finding a solution.
I've read the Market Scripts page
http://wiki.alioth.net/index.php/Oolite ... et_Scripts
and followed the link at the bottom of that page
viewtopic.php?f=4&t=17621#p239979
I've also looked at the ...market.js code in about a dozen OXPs that have been updated for v1.8+ but these all work by recreating the function of the old <= v1.7 code.
This seems like an unsatisfactory solution, not only because it effectively rolls Oolite back the old days, but also because it will not work for non-legacy commodities added by other OXPs.
So here's my question:
Is there an example of the New updateLocalCommodityDefinition code, i.e. using the New trade-goods.plist values: price_average, price_economic and price_random?
I've read the trade-goods.plist page
http://wiki.alioth.net/index.php/Trade-goods.plist
and I understand the use of price_average and price_random values, but the documentation for price_economic is less clear:
price_economic
- The proportion of the price affected by the system economy.
0 means that this good does not change in price depending on system economy.
0.3 means that the good would be 0.7 times price_average in an ideal exporting system,
and 1.3 times price_average in an ideal importing system.
I'm assuming this is all dealt with somewhere in the Oolite source code, and I'd be happy just to lift that bit of code, but I don't know how to get my hands on it.
This is my first post, so apologies if it's in the wrong place, or has already been dealt with - I've searched this forum for similar posts but I can only find this one:
viewtopic.php?f=4&t=3243&p=258017&hilit ... ic#p258017
which includes a question about how prices are calculated but that doesn't seem to have been answered.