Scripters cove

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

Moderators: winston, another_commander

User avatar
Rese249er
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Thu Jun 07, 2012 2:19 pm
Location: Well, I WAS in G3...

Re: Scripters cove

Post by Rese249er »

Smivs wrote:
Hehe, who knows what a bunch of nutters like us will do when given a new toy feature!
Well, now that the option is back, you'll be able to see what I do with it in... (looks to see what version's next) HoloNumHUDv1.2, out PDQ.
Got all turned around, lost my nav connection... Where am I now?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2409
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Associating a buoy with its mother ship

Post by Wildeblood »

When I target a buoy with the compass the only piece of useful information I can retrieve is the beacon code, and with many older OXPs even that is fairly cryptic. How do I get from the buoy to the station it's floating in front of, since that is the object I'm really interested in.
User avatar
Cmd. Cheyd
---- E L I T E ----
---- E L I T E ----
Posts: 934
Joined: Tue Dec 16, 2008 2:52 pm
Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...

Re: Scripters cove

Post by Cmd. Cheyd »

Can a world script call a function, check a variable, etc located inside an equipment script? If so, how? Obviously, worldScripts["foo"] is incorrect...
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Associating a buoy with its mother ship

Post by Thargoid »

Wildeblood wrote:
When I target a buoy with the compass the only piece of useful information I can retrieve is the beacon code, and with many older OXPs even that is fairly cryptic. How do I get from the buoy to the station it's floating in front of, since that is the object I'm really interested in.
I'd perform a search for all ships with suitable parameters (in this case ones that have the role of station or something along those lines) within a suitable radius of the position of the buoy.

Something like system.entitiesWithScanclass or system.shipsWith(Primary)Role or one of the similar scanning functions available through the system class.

Then check the array and pick the closest/most suitable candidate to be the relevant station (the array would presumably be one entity long anyway in most cases).
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Cmd. Cheyd wrote:
Can a world script call a function, check a variable, etc located inside an equipment script? If so, how? Obviously, worldScripts["foo"] is incorrect...
No. If the equipment script needs to interact with a world script, then any functions/variables that they both need access to need to be placed in the world script.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post by spara »

I've been meaning to ask this for quite some time.

1. Is it possible to reset the message_gui settings to their default values?

I have tried setting player.ship.hud = 'null' and using message_gui = {} in a resetting hud file. Neither seems to do the trick.

2. Is it possible to override just the message_gui settings from a hud file? Idea is that the other hud elements stay intact.

3. If it's not possible to reset the message_gui, what are the default values of it? I want to write a resetting hud.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2409
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: Scripters cove

Post by Wildeblood »

spara wrote:
I've been meaning to ask this for quite some time.

1. Is it possible to reset the message_gui settings to their default values?

