The Oolite Extended Project - Fork, no oxp

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

Moderators: winston, another_commander

Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

I really don't know how I managed to miss those comments...
Well, I know, actually.. I've searched the resulting plist for backslashes, and notepad++ didn't find any (and there are several comments).
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

Quick question:

I know that key label or string value must be quoted in ASCII if it contains spaces.

What about "-"s and "_"s?
I've seen alot of different cases and I'm pretty uncertain if it is OK to leave those unquoted. I mean, obviously windows will accept unquoted "_"s (not sure about "-"s), but I don't want to make the translation results windows-only...
Last edited by Chaky on Sun Oct 04, 2009 3:27 pm, edited 1 time in total.
pmw57
---- E L I T E ----
---- E L I T E ----
Posts: 389
Joined: Sat Sep 26, 2009 2:14 pm
Location: Christchurch, New Zealand

Post by pmw57 »

Okay I'm back now, and the old OSE-XML.plist is now updated to ose.js and hoopy-casino.js

Some notes:

I have checked the script against the .plist - I've even checked it twice.

The plist check for tech levels and related checks have been updated. In the plist and .js the tech level is measured from 0 to 15. This is shown on the screen as 1 to 16. So, the plist check if tech level is greater than 7 was checking it was our understanding of 9 or greater.

So, instead of checking techLevel > 7 I've been using techLevel >= 8, so that we can take the computer-measure of 0-15 and know that in our 1-16 ranking that we're after 9 or greater.

Similarly, random number checks are improved. Previously checks were if a random number between 1 and 100 was greater than 65. This would give you a 35% chance of that occurring. JavaScript random numbers are from 0 to 0.99999... Now the check is if random() < 0.35 for a 35% chance, which makes much more sense.

Some sanity checks have also been added too.

The updated ose scripts are ose.js and hoopy-casino.js from http://www.box.net/shared/dodzb27djm

A big thanks to Kaks and Eric for their advice. I now leave the fine-tuning up to Lestradae.

This wee (hah!) project has been great to get a feel for the oolite api. I look forward to working further with it.
A trumble a day keeps the doctor away, and the tax man;
even the Grim Reaper keeps his distance.
-- Paul Wilkins
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

Many thanks to you, pmw57, and also Kaks & Eric for helping in this endeavor, much appreciated! :D

I will test the new java script replacements and report back as soon as I have something substantial to say!

Btw, as pmw57 has just also translated about fifteen ship oxps' (and also the hoopy casino oxps') from XML to .js, perhaps it could be a good idea to update these oxps with the new .js version, too? Then players of the original oxps could also enjoy the resulting speed gain!

Cheers :D

L
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

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?!?

Screet
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

OK, so here are my test results from pmw57's new java script translations.

The placement of entities generally seems to work as intended, as OoBay stations and hardpirates are placed as they should, and all other spawn scripts united here work according to the same scheme.

The hoopy casino script also works. I have been to one with the new java script version and it also does everything that it's supposed to do.

The player stations still don't work as intended, same trouble as with the old script. :(

I'll repeat here what the script is supposed to do, and what the new OSE.js does instead:
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.

...

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.

The new script doesn't do that. Also, your legal status should get raised or lowered for some stations. The script also doesn't do that.
So while the new script works for everything but the player stations, it actually doesn't work at all for the player stations.

What it should do should be the following:

Code: Select all

<key>Stations_owned_show_HAH</key>
        <array>
        <dict>

        <key>conditions</key>
        <array>
              <string>mission_playerstation_HAH equal 1</string>
        </array>

        <key>do</key>
        <array>
              <string>setMissionDescription: Station_HAH_owned</string>
        </array>

        </dict>
        <dict>

        <key>conditions</key>
        <array>
              <string>mission_playerstation_HAH undefined</string>
        </array>

        <key>do</key>
        <array>
              <string>clearMissionDescription</string>
        </array>

        </dict>
        </array>
... (write the mission description into the mission screen) and this ...

