Page 20 of 63

Re: .

Posted: Fri Oct 02, 2009 4:37 pm
by Chaky
Lestradae wrote:
@Chaky:

You did translate it to OpenStep, not java script! So I will use the java script version, of pmw57! :(
No I didn't. I just wrote the code that did. (is that what it's called?)

And I never said anything about JS. I said ASCII...

come to think of it, it's kind of a miracle that code works at all, since I don't understand neither XML, ASCII nor JS.

Well... JS "looks familiar", but far from creating something with it.

Posted: Fri Oct 02, 2009 6:31 pm
by Eric Walch
Chaky wrote:
Tell you what.. I'll upload my translation of OSE-XML.plist for comparison.


The translation seems OK, but I don't guarantee it. All it takes is one rouge <key> to make the translation gibberish.
It is not OK.
- All the elements of an array must be terminated by a ","
- Only the last element in an array does not need the "," For some operating systems a "," is not even allowed for the last element.
- You defined the outer shell as a dictionary. Than you need a key value next but it is a new directory declaration.
- At the end there are "};" listed wheat should be "}," or better "}".

When I try to load my plist editor now already stumbles over the first line.

Posted: Fri Oct 02, 2009 6:33 pm
by Chaky
aaaaand that's why I still haven't released my unnamed baby yet..

Thanks for the pointers.

(I would've sworn that I fixed that comma-ending list...)

Posted: Fri Oct 02, 2009 6:51 pm
by Chaky
Eric Walch wrote:
- You defined the outer shell as a dictionary. Than you need a key value next but it is a new directory declaration.
- At the end there are "};" listed wheat should be "}," or better "}".

When I try to load my plist editor now already stumbles over the first line.
That outer shell would be <plist></plist> being translated to {}, same as dicts. I guess translator should simply ignore the plist part.. That's my flawed understanding of how the XML format works.. (as I said before, I can't tell heads from tails)

Regarding those ; I still need to "crack" the principle. I tried to get some answers from online wikis and tutorials, and the best explanation I got was that "lines can end with ; , but don't have to. (or was it for JS.. information overload...)

I guess that's what happens when you try to translate something from one language you don't understand, to another that you understand even less... while you have no idea what you're translating...

..

Posted: Fri Oct 02, 2009 7:04 pm
by Lestradae
Hi Chaky,

Really sorry that the XML -> OpenStep exercise was "too late" :(

But I'm very happy to have the whole thing in .js now!

Your fixes for Amen Brick's ship models etc. have now made it into OSE, though - already the downloadable beta test version here :D

I hope it was an interesting exercise in the inner workings of the legacy scripts, though?

L

..

Posted: Fri Oct 02, 2009 7:06 pm
by Lestradae
Just a quick question:

If I do a script action for a given system, say "0 170" in the planetinfo.plist, will that script action also be called all ten seconds or so or will it only be called when entering the "0 170" system?

Would be important information, thanks in advance for answers :)

L

PS:

Code: Select all

<key>2 30</key>
        <dict>
                <key>script_actions</key>
                <array>
                        <string>checkForShips: playerfuelstation</string>
                        <dict>
                                <key>conditions</key>
                                <array>
                                        <string>mission_playerstation_BAC equal 1</string>
                                        <string>shipsFound_number lessthan 1</string>
                                </array>
                                <key>do</key>
                                <array>
                                        <string>addSystemShips: playerfuelstation 1 0.8</string>
                                </array>
                        </dict>
                </array>
        </dict>

Posted: Fri Oct 02, 2009 7:10 pm
by Chaky
That (failed) attempt was actually a latest feature of a toolset that is in the developing (progress at continuous 95%).

Something that started as a simple tool to reduce a XML size (initiated by OSE plist size :D ) grew into a tool that does that in a batch... now has about 20 features that mostly work (this translation is the latest, and I failed it).

.. and I keep adding features, instead of releasing the thing...

Re: ..

Posted: Fri Oct 02, 2009 9:29 pm
by Kaks
Lestradae wrote:
If I do a script action for a given system, say "0 170" in the planetinfo.plist, will that script action also be called all ten seconds or so or will it only be called when entering the "0 170" system?
That would just be called the moment the system is populated.
It's just as easy/difficult to do the same thing using js, though...

Posted: Sat Oct 03, 2009 9:23 am
by Eric Walch
Chaky wrote:
That outer shell would be <plist></plist> being translated to {}, same as dicts. I guess translator should simply ignore the plist part.. That's my flawed understanding of how the XML format works.. (as I said before, I can't tell heads from tails)
You would have noticed when looking at an existing ascii plist. But removing the last flaws is just peanuts compared by what your script already achieves. I just wondered how those last two instances of "};" were generated. With an automated process you would think that when the rules are set up, everything works according those rules but only the last two instances were wrong.

