Page 22 of 63

Posted: Sun Oct 04, 2009 10:52 pm
by pmw57
Screet wrote:
Concerning the new JS I still miss my playerstation working or being shown at all.

I thought it was only "mission_playerstation_" vs. "playerstation_" in the naming, but even after adding "mission_" it did not show up?!?
Ahh, player stations. That has been interesting.

I have only just discovered that the following .plist method equates to this javsacript method

(plist) setMissionDescription -> (js) mission.setInstructionsKey()

So now, we can see the player stations on the mission screen.

Problem 1: How do we remove an entry from the mission screen?

The plist clearMissionDescription doesn't seem to have an equivalent javscript method.

Problem 2: The original plist code seems to indicate that multiple stations can be owned. How would we have the mission screen show the multiple stations?

The code has been updated so that the player stations now show. Now, the code for showing the player stations only runs when the ships manifest is shown.

Re: ..

Posted: Sun Oct 04, 2009 11:28 pm
by pmw57
Lestradae wrote:
4) Out of the "station bought" screen, on your "missions" screen now a line should appear saying "You own an X station in system Y in galactic sector Z. Income per WJ: AAAAA Cr"

That doesn't work. It does in the XML version. The script new simply doesn't do this. As I don't understand java script well enough to repair it, no idea why not.
The script has been updated so that the missions screen now shows what it should.

It works well when you have one station, but I foresee problems with multiple stations. With multiple stations it loops through them AAA, AAB, AAC... ABA, ABB, ABC... BAA, BAB, ...
and only the mission description for the last one that was found will appear.

Currently, if the script sets two or more mission descriptions, each previous one is overwritten by the newer one. I would like to find out how it may be possible to set multiple mission descriptions.
Lestradae wrote:
6) If you do a witchjump, the amount of credits it said in the equipment screen and says on your missions screen should be transferred to your account at arrival. (If you own multiple stations, the sum total of all their incomes should arrive) You will not get additional screen messages or somesuch. Your credits will simply rise the amount.
With the extra info about player stations, I have been able to test some of the functionality, such as the mission screens, credits and bounty. On todays even newer updated script I see that my credit rises. Would you kindly take a look at todays updated script.

Re: ..

Posted: Sun Oct 04, 2009 11:35 pm
by pmw57
Eric Walch wrote:
I only know that the current Hoopy version had already a much improved xml script compared with the original.
*slaps forehead*

I'll update the OSE hOopy Casino from the updated original tonight.
Eric Walch wrote:
One other thing that happens when translating to JS is that the timing is completely different. The legacy scripting makes sure that scripts are not run on an arrival_report. With JS one need to check in the script for this condition.
Thanks, I'll see what I can do about this tonight as well.
Eric Walch wrote:
This has nothing to do with the translation of pmw57 himself as by the look of it he is clearly more experienced in JS than I am. pmw57 just is unaware of some specific Oolite rules.
May I suggest that this information that would be helpful to know, is added on to the wiki as recommended usage, and code examples.

I see that there is a basic reference on there already, but information about making good use of them appears to be sorely lacking.

Posted: Sun Oct 04, 2009 11:40 pm
by pmw57
Screet wrote:
I think it should be player.ship.fuel, but have not tested that yet, except that I can report that this is no longer reported as a bug ;)
You're right, todays update now has player.ship.fuel
Screet wrote:
About the playerstations:
1) The code does check for the playerstation key to be INTEGER 1, while it is as STRING 1 in the save file. The if clauses to find the stations need to check for "1" instead of 1
Actually, they don't. The doubleequals comparison is a type-converting comparison operator, using complicated rules to loosly check equality.
https://developer.mozilla.org/en/Core_J ... _Operators

I will tighten the loose comparisons to be strict comparisons with the triple
equals, in a few days time.
Screet wrote:
2) The code that does create the string for the f5 mission screen does not activate after loading, only after docking, and then it shows a mission screen for the stations (including "press space") instead of adding the ship to the f5 mission screen.
Thanks, that's all fixed now.

X

Posted: Sun Oct 04, 2009 11:56 pm
by Lestradae
Hi pmw57, glad that you are on the chase again! :D

Two questions:

1) Where do I download the newest ose.js script version you made?
2) Does the newest version already contain fixes for the diverse player station issues?

Concerning 2): Yes, it is intended that players can own multiple stations, so everything has to stack on top of each other (legal rating changes, income, and also multiple entires on the F5-F5 screen) and if a station is sold, its entry on the F5-F5 screen has to be removed also.

Please let me know which of the above is already done and which is missing.
The plist clearMissionDescription doesn't seem to have an equivalent javascript method.
If this is the case, the devs have asked some time ago to alert them to java script commands still missing for translations from legacy scripts. Perhaps we should inform them about this.

