Page 2 of 2

Re: Java Script Error, Ship Is Undefined

Posted: Sat Dec 24, 2011 7:58 pm
by Thargoid
mandoman wrote:
I also SEE the difference in your first point, but don't understand it. In a shipdata.plist, doesn't the "like_ship" come BEFORE the ship it refers too? I'm staring at my shipdata.plist entry (one of them) right now, trying to see how what you are saying fits, and I don't see it. The way I use it LOOKS exactly like the same type of reference in "Behemoths" like_ship references. I'm missing something, I know. Behemoths defines two classes of Behemoth, but I notice it has models for sixteen ships. Each of those ships is given a "like_ship" reference to one of the two Behemoth types. I only have two ships, so far, and am working on a third, but it LOOKS like I did the same thing as done in "Behemoths" references. I'm getting dizzy. Okay, I'll study what you are saying, and try to understand, because I know you know the right of it. Sorry I'm so dense. :oops:
The order of the entities defined in the shipdata.plist doesn't matter - they are loaded into the game when the game loads, but only actually referenced when they are needed. Hence even if the template entity comes after the variant in the shipdata, both will be in memory when they are first called and so it doesn't really matter.

Basically what "like_ship = <myTemplate>" does is say go and find the entity labelled <myTemplate> and substitute all its keys into the variant entity (the one that contains the like_ship key). If there are keys of the same name in the variant entity then those take precidence over the like_ship ones (for example if the template ship has name = "DreadNaught-Template"; and the variant has name = "DreadNaught Rudolph"; then the entity will use name = "DreadNaught Rudolph";).

In your case the variant was looking to take keys from a template called "dreadnaught-type1" (due to "like_ship" = "dreadnaught-type1";) but that entity isn't refined anywhere. Your template entity is defined as "Dreadaught Type 1" in the shipdata.plist.

Remember computers and computer languages are dumb - I can tell when you said to go look for "dreadnaught-type1" that you meant it to use what you've defined as "Dreadaught Type 1", but your computer and Oolite can't. Simplest will be to change

Code: Select all

"Dreadaught Type 1" =
to

Code: Select all

"dreadnaught-type1" = 
which is I think what you actually mean. If you want another example, look in the shipdata.plist of my TCAT OXP, which also uses like_ship to a wide extent to define the different versions of the Raptor.

But as I said before, stick at it. I would expect quite soon you'll have a lightbulb moment and suddenly the mists will part and everything will become clear. I know it can be frustrating, but you're not doing too badly, you're getting closer to understanding I think.[/color]

Re: Java Script Error, Ship Is Undefined

Posted: Sat Dec 24, 2011 8:18 pm
by mandoman
Thargoid wrote:
The order of the entities defined in the shipdata.plist doesn't matter - they are loaded into the game when the game loads, but only actually referenced when they are needed. Hence even if the template entity comes after the variant in the shipdata, both will be in memory when they are first called and so it doesn't really matter.

Basically what "like_ship = <myTemplate>" does is say go and find the entity labelled <myTemplate> and substitute all its keys into the variant entity (the one that contains the like_ship key). If there are keys of the same name in the variant entity then those take precidence over the like_ship ones (for example if the template ship has name = "DreadNaught-Template"; and the variant has name = "DreadNaught Rudolph"; then the entity will use name = "DreadNaught Rudolph";).


In your case the variant was looking to take keys from a template called "dreadnaught-type1" (due to "like_ship" = "dreadnaught-type1";) but that entity isn't refined anywhere. Your template entity is defined as "Dreadaught Type 1" in the shipdata.plist.

Remember computers and computer languages are dumb - I can tell when you said to go look for "dreadnaught-type1" that you meant it to use what you've defined as "Dreadaught Type 1", but your computer and Oolite can't. Simplest will be to change

Code: Select all

"Dreadaught Type 1" =
to

Code: Select all

"dreadnaught-type1" = 
which is I think what you actually mean. If you want another example, look in the shipdata.plist of my TCAT OXP, which also uses like_ship to a wide extent to define the different versions of the Raptor.

