WIP In System Trader (Triage thread)

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

Moderators: winston, another_commander

Post Reply
User avatar
Dr.Tripsa
Dangerous
Dangerous
Posts: 84
Joined: Mon Apr 30, 2012 9:33 pm
Location: In your cargo bay, eating your chips.

WIP In System Trader (Triage thread)

Post by Dr.Tripsa »

trying to get this working but getting an error

Station.setMarketPrice: Invalid arguments ("Food", "190-2") -- expected Price must be between 0 and 1020 decicredits.

Code: Select all

"use strict";
this.name        = "In_System_Trader"; 
this.author      = "DrTripsa"; 
this.copyright   = "2013 Rob Hess";
this.licence     = "CC BY 3.0"; 
this.description = "In system trader support"; 
this.version     = "1.0";

//1.0 Basic changes, re-calculate prices/quantities when player leaves main station

this.shipLaunchedFromStation = function(station)
{
     if (station.isMainStation)
	 {
		 
		 var RAND_MULT = (system.scrambledPseudoRandomNumber(clock.minutes) * 255);
		 station.setMarketPrice("Food",(station.market.food.marketBasePrice + (RAND_MULT & station.market.food.marketMaskPrice) + ( system.economy * station.market.food.marketEcoAdjustPrice)));
		 station.setMarketQuantity("Food",(station.market.food.marketBaseQuantity + (RAND_MULT & station.market.food.marketMaskQuantity) + ( system.economy * station.market.food.marketEcoAdjustQuantity)) );
	 }
}
The end result will be a new market with each launch (of the player) from the main station, based correctly on economy etc
as you can see the number is currently not in range, but I'm unsure has to how to fix this.

any help would be greatly appreciated.
No, I'm not a Trumble... that's a speciest and offensive remark!
~munch~
What?.... I'm hungry.
User avatar
submersible
Commodore
Commodore
Posts: 264
Joined: Thu Nov 10, 2011 7:49 am

Re: WIP In System Trader (Triage thread)

Post by submersible »

Dr.Tripsa wrote:
trying to get this working but getting an error

Station.setMarketPrice: Invalid arguments ("Food", "190-2") -- expected Price must be between 0 and 1020 decicredits.

Code: Select all

		 station.setMarketPrice("Food",(station.market.food.marketBasePrice + (RAND_MULT & station.market.food.marketMaskPrice) + ( system.economy * station.market.food.marketEcoAdjustPrice)));
Guessing here;

I think the last + is stringwise (concatenation not addition) , so instead of 190 + -2 = 188 ; you get "190" + "-2" giving "190-2".

Go back to the documentation for those properties and be certain they are really numbers.

you could try wrapping things in Number() to explicitly cast into numeric.

Edit: slightly clarify +
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: WIP In System Trader (Triage thread)

Post by cim »

submersible wrote:
Go back to the documentation for those properties and be certain they are really numbers.
They're mostly strings. This is probably a bug.
User avatar
Dr.Tripsa
Dangerous
Dangerous
Posts: 84
Joined: Mon Apr 30, 2012 9:33 pm
Location: In your cargo bay, eating your chips.

Re: WIP In System Trader (Triage thread)

Post by Dr.Tripsa »

station.setMarketPrice("Food",Number(station.market.food.marketBasePrice + (RAND_MULT & station.market.food.marketMaskPrice) + ( system.economy * station.market.food.marketEcoAdjustPrice)));
gives a now error

Invalid arguments ("Food", NaN) -- expected Price must be between 0 and 1020 decicredits.

apparently Number() is Not a Number?!
No, I'm not a Trumble... that's a speciest and offensive remark!
~munch~
What?.... I'm hungry.
User avatar
Dr.Tripsa
Dangerous
Dangerous
Posts: 84
Joined: Mon Apr 30, 2012 9:33 pm
Location: In your cargo bay, eating your chips.

Re: WIP In System Trader (Triage thread)

Post by Dr.Tripsa »

Well submersible and cim had it! THANKS!!!!


now to do all the others...
No, I'm not a Trumble... that's a speciest and offensive remark!
~munch~
What?.... I'm hungry.
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: WIP In System Trader (Triage thread)

Post by Wildeblood »

I question the purpose: changing the prices every time you launch means having the opportunity of making money without going anywhere, not even as far as another station within sight. Just launch, re-dock.
User avatar
Dr.Tripsa
Dangerous
Dangerous
Posts: 84
Joined: Mon Apr 30, 2012 9:33 pm
Location: In your cargo bay, eating your chips.

Re: WIP In System Trader (Triage thread)

Post by Dr.Tripsa »

Wildeblood wrote:
I question the purpose: changing the prices every time you launch means having the opportunity of making money without going anywhere, not even as far as another station within sight. Just launch, re-dock.
Prices remain within system average range so any profit by trading with the main station alone will be meager at best, it's a fair question, but one I considered carefully in making this OXP.

This has been released https://bb.oolite.space/viewtopic.php?f=4&t=13702!
No, I'm not a Trumble... that's a speciest and offensive remark!
~munch~
What?.... I'm hungry.
User avatar
Dr.Tripsa
Dangerous
Dangerous
Posts: 84
Joined: Mon Apr 30, 2012 9:33 pm
Location: In your cargo bay, eating your chips.

