[Release] Market Observer

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

Moderators: another_commander, winston

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: [Release] marketObserver 1.5

Post by Wildeblood »

GGShinobi wrote:Just tried to download, but I get an error claiming that the download has been removed... :?
Link used: https://www.box.com/s/u0hij6k0jzid4ujp2xi2
That same link (to marketObserver 1.5) is working fine now.

User avatar
GGShinobi
---- E L I T E ----
---- E L I T E ----
Posts: 291
Joined: Tue Dec 25, 2012 7:20 pm

Re: [Release] marketObserver 1.5

Post by GGShinobi »

Wildeblood wrote:
GGShinobi wrote:Just tried to download, but I get an error claiming that the download has been removed... :?
Link used: https://www.box.com/s/u0hij6k0jzid4ujp2xi2
That same link (to marketObserver 1.5) is working fine now.
Affirmative. Mysteries of the internet...
忍 knowing that enough is enough, you'll always have enough.

Running Oolite 1.77 on Ubuntu Linux 12.04 LTS

User avatar
Solonar
Deadly
Deadly
Posts: 174
Joined: Sun Dec 04, 2011 4:04 am
Location: Galaxy 2 - Space Truckin

Re: [Release] marketObserver 1.5

Post by Solonar »

I like the fix in this release. The market hud did stick for me one time, but changing screens corrected the issue rather than needing to restart the game.
Image

SolarTech proudly presents the Plasma Turret Regulator Device Apparatus, aka the Turret Toggler

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: [Release] marketObserver 1.5

Post by Wildeblood »

Solonar, if it happens again please check your Latest.log file for a time-out error, like the ones in my message from January 20th on the previous page. I suspect this is the cause of your problem:-

Code: Select all

this.$sweepMarketHud = function() {//restore hud & remove timer
	if (this.$marketTimer != null || player.ship.hud == this.$marketHud) { <------- A
		var i;
		var padding =" ";
		this.$removeTimer();
		for (i = 0; i <= this.$gathValues.length; i++) {  <------------
			player.consoleMessage(padding);     <-------------
			padding = padding + " ";            <-------------
		}
		if (this.$restoreHud != this.$marketHud)
			player.ship.hud = this.$restoreHud;
		else //if something has gone wrong and restorehud is the same as markethud. Then fall back to fallbackhud
			player.ship.hud = this.$fallBackHud;
		player.ship.removeEquipment(this.$randomAdd);
	}
}
I would try replacing that for loop with a single line:-

Code: Select all

player.consoleMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
P.S. See pointer 'A', opening it in Windows Wordpad I see a stray character after the ||.

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

Re: [Release] marketObserver 1.5

Post by spara »

Wildeblood wrote:Solonar, if it happens again please check your Latest.log file for a time-out error, like the ones in my message from January 20th on the previous page. I suspect this is the cause of your problem:-

Code: Select all

this.$sweepMarketHud = function() {//restore hud & remove timer
	if (this.$marketTimer != null || player.ship.hud == this.$marketHud) { <------- A
		var i;
		var padding =" ";
		this.$removeTimer();
		for (i = 0; i <= this.$gathValues.length; i++) {  <------------
			player.consoleMessage(padding);     <-------------
			padding = padding + " ";            <-------------
		}
		if (this.$restoreHud != this.$marketHud)
			player.ship.hud = this.$restoreHud;
		else //if something has gone wrong and restorehud is the same as markethud. Then fall back to fallbackhud
			player.ship.hud = this.$fallBackHud;
		player.ship.removeEquipment(this.$randomAdd);
	}
}
I would try replacing that for loop with a single line:-

Code: Select all

player.consoleMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
P.S. See pointer 'A', opening it in Windows Wordpad I see a stray character after the ||.
It might very well be this that's causing the problems and the reason I can't reproduce it as I had no problem earlier either. If this really solves it, I owe you a big one, Wildeblood, again. That stray char is weird, I'm using Geany on Linux and don't see a thing, neither with less or nano. Could be an encoding thingy?

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: [Release] marketObserver 1.5

Post by Wildeblood »