But as I said before, stick at it. I would expect quite soon you'll have a lightbulb moment and suddenly the mists will part and everything will become clear. I know it can be frustrating, but you're not doing too badly, you're getting closer to understanding I think.[/color]
You're talking case reference differences? So, should I just use lower case for all shipdata entries? I use it for most of it already, except those cases when I'm defining weapons, and such. I see what you're saying now. The "like_ship" = "dreadnaught-type1" reference should be referring to an identical ship type title, in this caes "dreadnaught-type1" = {....etc., in shipdata.plist. I think i understand the "like_ship" requirements now. Thank you. Oh, and you're recommending the TCAT to study? Believe me, I study everything you, Smivs, Erich Walch, Aegidian, etc..... have created. I've learned a lot from those oxps, but must admit that much of it is still not very clear to me. Thanks for your encouragement, and help. :D

Re: Java Script Error, Ship Is Undefined

Posted: Sat Dec 24, 2011 8:30 pm
by Thargoid
Upper or lower case in names and unique identifiers doesn't really matter, as long as you're consistent as JS is case sensitive (it does matter in keys and values, which should generally be lower case - as usual the wiki is your guide here). Normal convention is to capitalise the first letter of each word making up a string except the first one. Hence I'd use something like mandoman_dreadnaughtType1 or somesuch.

It's also good practice to make your identifiers unique by adding either your name or the OXP name to the front of them. If you use generic names and then someone else writes an OXP which uses the same identifier, then one will overwrite the other with weird, unusual and often downright bizarre (but always undesired) results. This applies to anything you will want to be unique, such as shipdata.plist entity identifiers, script names, roles (except the generic ones like "trader", "pirate" etc), AI names, models and textures. The existing OXPs will (usually) give you a good example of how to do it.

And if there's specific stuff that's not clear, of course just ask, either in a thread or by PM. It's easier to guide as you go rather than to unweave a script with glitches (and less frustrating for you).

Re: Java Script Error, Ship Is Undefined

Posted: Sat Dec 24, 2011 8:49 pm
by mandoman
Okay. I better go back and rework this mess. I'm still getting "like_ship" Errror warnings, and a Java Script error saying the ship is "Undefined". I changed it to what you recommended, but I have a feeling it has something to do with the shipdata.plist entries. More questions to come. :)

Re: Java Script Error, Ship Is Undefined

Posted: Sat Dec 24, 2011 11:29 pm
by mandoman
What the heck does

Code: Select all

17:17:49.009 [script.javaScript.exception.badLeftsideOfAss]: ***** JavaScript exception (mandoman-dreadnaught.js.anon-script): ReferenceError: invalid assignment left-hand side
mean? "badLeftsideOfAss"??????? :shock:

Re: Java Script Error, Ship Is Undefined

Posted: Sun Dec 25, 2011 12:30 am
by DaddyHoggy
mandoman wrote:
What the heck does

Code: Select all

17:17:49.009 [script.javaScript.exception.badLeftsideOfAss]: ***** JavaScript exception (mandoman-dreadnaught.js.anon-script): ReferenceError: invalid assignment left-hand side
mean? "badLeftsideOfAss"??????? :shock:
It means:

Code: Select all

invalid assignment left-hand side

Re: Java Script Error, Ship Is Undefined

Posted: Sun Dec 25, 2011 1:03 am
by mandoman
DaddyHoggy wrote:
mandoman wrote:
What the heck does

Code: Select all

17:17:49.009 [script.javaScript.exception.badLeftsideOfAss]: ***** JavaScript exception (mandoman-dreadnaught.js.anon-script): ReferenceError: invalid assignment left-hand side
mean? "badLeftsideOfAss"??????? :shock:
It means:

Code: Select all

invalid assignment left-hand side
Maybe I didn't phrase the question correctly. What does"Invalid assignment left-hand side" mean. I've been looking around at the script, and I don't understand to what it is referring. Never mind, I'll figure it out.

Re: Java Script Error, Ship Is Undefined

Posted: Sun Dec 25, 2011 10:21 am
by Kaks
it means that instead of something like

xyz= 56+2;