Only problem are the ending "," that separate the elements in an array. There seem to be two definitions around. According mac OSX 10.4 or older it is not allowed to use a "," for the last element. The OS refuses to load these plist. For newer Mac OS or windows it is allowed to use a "," for the last element but it won't complain when one is missing. So to let it work for all operating systems, use the "," as separator of the elements and not as termination of the elements.

Posted: Sat Oct 03, 2009 8:32 pm
by Chaky
I've fixed the translator code so it will generate commas and semi-columns according to array/dictionary structure. Here is re-uploaded OSE-XML.plist, so if anyone would care to test it (and point the errors) I would greatly appreciate it.

Posted: Sat Oct 03, 2009 11:34 pm
by JensAyton
You’re putting commas after arrays in dictionaries, which does not make sense.

A dictionary consists of key-value pairs, of the form “key = value;”. There is always a semicolon after the dictionary. A dictionary is always enclosed in braces.
An array consists of items separated by commas. There is no comma after the last item. An array is always enclosed in parentheses.

You’ve incorporated comments into the code as strings, which will annoy the parser/whitelister.

Also, I don’t see why the file is called OSE-XML.plist when it isn’t XML. :-)

I don’t like the indentation style, but it isn’t technically wrong.

Posted: Sun Oct 04, 2009 8:00 am
by Screet
Hi,

I've got a very strange problem:

Code: Select all

[universe.tradeInValueForCommanderDictionary.valueCalculationError]: ***** ERROR: Shipyard dictionary entry for ship caduceus-omega-player required for trade in value calculation, but does not exist. Setting ship value to 0.
That's really strange because there's a shipyard.plist and shipyard-overrides.plist file which BOTH define that ship!

Any ideas?

Screet

Posted: Sun Oct 04, 2009 8:22 am
by Chaky
Ahruman wrote:
You’re putting commas after arrays in dictionaries, which does not make sense..
Thanks for the input... will fix that.
Ahruman wrote:
There is always a semicolon after the dictionary.
Eric Walch wrote:
- At the end there are "};" listed wheat should be "}," or better "}".
Now, I'm confused.
Ahruman wrote:
An array consists of items separated by commas. There is no comma after the last item. An array is always enclosed in parentheses.
Are you just stating the rules, or are you telling me thet there ARE commas after the last item in arrays? (and there should't be, 'coz I've fixed that part of the code...)
Ahruman wrote:
You’ve incorporated comments into the code as strings, which will annoy the parser/whitelister.
No, I haven't. There are no comments in the file whatsoever.

Atleast, not the <!-- --> type of comments.

Posted: Sun Oct 04, 2009 9:35 am
by JensAyton
Chaky wrote:
Ahruman wrote:
There is always a semicolon after the dictionary.
Eric Walch wrote:
- At the end there are "};" listed wheat should be "}," or better "}".
Now, I'm confused.
Oh dear… that was exactly the opposite of what I meant.

There is always a semicolon after each dictionary entry. There is nothing specifically after a dictionary except the closing }. Whether it’s followed by a semicolon, a space or nothing depends entirely on what it’s contained in.
Chaky wrote:
Are you just stating the rules,
Just the rules, m’am. Except where I got them wrong, of course. :-)
Chaky wrote:
Ahruman wrote:
You’ve incorporated comments into the code as strings, which will annoy the parser/whitelister.
No, I haven't. There are no comments in the file whatsoever.

Atleast, not the <!-- --> type of comments.
Line 310–312:

Code: Select all

"d100_number greaterthan 25",
"/* 75% chance of a trident in medium-tech stable systems */"
),
Here, an XML comment in the original has been turned into a C/OpenStep plist type comment, then put in a string.

Posted: Sun Oct 04, 2009 9:41 am
by Eric Walch
Chaky wrote:
Ahruman wrote:
There is always a semicolon after the dictionary.
Eric Walch wrote:
- At the end there are "};" listed wheat should be "}," or better "}".
Now, I'm confused.
When you look at the example Ahruman gives you'll see he means a semicolon after every dictionary entry.
Chaky wrote:
Ahruman wrote:
An array consists of items separated by commas. There is no comma after the last item. An array is always enclosed in parentheses.
Are you just stating the rules, or are you telling me thet there ARE commas after the last item in arrays? (and there should't be, 'coz I've fixed that part of the code...)
This part is just a bit of a problem as there are two different rules in use. On windows machines both versions are accepted. And as plist are uncommon to windows I assume oolite is under full control in examining them.
Mac OS until 10.4 refuses to read in plists that contain a comma after the last array entry. Mac OS 10.5 is more forgiving and accepts both ways now.

(And for some reason Apple changed the plist editor that ships with OS 10.5 in a way that it also terminates the last array element with a comma on saving. I am particular annoyed because of this as I know that plists saved with this editor in ascii mode are unreadable by older mac OS.)