Cheers

L

Posted: Mon Oct 05, 2009 12:43 am
by Kaks
L, I suspect the updated script is in the same place you found the previous one:

http://www.box.net/shared/dodzb27djm


And I believe that

Code: Select all

mission.setInstructionsKey("");
from within the script would do the same as

Code: Select all

clearMissionDescription
in legacy script.

Re: X

Posted: Mon Oct 05, 2009 1:07 am
by pmw57
Lestradae wrote:
Hi pmw57, glad that you are on the chase again! :D

Two questions:

1) Where do I download the newest ose.js script version you made?
The same link as before contains the updated code. Currently, there is only one link for the 0.70 version of the script. Thus it shall remain until we are happy with this series of testing.

The link for the latest 0.70 version of the updated scripts is http://www.box.net/shared/dodzb27djm
Lestradae wrote:
2) Does the newest version already contain fixes for the diverse player station issues?

Concerning 2): Yes, it is intended that players can own multiple stations, so everything has to stack on top of each other (legal rating changes, income, and also multiple entires on the F5-F5 screen) and if a station is sold, its entry on the F5-F5 screen has to be removed also.

Please let me know which of the above is already done and which is missing.
The legal ratings, income and removing of sold stations are all working.
The mission list screen has a developer-based difference of behaviour.

With the plist, you could setMissionDescription(name) and clearMissionDescription(name) with no trouble.

With the javsacript, I am led to believe that there is only one mission description allowed per script - setInstructionList(name) where you clear it with setInstructionList(null)

I suspect that listing your owned stations in the mission list isn't appropriate anyway. It would be interesting to hear from the game developers what they think is the best way of handling this in javascript. If there is no best way, it may have to stay as a plist until the game scripting can achieve what is required.
Lestradae wrote:
The plist clearMissionDescription doesn't seem to have an equivalent javascript method.
If this is the case, the devs have asked some time ago to alert them to java script commands still missing for translations from legacy scripts. Perhaps we should inform them about this.
It exists, but only as a set/clear mission on a per-script basis. One mission description per script and no more.

Posted: Mon Oct 05, 2009 1:11 am
by pmw57
Kaks wrote:
And I believe that

Code: Select all

mission.setInstructionsKey("");
from within the script would do the same as

Code: Select all

clearMissionDescription
in legacy script.
Am I right to believe that that is as one mission description per script?

Is the intention to place up to 160 station descriptions in the mission description area ever going to work, and if not, what viable solutions are there. Will it be best to stay with plist for that, or to redesign the intention of player stations?

Posted: Mon Oct 05, 2009 2:15 am
by pmw57
Given the limitation of one mission description per script, a work-around can be hacked by having one script file per intended mission description.

This update includes playerStationShow1.js, playerStationShow2.js, playerStationShow3.js, playerStationShow4.js, playerStationShow5.js

They all loop through the available player stations, but each one only stops and sets the mission description when they have found a certain number of stations.

Code: Select all

var ownedPlayerStation = '',
    stationsFound = 0,
    showStationAt = 3,