which means 'store the value '56+2' inside the variable 'xyz', you must have written something like

56+2=xyz

which for javascript means nothing at all (it could possibly be interpreted to mean "store the value inside 'xyz' inside the number 58" but js just doesn't like the concept)
On the left of an = sign ('assignment operator') there can only be the name of one variable/object for js to make sense of it... :)

...and merry xmas! :)

PS: since javascript is widely used for web pages and such, most js errors can be researched on the internet (even the Oolite-only ones are on google most of the time, amazingly enough). Entering 'invalid assignment left-hand side' in the google search box reveals quite a number of explanations why you could get that error! ;)

Re: Java Script Error, Ship Is Undefined

Posted: Sun Dec 25, 2011 11:21 am
by JensAyton
mandoman wrote:
"badLeftsideOfAss"???????
The identifiers for JS error messages are automatically converted from those used internally in SpiderMonkey, in this case JSMSG_BAD_LEFTSIDE_OF_ASS. I disavow all responsibility. :-)

Re: Java Script Error, Ship Is Undefined

Posted: Sun Dec 25, 2011 4:52 pm
by mandoman
Kaks wrote:
it means that instead of something like

xyz= 56+2;

which means 'store the value '56+2' inside the variable 'xyz', you must have written something like

56+2=xyz

which for javascript means nothing at all (it could possibly be interpreted to mean "store the value inside 'xyz' inside the number 58" but js just doesn't like the concept)
On the left of an = sign ('assignment operator') there can only be the name of one variable/object for js to make sense of it... :)

...and merry xmas! :)

PS: since javascript is widely used for web pages and such, most js errors can be researched on the internet (even the Oolite-only ones are on google most of the time, amazingly enough). Entering 'invalid assignment left-hand side' in the google search box reveals quite a number of explanations why you could get that error! ;)
Thank you extremely much. THAT was what I was looking for. That makes sense. I really appreciate the explanation. Now, maybe I can fix the problem.....and maybe not, but at least I know what THAT error message means. Merry Christmas to you, too. :D

Re: Java Script Error, Ship Is Undefined

Posted: Sun Dec 25, 2011 4:55 pm
by mandoman
Ahruman wrote:
mandoman wrote:
"badLeftsideOfAss"???????
The identifiers for JS error messages are automatically converted from those used internally in SpiderMonkey, in this case JSMSG_BAD_LEFTSIDE_OF_ASS. I disavow all responsibility. :-)
*************LOL************** :lol:

When I first saw that, I about fell out of my chair laughing. I may not understand Java Script, but I like it. :D

Re: Java Script Error, Ship Is Undefined

Posted: Thu Dec 29, 2011 2:56 am
by mandoman
I now have a version of the Dreadnaught that is loading without errors in Latest.log. I have shortened everything to simply "mandodred" what ever I'm defining, such as "mandodredReceiveDockingAI.plist", or "mandodreddocktype1.dat". I've been over it till my eyes are crossed. Before any of that I reloaded the Andricodred into Blender, cleaned up a few vertex points, and faces that weren't needed, re-did the Unwrap process, and the Texture process, and the exporting process, and the Obj2DatTex.py process. I did this in an attempt to maybe clean up the model, just in case something in the design itself was preventing it from spawning in the game. Didn't work. Not for the re-done Andricodred (mandodredType2), or the Andricothere (mandodredType1). I can't get either ship to spawn, and without any Latest.log errors to guide me, I'm stuck. Just for giggles, I thought I would type out the process I used with the DebugConsole for spawning the ships, and how it replied.
Typed into DebugConsole:

Code: Select all

:spawn mandodred-andricodred-carrier
ENTER

Answer:

Code: Select all

this.T = system.addships("mandodred-andricodred-carrier", 1, player.ship.position, 10000): if (this.T) this.T = this.T[0]; else consoleMessage('command-error', 'Could not spawn'" + "mandodred-andricodred-carrier" + '".'):
Could not spawn "mandodred-andricodred-carrier".
I did exactly the same thing, with the exact same results for the mandodred-andricothere-carrier battleship. I'm stuck.