Re: Scripted 'new' event handlers.

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

Moderators: winston, another_commander

Post Reply
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6885
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Re: Scripted 'new' event handlers.

Post by Disembodied »

Wildeblood wrote:
I'm an explorer, not a trader, so I'd be grateful for recommendations regarding price levels.

Trading Assistant OXP ver. 0.1
The Oolite Reference Sheet has minimum, average and maximum prices on page 3.
Last edited by Disembodied on Sun Jul 22, 2012 1:16 pm, edited 1 time in total.
Reason: removing URL as per Wildeblood's request
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2407
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

AI Trading Assistant OXP

Post by Wildeblood »

Here is a demonstration OXP that uses Capt. Murphy's example code, he posted yesterday, for a Trading Assistant that can warn the player if they're paying too much, selling for too low a price, or getting a good deal when buying or selling cargo.

Download AI Trading Assistant OXP ver. 1.6
AI Trading Assistant OXP ver. 1.6
Date: September 11th, 2012
Authors: Capt. Murphy, Wildeblood


Installation and use:

Place the Trading Assistant OXP into your "AddOns" folder. Head to a planet of technical level 9, or above, where you can purchase the Trading Assistant from the ship outfitters for 2012 credits. Trading Assistant will not be offered in the ship outfitters in communist systems.

Once purchased, the Trading Assistant will monitor your cargo trades in real time, and give an immediate warning if you are paying unusually high prices, or selling for low prices that are likely to result in unprofitable trading. It will also record the prices you pay for cargo, and later remind you when you sell. Being an artificial intelligence, and not heavy equipment, Trading Assistant is portable between ships, and will stay with you if you buy a new ship in the shipyard.


Modifying Trading Assistant

If you wish to change the (not very) witty remarks included in the player alerts, open the OXP and - inside the "Config" folder - open the file named "script.js" using a text-editor. The section containing the texts of the player alerts is very near the top of the file, and clearly labelled.

If you wish to change the names of the commodities shown on the market screen, similarly find the file named "descriptions.plist OFF" inside the "Config" folder, rename it to "descriptions.plist" and edit it using a text-editor. The example file supplied over-rides only the section of descriptions.plist (a quite large file elsewhere within Oolite) pertaining to commodity names.


Change Log:

1.6 (September 11th, 2012) Column of average prices now shown on market screen.

1.5 (August 13th, 2012) Texts of player alerts now correctly display customised commodity names.

1.4 BETA (July 22nd, 2012) Now keeps a record of the prices you pay for cargo.

1.3 (July 12th, 2012) Added HUD change when on market screen.

1.2 (May 17th, 2012) Compatible with development (1.77) versions of Oolite.

1.1 (April 21st, 2012) Added warnings when buying illegal goods.

1.0 (April 5th, 2012) Known bugs fixed, officially released.

0.3 (April 4th, 2012) Price spreads set (thanks, SandJ), and script.js re-arranged to encourage easy editing.

0.2 (April 3rd, 2012) Thanks to Disembodied for reminding me where to find the list of average commodity prices.

0.1 (April 3rd, 2012) Functional script of trading assistant, based on example code posted on-line by Capt. Murphy.
Last edited by Wildeblood on Tue Sep 11, 2012 9:39 am, edited 10 times in total.
"Would somebody stop that bloody music!"
User avatar
SandJ
---- E L I T E ----
---- E L I T E ----
Posts: 1048
Joined: Fri Nov 26, 2010 9:08 pm
Location: Help! I'm stranded down here on Earth!

Re: Scripted 'new' event handlers.

Post by SandJ »

Disembodied wrote:
Wildeblood wrote:
I'm an explorer, not a trader, so I'd be grateful for recommendations regarding price levels.
The Oolite Reference Sheet has minimum, average and maximum prices on page 3.
In the spreadsheet I use, I have two sets of values.

1. Main station prices
If the price is less than halfway between lowest and average, it tells me to buy.
If the price is more than halfway between highest and average, it tells me to sell.
E.g. food is min 2.0, average 5.0, max 8.0
It suggests I buy when price is < 3.5 ( (2.0 + 5.0) / 2)
It suggests I sell when price is > 6.5 ( (5.0 + 8.0 ) / 2)
This results in a cargo hold full is miscellaneous rubbish and is no good as an automated system, but is a handy guide. It is left to me to decide whether to sell food or alloys at a rubbish price to make room for something more profitable.

2. All dockables prices
I kept a track of prices at every kind of non-main station market for 230 dockables. The second half of the spreadsheet tells me to buy when the product is less than the minimum price for a main station, and sell when more than maximum price for a main station. (I did this to work out which ones pay most for what items, so I could work out where best to sell the proceeds of mining: who is buying minerals and alloys?)