Code: Select all

<key>Stations_owned_income_HAH</key>

        <array>
        <dict>

        <key>conditions</key>
        <array>
              <string>status_string equal STATUS_EXITING_WITCHSPACE</string>
              <string>mission_playerstation_HAH equal 1</string>
        </array>

        <key>do</key>
                  <array>
                     <string>awardCredits: 75000</string>
                  </array>

        </dict>
        </array>
... (add, for each station owned, after each withjump the income per WJ, 75000 Cr in the example above) and this:

Code: Select all

<key>Stations_owned_legal_HAH</key>

        <array>
        <dict>

        <key>conditions</key>
        <array>
              <string>status_string equal STATUS_EXITING_WITCHSPACE</string>
              <string>mission_playerstation_HAH equal 1</string>
              <string>legalStatus_number lessthan 70</string>
        </array>

        <key>do</key>
                  <array>
                     <string>setLegalStatus: 600</string>
                  </array>

        </dict>
        </array>
... though, the above is still cr*p as I don't want it to set a legal rating, I want it to raise or lower it similar to what the income part does with the player's credits:
A & B: Do nothing

C: Raise player bounty 5 points per jump if (see McLane's post) * the jump actually arrives in another system and not interstellar space

D: Raise player bounty 20 points per jump * (-> see above)

E: Lower player bounty 3 points per jump *

F: Raise player bounty 40 points per jump *

G: Lower player bounty 6 points per jump *

H: Raise player bounty 70 points per jump *

I: Do nothing

J: Lower player bounty 12 points per jump *

K & L: Lower player bounty 6 points per jump *
Oh, and the station codes:

First letter A to L: Type of station
Second letter A or B: There are two stations of every type each in every galactic sector, difference
Third letter A to H: Galactic Sector 1-8

pmw57's java script take at this looks like follows:

Code: Select all

this.processOwnedStations = function () {
        var leftChars = 'ABCDEFGHIJKL',
                midChars = 'AB',
                rightChars = 'ABCDEFGH',
                stationIncome = {
                        'A': 4000, 'B': 8000, 'C': 12000, 'D': 21000, 'E': 20000, 'F': 36000,
                        'G': 40000, 'H': 75000, 'I': 100000, 'J': 130000, 'K': 250000, 'L': 500000
                },
                stationBounty = {
                        'A': 0, 'B': 0, 'C': 5, 'D': 20, 'E': -3, 'F': 40,
                        'G': -6, 'H': 70, 'I': 0, 'J': -12, 'K': -6, 'L': -6
                },
                i, j, k,
                playerStation,
                income,
                bounty,
                totalBounty = 0;
        for (i = 0; i < leftChars.length; i++) {
                for (j = 0; j < midChars.length; j++) {
                        for (k = 0; k < rightChars.length; k++) {
                                playerStation = leftChars.charAt(i) + midChars.charAt(j) + rightChars.charAt(k);
                                income = stationIncome[leftChars[i]];
                                bounty = stationBounty[leftChars[i]];
                                if (missionVariables['playerstation_' + playerStation] == 1) {
                                        player.credits += income;
                                        totalBounty += bounty;
                                }
                        }
                }
        }
        if (player.bounty + totalBounty < 0) {
                player.bounty = 0;
        } else {
                player.bounty += bounty;
        }
};
this.showOwnedStation = function (station) {
        var leftChars = 'ABCDEFGHIJKL',
                midChars = 'AB',
                rightChars = 'ABCDEFGH',
                i, j, k,
                playerStation;
        for (i = 0; i < leftChars.length; i++) {
                for (j = 0; j < midChars.length; j++) {
                        for (k = 0; k < rightChars.length; k++) {
                                playerStation = leftChars.charAt(i) + midChars.charAt(j) + rightChars.charAt(k);
                                if (missionVariables['playerstation_' + playerStation] == 1) {
                                        mission.runMissionScreen('Station_' + playerStation + '_owned');
                                }
                        }
                }
        }
};
I really hope I get capable help to solve this, I want to have the whole thing in java script - and the legal rating has to rise or fall instead of being set, otherwise a) I'm not happy with it and b) it's going to be incompatible with anarchies, which I also don't want.