I have tried setting player.ship.hud = 'null' and using message_gui = {} in a resetting hud file. Neither seems to do the trick.
Have you tried again recently? It should be working as Kaks described in 1.77. That is, message_gui = {} should reset it.
spara wrote:
2. Is it possible to override just the message_gui settings from a hud file? Idea is that the other hud elements stay intact.
Have another look in Trading Assistant. Only the first HUD file switched to has the message_gui and comm_log_gui defined. The others inherit it. So yes, make a HUD file with just those, switch to it for a moment, then switch back. (No you can't eliminate the momentary flicker.)
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post by spara »

Wildeblood wrote:
spara wrote:
I've been meaning to ask this for quite some time.

1. Is it possible to reset the message_gui settings to their default values?

I have tried setting player.ship.hud = 'null' and using message_gui = {} in a resetting hud file. Neither seems to do the trick.
Have you tried again recently? It should be working as Kaks described in 1.77. That is, message_gui = {} should reset it.
:shock: Well so it does. This is good news.
spara wrote:
2. Is it possible to override just the message_gui settings from a hud file? Idea is that the other hud elements stay intact.
Wildeblood wrote:
Have another look in Trading Assistant. Only the first HUD file switched to has the message_gui and comm_log_gui defined. The others inherit it. So yes, make a HUD file with just those, switch to it for a moment, then switch back. (No you can't eliminate the momentary flicker.)
Yes, that's the way to do it with the default hud, but if I would like to do it with some other hud, it's not possible. As the other hud usually defines the message_gui. Basically I would like to only change the message_gui of a hud, it would feel a bit more consistent that way. Not a big thing anyway.
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post by Rorschachhamster »

Ok, I'm working on something, ... with my limited scripting abilities... :oops:
It is supposed to be a freighttrain, with multiple "waggons", that follow a tractionengine... It works, but as I based my script on the mobile ad boards from Thargoid, it looks a little stiff - with all trains following in a straight line, more or less (wich has the amusing side effect of the last trailer being quite fast in its rotation). How do I get a delay into the reaction from the trailers, so if the traction engine turns the trains follow but slightly delayed? Is this do-able? I plan do add a random number of engines, but to get the physics right, I started with three... here is the code:

Code: Select all

this.shipSpawned = function()
	{
	this.trailer = this.ship.spawnOne("trailer"); 
	this.trailer2 = this.ship.spawnOne("trailer"); 
	this.trailer3 = this.ship.spawnOne("trailer"); 
	this.freighttrainGroup = new ShipGroup("trailer", this.ship);
	this.ship.group = this.freighttrainGroup;
	this.freighttrainGroup.leader = this.ship;
	this.trailer.group = this.freighttrainGroup;
	this.trailer2.group = this.freighttrainGroup;
	this.trailer3.group = this.freighttrainGroup;
	
	this.callbackID = addFrameCallback(this.positionTrailer.bind(this));
	}
	
this.positionTrailer = function()
	this.trailer.position = this.ship.position.subtract(this.ship.orientation.vectorForward().multiply(this.trailer.collisionRadius + this.ship.collisionRadius));
	this.trailer.orientation = this.ship.orientation;
	this.trailer2.position = this.trailer.position.subtract(this.trailer.orientation.vectorForward().multiply(this.trailer.collisionRadius + this.trailer2.collisionRadius));
	this.trailer2.orientation = this.trailer.orientation;
	this.trailer3.position = this.trailer2.position.subtract(this.trailer2.orientation.vectorForward().multiply(this.trailer2.collisionRadius + this.trailer3.collisionRadius));
	this.trailer3.orientation = this.trailer2.orientation;
	}
Any hints would be welcome, and I'm still a bloody noob in js, so be gentle... :D and yes, I know, this is the barebones of the mobile ab board, but I looked into the timer at the wiki and couldn't get it right...

EDIT: As soon as I laid in bed, I had an idea :roll: ... the trick should be to distance the trailer from the traction engine without the vector forward and let it turn always into the direction of it, with the same "pitch"... quaternions? Oh, boy... :lol:
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 »

Now you use for the position:

Code: Select all

this.trailer.position = this.ship.position.subtract(this.ship.orientation.vectorForward().multiply(this.trailer.collisionRadius + this.ship.collisionRadius));
The used distance is fixed to (this.trailer.collisionRadius + this.ship.collisionRadius). When you want it more flexible, you must add variation to this distance. e.g. by adding a sinus of the time. And maybe a sinus of time*1.2 for the next one, so they don't use the same frequency.

And you can replace "orientation.vectorForward()" by just "vectorForward". In the first case you have to calculate a vectorForward from the quaternion on every frame. (Calculating a vectorForward is time consuming). But, the system already had calculated a vectorForward for each ship on each frame, so it is cheaper to directly use that one.
User avatar
CommRLock78
---- E L I T E ----
---- E L I T E ----
Posts: 1138
Joined: Sat Apr 07, 2012 7:35 pm
Location: US
Contact:

Re: Scripters cove

Post by CommRLock78 »

I've been working on a wee project tweaking a particular system slightly to my desire adding some planets from Deep Horizons Systems. Cmd_Cheyd has been more than gracious in giving me a hand, however, I feel like I've already asked enough of him at this point. If I'm not mistaken the only thing my script needs is a test to see whether the bodies have been already placed, and I was thinking a simple sum of the planets and moons in the if statement would be the way to go but I have no idea how to do that (I could very well be wrong about this as I am a complete and utter noob :D).

Code: Select all

this.name           = "Ededleen System Script"
this.licence        = "CC-NC-SA 3.0"
this.description    = "Populates Ededleen System with additional astronomical bodies via Cmd_Cheyd's Deep Horizon Systems";
this.version        = "0.1 alpha"


this.shipWillLaunchFromStation = function(station) 
{
     log (this.name, "Entering shipWillLaunchFromStation function.  Current Galaxy is: " + system.info.galaxyID + ".  Current System is: " + system.ID + ".");
   if (system.info.galaxyID === 0 && system.ID === 138) 
{      
      system.addPlanet("DeepHorizon_planet3");
      system.addPlanet("DeepHorizon_planet7");
      system.addPlanet("DeepHorizon_planet20");
      system.addMoon("DeepHorizon_moon11");
   }
		
}



this.shipWillExitWitchspace = function() 
{
     log (this.name, "Entering shipWillLaunchFromStation function.  Current Galaxy is: " + system.info.galaxyID + ".  Current System is: " + system.ID + ".");
   if (system.info.galaxyID === 0 && system.ID === 138) 
{      
      system.addPlanet("DeepHorizon_planet3");
      system.addPlanet("DeepHorizon_planet7");
      system.addPlanet("DeepHorizon_planet20");
      system.addMoon("DeepHorizon_moon11");
   }
		
}
"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

system.planets.length will give you the total number of planets and moons in the current system. But check for interstellar space first as it will be undefined there.
User avatar
CommRLock78
---- E L I T E ----
---- E L I T E ----
Posts: 1138
Joined: Sat Apr 07, 2012 7:35 pm
Location: US
Contact:

Re: Scripters cove

Post by CommRLock78 »

Thargoid wrote:
system.planets.length will give you the total number of planets and moons in the current system. But check for interstellar space first as it will be undefined there.
Thanks Thargoid :mrgreen:.

system.ID = -1 for interstellar, right?

Edit: As doubly textured planets don't readily reveal themselves, here's what I have now. I'm not quite sure of the syntax however :(:

Code: Select all

this.name           = "Ededleen System Script"
this.licence        = "CC-NC-SA 3.0"
this.description    = "Populates Ededleen System with additional astronomical bodies via Cmd_Cheyd's Deep Horizon Systems";
this.version        = "0.1 alpha"


this.shipWillLaunchFromStation = function(station) 
{
     log (this.name, "Entering shipWillLaunchFromStation function.  Current Galaxy is: " + system.info.galaxyID + ".  Current System is: " + system.ID + ".");
   if (system.ID !== -1 && system.info.galaxyID === 0 && system.ID === 138 && system.planets.length !== 5) 
{      
      system.addPlanet("DeepHorizon_planet3");
      system.addPlanet("DeepHorizon_planet7");
      system.addPlanet("DeepHorizon_planet20");
      system.addMoon("DeepHorizon_moon11");
   }
		
}



this.shipWillExitWitchspace = function() 
{
     log (this.name, "Entering shipWillLaunchFromStation function.  Current Galaxy is: " + system.info.galaxyID + ".  Current System is: " + system.ID + ".");
   if (system.ID !== -1 && system.info.galaxyID === 0 && system.ID === 138 && system.planets.length !== 5) 
{      
      system.addPlanet("DeepHorizon_planet3");
      system.addPlanet("DeepHorizon_planet7");
      system.addPlanet("DeepHorizon_planet20");
      system.addMoon("DeepHorizon_moon11");
   }
		
}
This seems to be working just fine, so far :D.
Last edited by CommRLock78 on Sat Jan 19, 2013 11:37 pm, edited 1 time in total.
"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

CommRLock78 wrote:
system.ID = -1 for interstellar, right?
Yes, though system.isInterstellarSpace is perhaps a better test.
User avatar
CommRLock78
---- E L I T E ----
---- E L I T E ----
Posts: 1138
Joined: Sat Apr 07, 2012 7:35 pm
Location: US
Contact:

Re: Scripters cove

Post by CommRLock78 »

cim wrote:
CommRLock78 wrote:
system.ID = -1 for interstellar, right?
Yes, though system.isInterstellarSpace is perhaps a better test.
What I have seems to work (so far :P) - I'm not sure how to implement system.isInterstellarSpace as it is Boolen
"I'll laser the mark all while munching a fistful of popcorn." - Markgräf von Ededleen, Marquess, Brutal Great One, Assassins' Guild Exterminator
---------------------------
At the helm of the Caduceus Omega, 'Murderous Morrígan'
Post Reply