Something that used both average (or quartiles as above) and min/max values may be useful.

"Great price, Commander. You won't get that cheaper in a Coriolis!"
"Good price, Commander."
"It's a seller's market here today, Commander."
"Wow! They sure are desperate here - I'd go fetch more from the main station if I were you, Commander."


Another thought for an add-on to it: "Commander, this is a main station, you are clean, and those are prohibited items. Just saying."
Flying a Cobra Mk I Cobbie 3 with nothing but Explorers Club.OXP and a beam laser 4 proper lasers for company :D
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2407
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripted 'new' event handlers.

Post by Wildeblood »

SandJ wrote:
Another thought for an add-on to it: "Commander, this is a main station, you are clean, and those are prohibited items. Just saying."
Unless the price is really good. :wink:
"Would somebody stop that bloody music!"
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: AI Trading Assistant OXP

Post by Zireael »

I was selling Gold at 72.0 Cr. First 5-6 tonnes, I got the Good! you're selling for a high price". The next some, I got the message that I'm selling for below-average.
Same situation with Gemstones at the same station, can't remember the exact value though.
NorthenderPNE
Deadly
Deadly
Posts: 132
Joined: Tue Jul 25, 2006 2:32 pm

Re: AI Trading Assistant OXP

Post by NorthenderPNE »

I too have had the same issue as Zireael. I was selling platinum for 72cr approx and got both messages at the same time. Using Ai Trading version 1.1 and the latest trunk 1.77.0.4887.

Jon :wink:
totya
Poor
Poor
Posts: 5
Joined: Mon May 14, 2012 2:22 pm

Re: AI Trading Assistant OXP

Post by totya »

Hi!

With Oolite latest beta (rev4936) and AI Trading Assistant OXP (1.1) I get information from price without I have Trading Assistant. Simple I start new game, and Trading Assistant is working on F8 screen.

I know, Oolite 1.77 is not official at the moment.

Thanks.
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:

Re: AI Trading Assistant OXP

Post by Cody »

Welcome aboard, totya - you'll know me as Cody at SSC.
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!
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2407
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant OXP

Post by Wildeblood »

totya wrote:
With Oolite latest beta (rev4936) and AI Trading Assistant OXP (1.1) I get information from price without I have Trading Assistant. Simple I start new game, and Trading Assistant is working on F8 screen.

I know, Oolite 1.77 is not official at the moment.
That's because the function Captain Murphy wrote to make this work is now incorporated into Oolite:-
cim wrote:
Phasted wrote:
An event-handler (well, two actually) that triggers when the player buys or sells cargo (passing commoditiy name, quantity, and price).
playerBoughtCargo(commodity,units,price) and playerSoldCargo(commodity,units,price) are available as of r4851.
You will find it misleading though, because Murphy's version passes the total price and cim's version passes the price per unit as parameters.

I've just uploaded an updated version that should fix this incompatibility.
User avatar
JazHaz
---- E L I T E ----
---- E L I T E ----
Posts: 2991
Joined: Tue Sep 22, 2009 11:07 am
Location: Enfield, Middlesex
Contact:

Re: AI Trading Assistant OXP

Post by JazHaz »

Can we have a New Cargoes version of this? :wink:
totya
Poor
Poor
Posts: 5
Joined: Mon May 14, 2012 2:22 pm

Re: AI Trading Assistant OXP

Post by totya »

Wildeblood wrote:
I've just uploaded an updated version that should fix this incompatibility.
Hi, I see this new version working now correctly, thank you.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2407
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant OXP

Post by Wildeblood »

I added some superficial prettification today:-

Image
User avatar
marcusrg
Deadly
Deadly
Posts: 216
Joined: Fri Jun 08, 2012 3:48 pm
Location: Somewhere in Brazil

Re: AI Trading Assistant OXP

Post by marcusrg »

Thanks, Wildeblood. Upddated here and working fine. :)
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2407
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: AI Trading Assistant OXP

Post by Wildeblood »

Version 1.4 BETA is much better than previous versions, because it records the prices you pay for cargo, then later when you sell, it reminds you how much you paid.

This is a beta version: it works, but I'm stuck with one thing in the script and would much appreciate some help: how do I retrieve the correct .displayName for each cargo type for use in console messages? I can't figure it out.
Last edited by Wildeblood on Mon Aug 13, 2012 9:37 am, edited 2 times in total.
"Would somebody stop that bloody music!"
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: AI Trading Assistant OXP

Post by Thargoid »

The list element of Manifest contains what you need, amongst other bits.
Post Reply