Page 1 of 1
Reading commodity prices
Posted: Wed Aug 18, 2010 10:32 pm
by lesliev
Hello!
I have been browsing the Javascript reference for a while but I can't seem to see anything for reading commodity prices. I want to read the commodity prices for the whole galaxy - or if that's too slow, perhaps just all the commodity prices within one or two jumps.
How do you do that?
Les
Posted: Wed Aug 18, 2010 10:39 pm
by DaddyHoggy
You can't I don't think.
1) Gameplay wise - canon/handwavium - no system is allowed to transmit its prices beyond its own borders.
2) Code wise - Each system is created pseudorandomly at the moment you jump in to it - before that moment - there is no commodity price list...
Posted: Wed Aug 18, 2010 10:40 pm
by Cmd. Cheyd
DH is correct. Commodity information is not exposed to javascript at this time.
Posted: Wed Aug 18, 2010 10:44 pm
by DaddyHoggy
Cmd. Cheyd wrote:DH is correct. Commodity information is not exposed to javascript at this time.
You know - all my code knowledge is obtained purely by osmosis via these forums from you guys - I'm sure I supposed to be remembering important stuff instead...
Re: Reading commodity prices
Posted: Thu Aug 19, 2010 7:42 am
by Eric Walch
lesliev wrote:Hello!
I have been browsing the Javascript reference for a while but I can't seem to see anything for reading commodity prices. I want to read the commodity prices for the whole galaxy - or if that's too slow, perhaps just all the commodity prices within one or two jumps.
How do you do that?
Les
On the wiki page about commodities.plist is explained how prices are calculated. You will see that is contains a random number. That means that even when you would calculate a correct value for the adjacent system, the market will have changed by the time you arrived there. So even when it would be possible, it would be useless.
You can compare it with the calculation of the tomorrows values of earths commodity market: A lot of people would pay good money when you would find an accurate formula to do that
Re: Reading commodity prices
Posted: Thu Aug 19, 2010 12:06 pm
by Commander McLane
lesliev wrote:Hello!
I have been browsing the Javascript reference for a while but I can't seem to see anything for reading commodity prices.
First of all, hello and welcome to the boards!
You have been unlucky with the Javascript reference, because commodity prices are not in the realm of JavaScript. They are calculated via a plist, and—as the other guys already said—ae calculated only the very moment the player jumps into a system. Therefore no commodity prices for adjacent systems (or the whole galaxy) ever exist.
The documentation is here:
http://wiki.alioth.net/index.php/Commodities.plist
And for everything else which isn't related to JavaScript you will find links to the documentation on the Oolite Scripting category page:
http://wiki.alioth.net/index.php/Catego ... _scripting
Posted: Thu Aug 19, 2010 12:59 pm
by lesliev
Hmmm, thanks everyone.
I did see the Commodities.plist wiki entry but assumed MARKET_RND was random with a fixed seed so that market prices stayed the same for each system - like in the original Elite.
I assume Javascript can't read the plist dictionaries after they have been loaded by Oolite?
Posted: Thu Aug 19, 2010 1:07 pm
by Commander McLane
lesliev wrote:I did see the Commodities.plist wiki entry but assumed MARKET_RND was random with a fixed seed so that market prices stayed the same for each system - like in the original Elite.
Market prices
never stayed the same in the original Elite (at least not in the versions I used to play: C64 and Atari ST). They were subject to random just like in Oolite—which is at its core a faithful recreation of Elite.
lesliev wrote:I assume Javascript can't read the plist dictionaries after they have been loaded by Oolite?
No, not generally. Only where certain entries of the dictionaries have been exposed to JS.
You could of course
file a request for exposing the current system's data in either the System or the Station class, or probably in the SystemInfo class.
Posted: Thu Aug 19, 2010 5:55 pm
by lesliev
The version I used to play was the CGA PC version, and later Elite Plus on the PC. There were buying and selling prices for each commodity, not just one price. And the prices always stayed the same for a system. I downloaded Elite Plus again to check.
Back in the DOS days I wrote a program which allowed me to type in the market prices for many of the systems and then calculate optimum trading routes.
Probably a year ago I downloaded the source for Oolite and hacked a lesser "trading computer" into the game - just something to show ((price - average) * cargo_bay_size) next to each commodity. I was thinking of trying to write a few "trading computer" OXP's.
Posted: Thu Aug 19, 2010 6:53 pm
by Commander McLane
lesliev wrote:The version I used to play was the CGA PC version, and later Elite Plus on the PC. There were buying and selling prices for each commodity, not just one price.
That's not Elite, but a rather fundamental aberration from Elite.
lesliev wrote:Probably a year ago I downloaded the source for Oolite and hacked a lesser "trading computer" into the game - just something to show ((price - average) * cargo_bay_size) next to each commodity. I was thinking of trying to write a few "trading computer" OXP's.
We are always happy to welcome a new scripter with new ideas!
However, due to the sometimes rather high fluctuation of prices I doubt the usefulness of calculating the current price against the average. You've already dug into commodities.plist, so you know that also the system economy plays an important role (the average price for any commodity in a rich industrial is very much different from the average price for the same commodity in a poor agricultural). And that doesn't even take into account non-main stations which may (and often do) offer completely different prices and therefore much bigger profit rates.
Posted: Thu Aug 19, 2010 7:06 pm
by lesliev
Well that's just it: showing the difference from the average shows you how much of a good deal you are looking at. And sometimes you have a small profit on something, but there's a full 35t available and that makes it a good buy.
Thanks for all the welcomings!
Posted: Thu Aug 19, 2010 7:11 pm
by Cody
Hi Les and welcome.
The commodity prices in Elite Plus were always a bit strange (a bug?… and not the only one, I hated the joystick bug).
I just booted up my old 3.5 floppy of EP, and actually found my old save games, which I’d given up ever finding… thanks for that. The game moves so fast, and uses 50% of processor power (of course, that’s not in an emulator), compared to 6% for Oolite. A little trip down memory lane, with an old Archangel commander.