Yes, there was a naming discontinuity between:
worldScripts['nullgates'].nullgate
and
this.name = "NullGate";
So I renamed them both to just use "nullgate", and that clears up most of my confusion.
Seems you can't set or check variables in nonexistent worldScripts.
Btw, what is the difference between this:
worldScripts['nullgate'].nullgate
and this:
worldScripts["nullgate"].nullgate
...if any.
problems with variable-assigned ships...
Moderators: winston, another_commander, Getafix
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: problems with variable-assigned ships...
Switeck wrote:worldScripts['nullgate'].nullgate
edit - fair enough learn something new and all of that....
Valid syntax.Switeck wrote:worldScripts["nullgate"].nullgate
Last edited by Capt. Murphy on Wed Mar 14, 2012 7:58 pm, edited 1 time in total.
Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
Re: problems with variable-assigned ships...
'string' (in single quotes) also works for defining string values in Javascript. So that should work too.Capt. Murphy wrote:Invalid syntax - you are looking for string value which is by definition enclosed in "string"Switeck wrote:worldScripts['nullgate'].nullgate
Re: problems with variable-assigned ships...
Indeed, the two are equivalent.
You could also use
You could also use
worldScripts.nullgate.nullgate
where the first nullgate
is the script name and the second is the function name within it. That method does have the disadvantage though that it can't cope with spaces in the script name.My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: problems with variable-assigned ships...
It's the same, but you can also have:Switeck wrote:Btw, what is the difference between this:
worldScripts['nullgate'].nullgate
and this:
worldScripts["nullgate"].nullgate
...if any.
worldScripts["nullgate's"].nullgate
but not:
worldScripts['nullgate's'].nullgate
So a ' inside a string of double quotes is accepted as part of the string and not as starting/ending point of a string.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Re: problems with variable-assigned ships...
Which is probably also why this works:
log(this.name,"worldScripts['nullgate'].nullgate is not null!");
...but this does not:
log(this.name,"worldScripts["nullgate"].nullgate is not null!");
log(this.name,"worldScripts['nullgate'].nullgate is not null!");
...but this does not:
log(this.name,"worldScripts["nullgate"].nullgate is not null!");
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: problems with variable-assigned ships...
Notepad++ should give you a clue when this is going to be a problem. When editing a recognised JS script it automatically greys out the text that is part of a recognised string...Switeck wrote:Which is probably also why this works:
log(this.name,"worldScripts['nullgate'].nullgate is not null!");
...but this does not:
log(this.name,"worldScripts["nullgate"].nullgate is not null!");
log(this.name,"worldScripts['nullgate'].nullgate is not null!")
log(this.name,"worldScripts["nullgate"].nullgate is not null!")
Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1