[Release] In System Trader OXP 1.40!

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

Moderators: winston, another_commander

ocz
Deadly
Deadly
Posts: 175
Joined: Tue Nov 10, 2015 1:59 pm

Re: [Release] In System Trader OXP 1.40!

Post by ocz » Tue Feb 09, 2016 12:07 am

Turned out JSON did everything just fine from the beginning. Even the nested objects. I just made a stupid mistake, by calling the properties the wrong way. It didn't occure to me and I continued to look for the reason. Then I found on some pages, that JSON in some cases had difficulties with nested objects as properties of object, what also was my theory at that moment.
Once I realized, where I made a mistake, it unfolded rather quickly. (See edits in my post above)


Version 1.5 works and saves/restores data as it should do. (Upload link above)

Xanthin
Average
Average
Posts: 10
Joined: Wed Mar 09, 2016 7:54 pm

Re: [Release] In System Trader OXP 1.40!

Post by Xanthin » Thu Mar 10, 2016 6:10 pm

Hi, it seems that In System Trader and [wiki]Stations for Extra Planets[/wiki] are not compatible together. As soon as I add it to the addons (with its dependicies) I get this error (varying in the commodity and in a 5 minutes interval):

Code: Select all

Exception: Error: Station.setMarketQuantity: Invalid arguments ("radioactives", NaN) -- expected Quantity must be between 0 and the station market capacity.
    Active script: In_System_Trader 1.5
    InSystemTrader_worldscript.js, line 348:
    	station.setMarketQuantity(commodity, qBase);
Having the logging in line 349 of the InSystemTrader_worldscript.js uncommented I can see in the console, that other stations (rock hermits, main station, etc.) are mentioned with price and quantity, but none of the stations added by"sfep" and also not the main station if "sfep" is active.

Like here, just in Lave after fresh start and 5 minutes after leaving the main station:
without "sfep" and any other additional stations adding oxp:

Code: Select all

Rock Hermit radioactives: 208.41196324955206Cr ,3.056493188044678
Rock Hermit radioactives: 208.41196324955206Cr ,3.056493188044678
Rock Hermit radioactives: 208.41196324955206Cr ,3.056493188044678
Coriolis Station radioactives: 208.41196324955206Cr ,12.521762415537875
with "sfep" as the only additional stations adding oxp

Code: Select all

Rock Hermit radioactives: 208.41196324955206Cr ,3.056493188044678
The error also seems to prevent the amw_unit to pop up with its message.

I use Oolite 1.82 x64 under Windows 7 Service Pack 1 64-bit.
The error appears with both, the 1.40 and 1.5 version of In System Trader and Stations fo Extra Planets OXP ver 1.8 (from the inbuilt expansions manager).

Unfortunately I'm quite new here and have no real programming knowledge (it already took me a couple of days to find the source of the error). It would be great if someone has an idea how both could harmonise together since both are a nice addition to the game. :)

ocz
Deadly
Deadly
Posts: 175
Joined: Tue Nov 10, 2015 1:59 pm

Re: [Release] In System Trader OXP 1.40!

Post by ocz » Sat Mar 12, 2016 10:16 pm

I'm sorry I didn't answered immediately, but I'm kind of busy these days.