Re: WIP In System Trader (Triage thread)

Post by Dr.Tripsa »

next hurdle has to do with the upcoming update,
apparently I am somehow using descriptions.plist wrong?

here is the plist

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>istgreet</key>
   <array>
       <string>"Welcome back, Commander..."</string>
       <string>"Still in this backwater system, Commander?..."</string>
       <string>"Oh you're back Commander, is it tuesday already..."</string>
       <string>"Back already eh? Bet you can do those spacelanes in your sleep..."</string>
       <string>"Aww, miss me already Commander?..."</string>
   </array>
   <key>istinvite</key>
   <array>
       <string>"You should speak with my cousin"</string>
	   <string>"You should speak with my old friend"</string>
	   <string>"You should speak with my Fathers brothers cousins former roomate"</string>
	   <string>"You should speak with my boss"</string>
	   <string>"You should speak with my underling"</string>
	   <string>"You should speak with my minion"</string>
	   <string>"You should speak with my former lover, whom I am awkwardly still friends with,"</string>
	   <string>"You should speak with my clone"</string>
	   <string>"You should speak with my Latin dance instructor"</string>
	   <string>"You should speak with my sentient houseplant"</string>
	   <string>"You should speak with my conjoined twin"</string>
	   <string>"You should speak with my friends friend"</string>
   </array>
   <key>istoffer</key>
   <array>
       <string>"They owe me a favor."</string>
       <string>"They need a good pilot."</string>
       <string>"What about? Getting out of this arse end of space of course!"</string>
       <string>"They've got need of someone... descrite."</string>
       <string>"They need a fast ship, and no Naval entanglements, if you catch my drift."</string>
	   <string>"They owe me... especially after last night, erm... don't ask."</string>
   </array>
</dict>
</plist>
here is the code that uses it

Code: Select all

this.shipEnteredStationAegis = function(station)
{
     //Give player a hint that the friends they have made might have deals for them
	 //for a test, we'll remove the randomness
	 //var RAND_MULT = (system.scrambledPseudoRandomNumber(clock.minutes) * 255);
	 if(this.IN_SYSTEM_TRADER_REP >= 0)
		 {
		     //periodically we give the player a hint... friend of a friend etc
			 var message = [istgreet] + " " + [istinvite] + " " + [nom] + " " + [istoffer];
			 player.commsMessage(message);
		 }
}
and here is the error

Code: Select all

17:53:19.802 [script.javaScript.exception.notDefined]: ***** JavaScript exception (In_System_Trader 1.05): ReferenceError: istgreet is not defined
what am I doing wrong?
No, I'm not a Trumble... that's a speciest and offensive remark!
~munch~
What?.... I'm hungry.
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: WIP In System Trader (Triage thread)

Post by Wildeblood »

Code: Select all

 <string>"Welcome back, Commander..."</string>

Code: Select all

 <string>Welcome back, Commander...</string>
Although it might be something else, as well. I wouldn't bother using descriptions.plist, myself.
User avatar
Dr.Tripsa
Dangerous
Dangerous
Posts: 84
Joined: Mon Apr 30, 2012 9:33 pm
Location: In your cargo bay, eating your chips.

Re: WIP In System Trader (Triage thread)

Post by Dr.Tripsa »

it looks like support for [item in descriptions.plist] is only in legacy scripting...
I may have to hardcode it.. ick
No, I'm not a Trumble... that's a speciest and offensive remark!
~munch~
What?.... I'm hungry.
User avatar
submersible
Commodore
Commodore
Posts: 264
Joined: Thu Nov 10, 2011 7:49 am

Re: WIP In System Trader (Triage thread)

Post by submersible »

Dr.Tripsa wrote:
it looks like support for [item in descriptions.plist] is only in legacy scripting...
I may have to hardcode it.. ick
Or not - have you tried

Code: Select all

expandDescription("[istoffer]")
User avatar
Dr.Tripsa
Dangerous
Dangerous
Posts: 84
Joined: Mon Apr 30, 2012 9:33 pm
Location: In your cargo bay, eating your chips.

Re: WIP In System Trader (Triage thread)

Post by Dr.Tripsa »

I can't seem to find reference to that function on the wiki, but I've found a work around for now
btb

1.05 released :)

EDIT: found it... well there is always 1.06
No, I'm not a Trumble... that's a speciest and offensive remark!
~munch~
What?.... I'm hungry.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6311
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: WIP In System Trader (Triage thread)

Post by Diziet Sma »

Minor spelling point.. "descrite" should be "discrete". :wink:
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
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: WIP In System Trader (Triage thread)

Post by Eric Walch »

You probably found it by now, but look again at:

Code: Select all

var message = [istgreet] + " " + [istinvite] + " " + [nom] + " " + [istoffer];
"[" is not a valid JS command. It should be

Code: Select all

var message = "[istgreet]" + " " + "[istinvite]" + " " + "[nom]" + " " + "[istoffer]";
or just:

Code: Select all

var message = "[istgreet] [istinvite] [nom] [istoffer]";
And remember those names are globally shared among other oxps, so make them more unique.
Post Reply