Help? :(

L
Last edited by Lestradae on Sun Oct 04, 2009 6:35 pm, edited 3 times in total.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

From what I see of the code, it does seem to do exactly what it needs to do for bounty & credits. Maybe a last minute change to the code caused some problems there, something that any programmer I know has had problems with at one point or another.

In any case, wouldn't it be better to ask pwm57 directly?

From the code he's produced already I'd say he is the 'capable help to solve this' you're saying you're looking for...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

Kaks wrote:
From the code he's produced already I'd say he is the 'capable help to solve this' you're saying you're looking for...
pmw57 told me that he was capable in java script generally, but not the Oolite-specific methods and that I should take it myself from here ...

While he's been a great help so far (all other parts of his script work) I simply can't take it from here, as I have no idea how either his script works nor why it doesn't do what it should concerning the abovementioned parts at all :(

So, pmw57, if you read this, please have mercy on a java script noob :P and/or if someone else can spot what goes wrong in there, definitely feel free to help out.

:?

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

Post by Eric Walch »

Lestradae wrote:
Btw, as pmw57 has just also translated about fifteen ship oxps' (and also the hoopy casino oxps') from XML to .js, perhaps it could be a good idea to update these oxps with the new .js version, too? Then players of the original oxps could also enjoy the resulting speed gain!
I only know that the current Hoopy version had already a much improved xml script compared with the original. Some months ago there were reported bugs in hoopy here and I uploaded a new version. Just a pity that the translation is now based on the one with the bug and still contains the bug. The main problem is that when a player launches from within a gamescreen, he is denied access in future. The current version is not only free from this bug but also fixes saved games that contain a wrong entry.

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. You now loose all messages on captured escape capsules. Not the most important stuff and good enough for ose probably. But the original should be as flawless as possible when changing. And certainly not be worse than original.

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.

e.g. when defining a mission description it is saved with the name of the script. When putting all in one script, there can only be one mission description.

And 6 oxp's of the OSE-XML.plist use already a JS script in their current version.

One other problem with the old and new script is that is in totally incompatible with mission oxp's. It refuges to check for existing mission screens but just overwrites them. I already wrote pmw57 that this is not a problem itself but the readme should clearly warn to not use ose.oxp in combination with mission oxp's.
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Post by Screet »

I think there's a minor bug:

Code: Select all

[script.javaScript.warning.undefinedProp]: ----- JavaScript warning ("Oolite Shipyard Extension" 0.70): reference to undefined property player.fuel
[script.javaScript.warning.undefinedProp]:       ../AddOns/A - Oolite Shipyards Extension WiP V0.69.oxp/Scripts/ose.js, line 98.
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 ;)

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

Screet
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

Hi Eric,

Very relevant informations, all!
I only know that the current Hoopy version had already a much improved xml script compared with the original. Some months ago there were reported bugs in hoopy here and I uploaded a new version. Just a pity that the translation is now based on the one with the bug and still contains the bug. The main problem is that when a player launches from within a gamescreen, he is denied access in future. The current version is not only free from this bug but also fixes saved games that contain a wrong entry.
I assume that if your newer hoopy version is much improved, I guess I'll better use the newer script instead for OSE. Wouldn't it make sense - thinking of the speed difference issue - to translate that one to java script, too, btw? Just saying.
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. You now loose all messages on captured escape capsules. Not the most important stuff and good enough for ose probably. But the original should be as flawless as possible when changing. And certainly not be worse than original.
Hm, no it's not good enough for OSE in that case. I am actually at a stage where I am no longer going to add anything big and new, but fix any bug and unintended strangeness that I become or am made aware of.