I found the reason for the bug. The OXP-station's markets of Stations for Extra Planets don't contain a capacity property within the commodities property. This led to multiplying the new quantity value with an undefined value, leaving it undefined itself. That coursed the error. I already wrote a quickfix for this bug, but the OXP stopped working, because of reasons. Again. Reasons I have to figure out. :( Again... And I'm tired right now. I hope I'm still able to communicate every important information to you.

I want to upload a fixed v1.5.1 soon, but in case you don't want to wait, here's the quickfix:

Code: Select all

	var qBase = parseFloat(station.market[commodity].quantity_average);
	var qEcon = qBase * station.market[commodity].quantity_economic * -1 * bias;
	var qRandom = qBase * station.market[commodity].quantity_random * (system.scrambledPseudoRandomNumber(randomizeSeed+2) - system.scrambledPseudoRandomNumber(randomizeSeed+3));
	qBase += qEcon + qRandom;

	//Bugfix 1.5.1: Sometimes station markets seem to be missing the capacity property. In this case 127 will be assumed.
	var capacity;
	if (station.market[commodity].capacity) capacity = station.market[commodity].capacity;
	else capacity = 127;
	
	// Scale quantity to match the capacity of the station
	qBase = (qBase/127) * capacity;
	
	// Make sure quantity DOES really match stations capacity
	if (qBase > capacity) qBase = capacity;
	if (qBase < 0.0) qBase = 0;

	station.setMarketPrice(commodity, pBase);
	station.setMarketQuantity(commodity, qBase);
	log(station.name + " " + commodity + ": " + pBase + "Cr ," + qBase);
And don't worry about being inexperienced in mending OXPs. You're doing well as far as I see it.

ocz
Deadly
Deadly
Posts: 175
Joined: Tue Nov 10, 2015 1:59 pm

Re: [Release] In System Trader OXP 1.40!

Post by ocz » Sun Mar 13, 2016 10:41 am

Version 1.5.1:
with kind help from Xanthin

Changelog:
1.5.1 2016/03/12
  • Bugfix: Some OXP-Station's markets are missing the capacity property for commodities. In this case 127 is now assumed.
Download: In_System_Trader_1.5.1.oxz
Last edited by ocz on Thu Mar 17, 2016 12:31 pm, edited 2 times in total.

Xanthin
Average
Average
Posts: 10
Joined: Wed Mar 09, 2016 7:54 pm

Re: [Release] In System Trader OXP 1.40!

Post by Xanthin » Mon Mar 14, 2016 11:51 pm

Again: thank you very much for the update that fixed the issue and your friendly support!

I spotted [wiki]RRS Group[/wiki], [wiki]Black Monk Monastery[/wiki], [wiki]HoOpy Casino[/wiki] und [wiki]Deep Space Dredger[/wiki] giving me errors too. The console output is **here**. (every mod tested alone with just IST 1.5.1)

ocz
Deadly
Deadly
Posts: 175
Joined: Tue Nov 10, 2015 1:59 pm

Re: [Release] In System Trader OXP 1.40!

Post by ocz » Tue Mar 15, 2016 6:44 pm

JScript is funny.
if capacity = 0 is a given property and you ask if capacity exists (if someStation.market["someCommodity"].capacity) log("Yupp"); else log("Nope");) it tells you "Nope".

If you ask it instead:
if (someStation.market["someCommodity"].capacity||(someStation.market["someCommodity"].capacity==0)) log("Yupp"); else log("Nope");
Its answer is "Yupp".

EDIT: if someStation.market["someCommodity"].hasOwnProperty("capacity") log("Yupp"); else log("Nope"); is the more elegant way to phrase it.


This caused at least, some of the errors with "RRS Group". It's fixed in the upcoming v1.5.2. I hope this fixes all errors in the above mentioned OXPs, but this still needs further validation.
Last edited by ocz on Tue Mar 15, 2016 6:53 pm, edited 1 time in total.

User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2550
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: [Release] In System Trader OXP 1.40!

Post by spara » Tue Mar 15, 2016 6:52 pm

ocz wrote:JScript is funny.
if capacity = 0 is a given property and you ask if capacity exists (if someStation.market["someCommodity"].capacity) log("Yupp"); else log("Nope");) it tells you "Nope".

If you ask it instead:
if (someStation.market["someCommodity"].capacity||(someStation.market["someCommodity"].capacity==0)) log("Yupp"); else log("Nope");
Its answer is "Yupp".
That's because 0 equals false in javascript comparison. In the latter one you're testing if capacity is false, which it is thus the comparison returns true. As it should.

ocz
Deadly
Deadly
Posts: 175
Joined: Tue Nov 10, 2015 1:59 pm

Re: [Release] In System Trader OXP 1.40!

Post by ocz » Tue Mar 15, 2016 7:05 pm

Jupp, now I know that. I just didn't realize there was such a pothole as those falsy values (0, false and ""). At some point I thought var bool = false; if (bool) log("true"); else log("false") yielded true and I thought: 'Aha, the name-only in the if-clause looks up the existence of an object.' (Of course it returns false.) Gave me the wrong impression. Must have used var bool = "false"; or something back then.

ocz
Deadly
Deadly
Posts: 175
Joined: Tue Nov 10, 2015 1:59 pm

Re: [Release] In System Trader OXP 1.40!

Post by ocz » Thu Mar 17, 2016 12:26 pm

Version 1.5.2:
with kind help from Xanthin

Changelog:
1.5.2 2016/03/17
  • Bugfix: A.M.W. message displays commodity name
  • Bugfix: Caught another bug, that has risen from the bugfix in v1.5.1
  • Bugfix+Feature: New values of commodities look now more random.