...
		if (missionVariables['playerstation_' + playerStation] == 1) {
			stationsFound += 1;
			if (showStationAt === stationsFound) {
				ownedPlayerStation = 'Station_' + playerStation + '_owned';
...
mission.setInstructionsKey(ownedPlayerStation);
This way, the playerStationShow scripts all together show the first five player stations that are found. Given that there seems to be a limitation of 4 mission descriptions on the mission page, this solution should do for now.

The updated script files are at http://www.box.net/shared/dodzb27djm
But I do want to hear from the Oolite scripting gods about if there is a better way to achieve this. I don't mind if better means "go back to plist for less resource usage" or even "kill the project, until xyz is done"

Posted: Mon Oct 05, 2009 5:16 am
by pmw57
As a separate issue, the log file says that lestradae3-navycondor is in the ship yard, but there is no ship data entry about it.
[shipData.load.shipyard.unknown]: ----- WARNING: the shipyard.plist entry "lestradae3-navycondor" does not have a corresponding shipdata.plist entry, ignoring.
A similar navy condor already in the ship data is:
<key>NavyCondor-player</key>
<dict>
<key>like_ship</key>
<string>NavyCondor-template</string>
<key>max_energy</key>
<real>1050</real>
<key>roles</key>
<string>player</string>
<key>name</key>
<string>Condor Destroyer</string>
</dict>
Is the the lestradae3-navycondor similar, and if so what name would it have?

Posted: Mon Oct 05, 2009 7:44 am
by Screet
Hi,

a very strange thing:

Code: Select all

[script.missionDescription.noMissionText]: ***** SCRIPT ERROR: in "Oolite Shipyard Extension - Show First Owned Player Station", no missiontext set for key '' [UNIVERSE missiontext] is:
It does not show the stations on f5 screen, but instead writes the complete mission text of all mission oxp's I have installed into the log. Some 20000 lines after a few times trying to look at f5.

I fail to understand this. Is this a bug in my trunk version? I'm sure that there should not be everything from all oxp's written to the log?!?

Screet

Re: X

Posted: Mon Oct 05, 2009 7:51 am
by Eric Walch
pmw57 wrote:
With the plist, you could setMissionDescription(name) and clearMissionDescription(name) with no trouble.

With the javsacript, I am led to believe that there is only one mission description allowed per script - setInstructionList(name) where you clear it with setInstructionList(null)
Even with plist you could not use clearMissionDescription(name). It has always been clearMissionDescription.

Already from the beginning of introduction of the mission descriptions they are stored together with the mission variables with the script name as key. Because the scriptname is the key, only one description can be stored per script. When you want more, you must define more scripts. Therefor it is also important to not change scriptnames when translating: you will lose previous descriptions.

It also does not make sense to allow so many mission descriptions as that mission page is mend pure for ongoing missions and a player is not likely doing dozens of missions at a time. I assume that when you define to many ongoing missions, the text will run of the screen.

By the way: There is no need to update the mission descriptions on every jump. Legacy was a very inefficient language. Even occasions that occured once had to be evaluated every 10 seconds because the script could only be evaluated in total. The owned stations are triggered by buying stuff. So in this case it would be more efficient to set that only once on buying it:

Code: Select all

this.playerBoughtEquipment = function()
{
   // set/reset the description here.
}
See: event handlers

..

Posted: Mon Oct 05, 2009 7:54 am
by Lestradae
Hi pmw57,

Went through the new script version and due to the similarities, I noticed that I actually start to understand a little bit of this stuff! :shock:

It always puzzles me when order emerges from chaos like this in my head ... OK, philosophy aside :)

Looks to me as if everything is now working except the listing of player stations on the mission screen. (I did not understand what the five "playerStationShow" scripts are actually supposed to do, I have to admit :oops: )

In my test games, I help myself by using the crippled rest of the old OSE-XML.plist for the parts that are not yet successfully taken over by the new java script, will do so for the F5-F5 entries now and test. I will also look into the original oxp scripts Eric wrote me which have been updated already and see if it makes sense to exchange/replace all of them with the "new originals".

Concerning the multiple stations, this is a plot point, so to speak. Buying and selling stations is meant to be a strategic decision for very advanced players. I don't suppose many players will own more than a max of three to five stations at a time.

Then, I hope that the missions screen will be reworked the same way the equipment screen was reworked to stop it from overflowing (* looks towards Kaks + Eric & ducks below any potentially thrown objects * :P ), but if players don't own more than the abovementioned 3-5 it should work fine. You also have the double-check about what you can sell via the equipment screen.

So I hope that this last showstopper can be removed and OSE becomes a completely java-script driven, mission oxp - and escape pod insurance - compatible test meta-oxp ... for now.

Cheers everyone and thanks plus keep up the good work! :D

L

PS: Ah, and the "lestradae3-navycondor" entry is a relic from RS already removed on my post-V0.69 OSE, thanks for reporting it anyways 8)

Posted: Mon Oct 05, 2009 9:05 am
by pmw57
Screet wrote:
It does not show the stations on f5 screen, but instead writes the complete mission text of all mission oxp's I have installed into the log. Some 20000 lines after a few times trying to look at f5.

I fail to understand this. Is this a bug in my trunk version? I'm sure that there should not be everything from all oxp's written to the log?!?
Wow, that could be a problem with passing an empty string.

You're supposed to pass null to clear the mission for that script, but I didn't realise that passing an empty string would cause such a problem.

The script has been updated so that null is passed instead, and the trunk code really should be updated to properly handle this bug.

The player station scripts have also been updated so that they run either on first load, or when a player docks with the station.

The update OSE scripts are at http://www.box.net/shared/dodzb27djm

Re: X

Posted: Mon Oct 05, 2009 9:07 am
by pmw57
Eric Walch wrote:
By the way: There is no need to update the mission descriptions on every jump. Legacy was a very inefficient language. Even occasions that occured once had to be evaluated every 10 seconds because the script could only be evaluated in total. The owned stations are triggered by buying stuff. So in this case it would be more efficient to set that only once on buying it:

Code: Select all

this.playerBoughtEquipment = function()
{
   // set/reset the description here.
}
I like your way of thinking. Will perform that update on the other playerstation files at the first opportunity.