Can you point me to which parts of the translated scripts could produce such lost messages?
pmw57 just is unaware of some specific Oolite rules.
If even a java script adept like pmw57 has troubles with those, I would humbly suggest that perhaps the documentation of these rules is lacking a bit. No offense meant.
e.g. when defining a mission description it is saved with the name of the script. When putting all in one script, there can only be one mission description. ... One other problem with the old and new script is that is in totally incompatible with mission oxp's. It refuges to check for existing mission screens but just overwrites them. I already wrote pmw57 that this is not a problem itself but the readme should clearly warn to not use ose.oxp in combination with mission oxp's.
I assume you are referring to the java scripts versions of the player stations, yes? Because otherwise I would ask you to again point me to where in the OSE scripts this could happen.

The original XML scripts concerning this only write to the F5-F5 missions screen, they do not overwrite anything at docking because there are no messages at docking.
And 6 oxp's of the OSE-XML.plist use already a JS script in their current version.
Again, I would ask you to point me to the oxps for which this is the case. Because then I can & will update them to current standards.

My aim is to get OSE as bug-free and compatible with everything else, if core-game or oxps, as possible. There is no "good enough" for me on this. If something can do better or creates problems, I change it if I can. Loosing escape pod insurances or even having OSE incompatible with mission oxps is out of the question for me.

If you answered my above enquiries this would be most helpful.

Good n8

L

PS: @Screet:
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
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.
Screet, do you think you could provide a fix for the abovementioned two errors? 8)
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Re: ..

Post by Screet »

Lestradae wrote:
@Screet:
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
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.
Screet, do you think you could provide a fix for the abovementioned two errors? 8)
What I write in Point 1 is the solution. Simply put "" around the 1 in the two parts that check for playerstation_ ...

Point two is different - I simply do not know how to add anything to that screen, nor do I know what sort of event handler the script would have to use. All I know is that it currently creates a mission screen once the player docks (which I think is the one Eric complained about, but that screen should not be there!).

Screet
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

I assume that if your newer hoopy version is much improved,
No, I think it is just one check on launching that was changed. All the other improvements are covered by translating to JS. Only for triggering the missionscreen I would not use the handler that triggers on every screen change but only the ones designed for the job. This is all documented.
Can you point me to which parts of the translated scripts could produce such lost messages?
What about this page: mission_offering or any of the oxp's that show mission pages. Most of them do it right and with 1.73 it is even easier to handle not overwriting the arrival page as that now gives a trigger of its own when it is finishing displaying.
Again, I would ask you to point me to the oxps for which this is the case. Because then I can & will update them to current standards.
Behemoth, cobra clipper, pirate coves, ixian ships, dredgers, super cobra have all JS worldScripts for ship addition. (Actually supercobra has no addition script anymore as that ship could just as well be added by the populator in combination with a shipscript).
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

..

Post by Lestradae »

@Screet:

Your explanation is enough so that I might even attempt to repair the player stations part of the java script. If I don't manage, I'd have to let this part stay as it is - in XML :(

@Eric:

I think I will update OSE on all seven original oxps you listed. I did observe what was going on but somehow missed all these new developments. Well, now I know.

The mission screen abuse thing happens because the OSE.js uses the wrong .js commands for what I intend to do. The potentially mission-breaking and insurance-stealing screen shouldn't be there at all - in the XML version, the text is written to the F5-F5 missions page, not presented as a mission text at docking.

:idea:

L
Screet
---- E L I T E ----
---- E L I T E ----
Posts: 1883
Joined: Wed Dec 10, 2008 3:02 am
Location: Bremen, Germany

Re: ..

Post by Screet »

Lestradae wrote:
@Screet:
Your explanation is enough so that I might even attempt to repair the player stations part of the java script. If I don't manage, I'd have to let this part stay as it is - in XML :(
Basically it's working ;) One thing is just not where it belongs (creating a mission screen instead of adding a string to f5) but the part to give credits seems to work without any problem after changing 1 to "1".

Screet
Post Reply