Download: In_System_Trader_1.5.2.oxz

Xanthin
Average
Average
Posts: 10
Joined: Wed Mar 09, 2016 7:54 pm

Re: [Release] In System Trader OXP 1.40!

Post by Xanthin » Sun Mar 20, 2016 10:54 pm

Great, prices and quantities actualy differ more now per each station at a change event. Thank you for the update.

ocz
Deadly
Deadly
Posts: 175
Joined: Tue Nov 10, 2015 1:59 pm

Re: [Release] In System Trader OXP 1.40!

Post by ocz » Mon Mar 21, 2016 12:14 pm

Xanthin wrote:Great, prices and quantities actualy differ more now per each station at a change event. Thank you for the update.
They are all randomly placed within the range defined for the commodities in the station markets. The calculations are nearly mathematically identical to the calculations the game-engine does when entering a system.

Devium
Competent
Competent
Posts: 60
Joined: Tue Jun 09, 2015 5:39 am

Re: [Release] In System Trader OXP 1.40!

Post by Devium » Thu Jun 02, 2016 4:12 pm

Not sure where this belongs. Had a misjump where my energy banks were slowly depleting though I didn't see any reason why. Was close enough to jump back to planet but game closed when I tried.

Code: Select all

0:50:27.281 [LogEvents]: Player started 15 seconds standard jump countdown
10:50:29.156 [LogEvents]: Player got message from Cobra Mark I 27843 : Everything looks clean at the moment.
10:50:42.288 [LogEvents]: Player will enter witchspace due to standard jump
10:50:42.292 [LogEvents]: Player compass targeted in mode COMPASS_MODE_BEACONS
10:50:42.293 [LogEvents]: Player exited from the vicinity of [Planet position: (2.11446e+006, 1.63349e+006, 337411) radius: 70000 m]
10:50:42.293 [LogEvents]: Player lost lock on G-Z1 Icosahedron Station 24735
10:50:42.352 [LogEvents]: Player will exit witchspace
10:50:42.673 [LogEvents]: Player alert condition changed from 2 to 1
10:50:44.945 [LogEvents]: Player exited from witchspace
10:50:46.179 [LogEvents]: Player new day 2084892
10:50:46.674 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:50:50.179 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:50:53.674 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:50:54.426 [LogEvents]: Player gui screen changed from GUI_SCREEN_MAIN to GUI_SCREEN_SHORT_RANGE_CHART
10:50:57.173 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:00.674 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:02.194 [LogEvents]: Player gui screen will change from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_SYSTEM_DATA
10:51:02.214 [LogEvents]: Player gui screen changed from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_SYSTEM_DATA
10:51:04.175 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:05.110 [LogEvents]: Player gui screen changed from GUI_SCREEN_SYSTEM_DATA to GUI_SCREEN_MAIN
10:51:05.123 [LogEvents]: Player VIEW_FORWARD
10:51:07.112 [LogEvents]: Player gui screen will change from GUI_SCREEN_MAIN to GUI_SCREEN_STATUS
10:51:07.134 [LogEvents]: Player gui screen changed from GUI_SCREEN_MAIN to GUI_SCREEN_STATUS
10:51:07.673 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:09.628 [LogEvents]: Player gui screen will change from GUI_SCREEN_STATUS to GUI_SCREEN_MANIFEST
10:51:09.651 [LogEvents]: Player gui screen changed from GUI_SCREEN_STATUS to GUI_SCREEN_MANIFEST
10:51:11.178 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:14.409 [LogEvents]: Player gui screen changed from GUI_SCREEN_MANIFEST to GUI_SCREEN_SHORT_RANGE_CHART
10:51:14.677 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:18.177 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:21.381 [LogEvents]: Player gui screen changed from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_LONG_RANGE_CHART
10:51:21.672 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:23.506 [LogEvents]: Player gui screen changed from GUI_SCREEN_LONG_RANGE_CHART to GUI_SCREEN_SHORT_RANGE_CHART
10:51:24.032 [LogEvents]: Player gui screen will change from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_SYSTEM_DATA
10:51:24.033 [LogEvents]: Player gui screen changed from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_SYSTEM_DATA
10:51:25.174 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:28.673 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:31.170 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (Smugglers_Illegal 0.7.9): TypeError: system.mainStation is null
10:51:31.170 [LogEvents]: Player gui screen will change from GUI_SCREEN_SYSTEM_DATA to GUI_SCREEN_MARKET
10:51:31.198 [LogEvents]: Player gui screen changed from GUI_SCREEN_SYSTEM_DATA to GUI_SCREEN_MARKET
10:51:32.172 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:35.676 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:35.752 [LogEvents]: Player gui screen will change from GUI_SCREEN_MARKET to GUI_SCREEN_MARKETINFO
10:51:35.755 [LogEvents]: Player gui screen changed from GUI_SCREEN_MARKET to GUI_SCREEN_MARKETINFO
10:51:37.959 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (Smugglers_Illegal 0.7.9): TypeError: system.mainStation is null
10:51:37.960 [LogEvents]: Player gui screen will change from GUI_SCREEN_MARKETINFO to GUI_SCREEN_MARKET
10:51:37.963 [LogEvents]: Player gui screen changed from GUI_SCREEN_MARKETINFO to GUI_SCREEN_MARKET
10:51:39.176 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:41.005 [LogEvents]: Player gui screen changed from GUI_SCREEN_MARKET to GUI_SCREEN_MAIN
10:51:41.007 [LogEvents]: Player VIEW_FORWARD
10:51:42.677 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:43.223 [LogEvents]: Player VIEW_AFT
10:51:44.024 [LogEvents]: Player VIEW_FORWARD
10:51:46.179 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:49.676 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:53.181 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:51:56.677 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:00.176 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:03.679 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:07.176 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:10.673 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:14.180 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:17.674 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:21.200 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:22.641 [LogEvents]: Player VIEW_AFT
10:52:24.276 [LogEvents]: Player VIEW_FORWARD
10:52:24.675 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:28.179 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:31.672 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:35.174 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:38.678 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:42.180 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:45.673 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:47.866 [LogEvents]: Player gui screen changed from GUI_SCREEN_MAIN to GUI_SCREEN_SHORT_RANGE_CHART
10:52:48.862 [LogEvents]: Player gui screen changed from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_LONG_RANGE_CHART
10:52:49.175 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:49.569 [LogEvents]: Player gui screen changed from GUI_SCREEN_LONG_RANGE_CHART to GUI_SCREEN_SHORT_RANGE_CHART
10:52:51.114 [LogEvents]: Player gui screen changed from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_MAIN
10:52:51.117 [LogEvents]: Player VIEW_FORWARD
10:52:52.680 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:55.795 [LogEvents]: Player gui screen changed from GUI_SCREEN_MAIN to GUI_SCREEN_SHORT_RANGE_CHART
10:52:56.181 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:59.674 [script.javaScript.exception.notFunction]: ***** JavaScript exception (IST_masterScript 5.31): TypeError: s.filteredEntities is not a function
10:52:59.692 [LogEvents]: Player gui screen will change from GUI_SCREEN_SHORT_RANGE_CHART to GUI_SCREEN_SYSTEM_DATA

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] In System Trader OXP 1.40!

