Reading commodity prices

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
lesliev
Average
Average
Posts: 14
Joined: Sun Aug 15, 2010 5:07 pm

Reading commodity prices

Post 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
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post 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...
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Post by Cmd. Cheyd »

DH is correct. Commodity information is not exposed to javascript at this time.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post 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... :wink:
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Reading commodity prices

Post 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 :wink:
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Reading commodity prices

Post 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! :D

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
lesliev
Average
Average
Posts: 14
Joined: Sun Aug 15, 2010 5:07 pm

Post 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?
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post 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.
lesliev
Average
Average
Posts: 14
Joined: Sun Aug 15, 2010 5:07 pm

Post 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.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post 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! :D

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.
lesliev
Average
Average
Posts: 14
Joined: Sun Aug 15, 2010 5:07 pm

Post 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!
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Post 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.
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
Post Reply