Scripters cove

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

Moderators: winston, another_commander

User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Scripters cove

Post by JensAyton »

Eric Walch wrote:
it still makes sense to check for "ship.docked == true
Just check if (ship.docked). Explicitly comparing to true serves no purpose except in specialized situations.
User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 909
Joined: Wed Feb 23, 2011 10:08 pm
Location: Preying Manta
Contact:

Re: Scripters cove

Post by CaptSolo »

Could someone please tell me the Oolite coordinate system as it pertains to the view screen? Thanks
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripters cove

Post by Svengali »

CaptSolo wrote:
Could someone please tell me the Oolite coordinate system as it pertains to the view screen? Thanks
If I get this right you are talking about custom_views? If so then
[wiki]Shipdata.plist[/wiki] (custom_views), view_position is X,Y,Z - [0,0,0] should be the center.
[wiki]Quaternion[/wiki]

A good overview about Oolite
http://wiki.alioth.net/index.php/Catego ... _scripting
User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 909
Joined: Wed Feb 23, 2011 10:08 pm
Location: Preying Manta
Contact:

Re: Scripters cove

Post by CaptSolo »

Svengali wrote:
CaptSolo wrote:
Could someone please tell me the Oolite coordinate system as it pertains to the view screen? Thanks
If I get this right you are talking about custom_views? If so then
[wiki]Shipdata.plist[/wiki] (custom_views), view_position is X,Y,Z - [0,0,0] should be the center.
[wiki]Quaternion[/wiki]

A good overview about Oolite
http://wiki.alioth.net/index.php/Catego ... _scripting
Thanks for your reply. Should have been more specific as I was referring to the Forward, rear, left and right views. But I figured it out by studying the hud.plist. I have made a copy of that file to the Add Ons folder to tinker with.
User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 909
Joined: Wed Feb 23, 2011 10:08 pm
Location: Preying Manta
Contact:

Re: Scripters cove

Post by CaptSolo »

Considering this snippet from hud.plist,

Code: Select all

{	// scanner
	alpha		= 1.0;
	selector	= "drawScanner:";
	x		= 0;
	y		= 60;
	y_origin	= -1;
	height	= 72.0;
	width		= 288.0;
	rgb_color	= (1.0, 0.0, 0.0);
},
Made me ask two questions:
1) How is this procedure executed / handled?
2) How many draw procedures are there other than drawing rectangles, circles, and ellipses that a scripter could use?
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Hi,

Is there a way to call a function in a world script from another one.

Like a callback passed by a string.

As an example

Word Script A
this.startUp = function()
{
this.callback="B";
}
this.B = function(option)
{
log(this.name,option);
}


And second script can retrieve the name of the call back by worldScripts("A").callback;

But I could not achieve to call the callback from second script.
My OXP's
And Latest Mission Coyote's Run
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Scripters cove

Post by Commander McLane »

You can call any world script function from any other script by pre-fixing the world script name.

Example: this.$setUpSystem() in the Anarchies-script can be called from anywhere (including the JS-console, which is particularly useful for playtesting) with worldScripts.Anarchies.$setUpSystem().

The prefix for world scripts is worldScript (see here), which is followed by the script name (the one specified in this.name at the top of your world script). There are some special rules if your script name contains a SPACE.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Thanks Commander McLane,

But my problem is trying to pass the name of the function as a string property.

wordScripts("MyWordScript") gets my MyWordScript. Like this I want to call a Function in that world script by name.
My OXP's
And Latest Mission Coyote's Run
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

Never mind I solved the problem.
My OXP's
And Latest Mission Coyote's Run
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Re: Scripters cove

Post by DaddyHoggy »

If you say how, others will benefit from your discovery...
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Scripters cove

Post by Okti »

DaddyHoggy wrote:
If you say how, others will benefit from your discovery...
You are right.

The method is

Code: Select all

worldScripts["scriptname"]["functionname"](args);
I tried it at the first place but I forgot to add this. before the function name :D
My OXP's
And Latest Mission Coyote's Run
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: Scripters cove

Post by Capt. Murphy »

Morning (yawn),

Anyone know if the variable ship_trade_in_factor in the save file is visible to JS and if so what's the property to access it (player.ship.something???).

Ta,
[EliteWiki] 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
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: Scripters cove

Post by Eric Walch »

Okti wrote:
The method is

Code: Select all

worldScripts["scriptname"]["functionname"](args);
I tried it at the first place but I forgot to add this. before the function name :D
That you need to include "this." when writing it down as string is new to me. I always used:

Code: Select all

worldScripts.scriptname.functionname(args)
for calling functions with parameters in other scripts. Or

Code: Select all

worldScripts["scriptname"].functionname(args)
Both go without a "this". Writing down as string is only needed when the string contains special characters. A scriptname might contain such characters, but a function never.
"Capt Murphy"]Anyone know if the variable ship_trade_in_factor in the save file is visible to JS and if so what's the property to access it (player.ship.something???).
ship_trade_in_factor is not exposed.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Scripters cove

Post by JensAyton »

Eric Walch wrote:
Both go without a "this". Writing down as string is only needed when the string contains special characters. A scriptname might contain such characters, but a function never.
foo.bar is purely shorthand for foo["bar"]. There is no difference in behaviour. As such, foo["Fred Bloggs"] = function () {} is perfectly valid.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

But foo.fred bloggs = function() isn't due to the space (an example of the special characters).

Personally I always tend to use worldScripts["name"] rather than worldScripts.name even when name doesn't include a space or somesuch, just for consistency. But as Eric says, the functions themselves never will have such characters in them by definition.
Post Reply