spara wrote:Could be an encoding thingy?
Are you an Unamerican with one of those pesky foreign keyboards? (There's another one after the || on line 19, too.)

I have a feature request for version 1.6 or later: I've never understood why you use a last in, first out list. I've never heard of anyone in real life calculating profit that way. Since they're fungible goods, the cost should be averaged, but I understand you don't want to do that.

If you view the trading process as a putting goods through your possession, the inventory should handled first in, first out, i.e. through-put. A more conservative approach, that avoids counting chooks before they hatch, is to always sell the highest cost goods first, and lower cost, more profitable inventory afterwards. That's what I'd like you to do.

Not in playerBoughtCargo, because the display would look broken, nor when leaving the market screen, because the player might return to the screen several times, but on shipLaunchedFromStation sort the arrays into descending order of cost. So that the next time you dock, the purchase prices displayed are the highest prices you've paid, rather than the most recent prices you've paid.

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

Re: [Release] marketObserver 1.5

Post by spara »

Wildeblood wrote:
spara wrote:Could be an encoding thingy?
Are you an Unamerican with one of those pesky foreign keyboards? (There's another one after the || on line 19, too.)
Quilty :D. Let's see if I can make them visible to me, so I can remove them. I have always hated encoding things. In the past I wrote some mobile stuff (SMS & WAP & WEB) with Java and I had to use Finnish as it was for Finnish end users. My head was spinning with UTF and ISO-88591 etc. Happy that's in the past.
Wildeblood wrote: I have a feature request for version 1.6 or later: I've never understood why you use a last in, first out list. I've never heard of anyone in real life calculating profit that way. Since they're fungible goods, the cost should be averaged, but I understand you don't want to do that.
I'm no economist, but to my understanding in the real world two methods are used for profit counting: average and FIFO. If someone knows better, correct me.

So you're right, not done like that in the real world. Actually in the first version I had the whole log open like this 2x6.7 4x7.2 4x5.2 etc and the list was purged with FIFO principle. It was nice with my widescreen monitor, but when I shrinked it down, only the last one (left most) was visible :(. Purging from the one that was visible made sense then and I haven't thought it since.
Wildeblood wrote: ...So that the next time you dock, the purchase prices displayed are the highest prices you've paid, rather than the most recent prices you've paid.
This is a sensible idea and worth implementing.

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

Re: [Release] marketObserver 1.6

Post by spara »

New version (1.6).

* Some reordering of execution and Wildebloods suggestion for fixing Solonar's "sticky hud" problem. Let's hope this helps.
* Implemented Wildebloods suggestion of ordering the purchace log. Now you sell the most expensive ones first. Makes more sense now.

User avatar
Solonar
Deadly
Deadly
Posts: 174
Joined: Sun Dec 04, 2011 4:04 am
Location: Galaxy 2 - Space Truckin

Re: [Release] marketObserver 1.6

Post by Solonar »

Using trunk 5635 and Market Observer 1.6, the first time view took a few seconds to load but there were no display problems so far. The following appeared in the logs after the first time use and the long load time...
12:59:06.945 [script.javaScript.timeLimit]: ***** ERROR: Script "market_observer" ran for 4.58903 seconds and has been terminated.
12:59:06.945 [script.javaScript.stackTrace]: 0 (../AddOns/Market Observer 1.6.oxp/Config/script.js:288) <anonymous function>
12:59:06.946 [script.javaScript.stackTrace]: this: [Script "market_observer" version 1.6]
12:59:06.946 [script.javaScript.stackTrace]: 1 (../AddOns/Market Observer 1.6.oxp/Config/script.js:179) <anonymous function>
12:59:06.946 [script.javaScript.stackTrace]: this: [Script "market_observer" version 1.6]
12:59:06.946 [script.javaScript.stackTrace]: from: "GUI_SCREEN_SHORT_RANGE_CHART"
12:59:06.946 [script.javaScript.stackTrace]: to: "GUI_SCREEN_MARKET"
Image

SolarTech proudly presents the Plasma Turret Regulator Device Apparatus, aka the Turret Toggler

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

Re: [Release] marketObserver 1.6

Post by spara »

Solonar wrote:Using trunk 5635 and Market Observer 1.6, the first time view took a few seconds to load but there were no display problems so far. The following appeared in the logs after the first time use and the long load time...
12:59:06.945 [script.javaScript.timeLimit]: ***** ERROR: Script "market_observer" ran for 4.58903 seconds and has been terminated.
12:59:06.945 [script.javaScript.stackTrace]: 0 (../AddOns/Market Observer 1.6.oxp/Config/script.js:288) <anonymous function>
12:59:06.946 [script.javaScript.stackTrace]: this: [Script "market_observer" version 1.6]
12:59:06.946 [script.javaScript.stackTrace]: 1 (../AddOns/Market Observer 1.6.oxp/Config/script.js:179) <anonymous function>
12:59:06.946 [script.javaScript.stackTrace]: this: [Script "market_observer" version 1.6]
12:59:06.946 [script.javaScript.stackTrace]: from: "GUI_SCREEN_SHORT_RANGE_CHART"
12:59:06.946 [script.javaScript.stackTrace]: to: "GUI_SCREEN_MARKET"
Looks like it's just too heavy. I'll try to lightweight it a bit.

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

Re: [Release] marketObserver 1.6.1

Post by spara »

New version 1.6.1. Optimized and lightweighted code as much as possible (within my limited skills :mrgreen:). Hopefully that's enough to make it work for Solonar and possibly others who are having trouble with it.

User avatar
Solonar
Deadly
Deadly
Posts: 174
Joined: Sun Dec 04, 2011 4:04 am
Location: Galaxy 2 - Space Truckin

Re: [Release] marketObserver 1.6.1

Post by Solonar »

Using trunk 5635 and Market Observer 1.6.1, the first time use and view of the commodities page displayed the market hud improper. The spaces reserved for the prices and the advertisements were present but were empty. Changing to other pages and them viewing the commodity page corrected the display of the market hud.

The following appeared in the logs at this time...

15:28:45.499 [script.javaScript.timeLimit]: ***** ERROR: Script "market_observer" ran for 3.86869 seconds and has been terminated.
15:28:45.499 [script.javaScript.stackTrace]: 0 (../AddOns/Market Observer 1.6.1.oxp/Config/script.js:182) <anonymous function>
15:28:45.499 [script.javaScript.stackTrace]: this: [Script "market_observer" version 1.6.1]
15:28:45.500 [script.javaScript.stackTrace]: from: "GUI_SCREEN_SHORT_RANGE_CHART"
15:28:45.500 [script.javaScript.stackTrace]: to: "GUI_SCREEN_MARKET
Image

SolarTech proudly presents the Plasma Turret Regulator Device Apparatus, aka the Turret Toggler

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: [Release] marketObserver 1.6.1

Post by Wildeblood »

Solonar wrote:The spaces reserved for the prices and the advertisements were present but were empty. Changing to other pages and them viewing the commodity page corrected the display of the market hud.
The missing advertisements are easily explained. When Spara added this.$setAds(); to the code just before uploading, he put it in the wrong place. Obviously he doesn't have ads on his personal version. :mrgreen: Now the truth comes out, bwahaha! :D

Code: Select all

this.guiScreenChanged = function(to, from) {
	if (to == "GUI_SCREEN_MARKET" && player.ship.docked && guiScreen != "GUI_SCREEN_MISSION") { //swap to market hud
		this.$checkMinMax = true;
		this.$restoreHud = player.ship.hud;
		player.ship.hud = this.$marketHud;
		this.$startTimer();
	}
	if (from == "GUI_SCREEN_MARKET") { //restore hud
		this.$setAds(); // <--------------------------------------!
		this.$sweepMarketHud();
	}
}
And what's this paranoia about mission screens?

Code: Select all

if (to == "GUI_SCREEN_MARKET" && player.ship.docked && guiScreen != "GUI_SCREEN_MISSION")

Code: Select all

if (guiScreen === "GUI_SCREEN_MARKET" && player.ship.docked)

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

Re: [Release] marketObserver 1.6.1

Post by spara »

Wildeblood wrote:
Solonar wrote:The spaces reserved for the prices and the advertisements were present but were empty. Changing to other pages and them viewing the commodity page corrected the display of the market hud.
The missing advertisements are easily explained. When Spara added this.$setAds(); to the code just before uploading, he put it in the wrong place. Obviously he doesn't have ads on his personal version. :mrgreen: Now the truth comes out, bwahaha! :D
Got me...almost :lol:. I set ads in startUp and after that every time exiting market screen. When hunting this one down I have taken every action possible (?) away from transition to market screen.
Wildeblood wrote: And what's this paranoia about mission screens?

Code: Select all

if (to == "GUI_SCREEN_MARKET" && player.ship.docked && guiScreen != "GUI_SCREEN_MISSION")

Code: Select all

if (guiScreen === "GUI_SCREEN_MARKET" && player.ship.docked)
That I put for Commodity Markets that puts up a mission screen when switching to market screen. Didn't want to switch hud on top that. Your line works as well of course. I'll change it, that's one expression less to evaluate.

I made a couple of alterations further and sent a test version to Solonar, let's see what happens. I'm quite lost here as this oxp works for with no problem.

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2161
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: [Release] marketObserver 1.6.1

Post by Wildeblood »

Here's one I got when I tried 1.6.1 this morning:-
11:40:43.013 [script.javaScript.exception.undeclaredVar]: ***** JavaScript exception (market_observer 1.6.1): ReferenceError: assignment to undeclared variable j
11:40:43.013 [script.javaScript.exception.undeclaredVar]: ../AddOns/marketObserver_1.6.1.oxp/Config/script.js, line 221.
IIRC, this is the first line of printValues where the var declaration is missing the 'j". But this is a new bug, when I added the j the display started working, but with the delays Solonar reports.

I wonder... (ignore what follows, it's just me thinking out loud)... is it because gatherMarketValues (?) is writing the array and printValues is reading the array at the same time...?

Post Reply