Post by gsagostinho » Thu Nov 02, 2017 8:12 pm

Is this OXP still being maintained? I keep getting some errors from it from time to time:

Code: Select all

00:06:46.560 [script.javaScript.exception.ooliteDefined]: ***** JavaScript exception (In_System_Trader 1.4): Error: Station.setMarketPrice: Invalid arguments ("Food", NaN) -- expected Unrecognised commodity type.
00:06:46.560 [script.javaScript.exception.ooliteDefined]:       C:\Oolite-Trunk/oolite.app/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.DrTripsa.InSystemTrader.oxz/Scripts/InSystemTrader_worldscript.js, line 83.

Duggan
---- E L I T E ----
---- E L I T E ----
Posts: 487
Joined: Sat Dec 31, 2011 2:58 pm

Re: [Release] In System Trader OXP 1.40!

Post by Duggan » Tue Nov 07, 2017 2:25 am

I am guessing that this OXP is not being maintained given the lack of response :)
Flying Python Class Cruiser, Chapter & Verse IV

User avatar
gsagostinho
---- E L I T E ----
---- E L I T E ----
Posts: 558
Joined: Sun Jul 19, 2015 1:09 pm

Re: [Release] In System Trader OXP 1.40!

Post by gsagostinho » Tue Nov 07, 2017 12:27 pm

Duggan wrote: I am guessing that this OXP is not being maintained given the lack of response :)
Yeah, that seems to be the case :(

Post Reply