Page 57 of 117

Re: Scripters cove

Posted: Thu Dec 06, 2012 8:11 pm
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.

Associating a buoy with its mother ship

Posted: Sat Dec 08, 2012 2:57 pm
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.

Re: Scripters cove

Posted: Sat Dec 08, 2012 4:08 pm
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...

Re: Associating a buoy with its mother ship

Posted: Sat Dec 08, 2012 4:33 pm
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).

Re: Scripters cove

Posted: Sat Dec 08, 2012 4:39 pm
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.

Re: Scripters cove

Posted: Sun Jan 13, 2013 3:02 pm
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.

Re: Scripters cove

Posted: Sun Jan 13, 2013 3:14 pm
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.)

Re: Scripters cove

Posted: Sun Jan 13, 2013 3:36 pm
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.

Re: Scripters cove

Posted: Mon Jan 14, 2013 9:30 pm
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:

Re: Scripters cove

Posted: Wed Jan 16, 2013 8:15 am
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.

Re: Scripters cove

Posted: Sat Jan 19, 2013 9:24 pm
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");
   }
		
}

Re: Scripters cove

Posted: Sat Jan 19, 2013 9:50 pm
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.

Re: Scripters cove

Posted: Sat Jan 19, 2013 11:21 pm
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.

Re: Scripters cove

Posted: Sat Jan 19, 2013 11:30 pm
by cim
CommRLock78 wrote:
system.ID = -1 for interstellar, right?
Yes, though system.isInterstellarSpace is perhaps a better test.

Re: Scripters cove

Posted: Sat Jan 19, 2013 11:46 pm
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