Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

I've broken the 7 ly limit! (sort of...)

General discussion for players of Oolite.

Moderators: winston, another_commander

User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Post by Mauiby de Fug »

The way it's set to work is this:

You buy the wormhole generator as a piece of pylon based equipment.
You select your hyperspace destination in the usual way on the galactic map.
You fire the generator in the same way as you would a missile/mine.
The generator then exits the system to another system in range that is on the route to the hyperspace destination you selected, leaving a wormhole in it's wake.
You then follow it through the wormhole.
Once in the next system, the drone exits the system to the next system on the route.
You follow.
Repeat.
User avatar
Phantom Hoover
Dangerous
Dangerous
Posts: 100
Joined: Mon Mar 22, 2010 9:06 pm

Post by Phantom Hoover »

So it just makes a wormhole to <arbitrary system>, ignoring the 7 LY jump limit?
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Post by Mauiby de Fug »

No, it makes a series of wormholes to an arbitrary system, each of which is within the 7 LY jump limit.
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:

Post by Commander McLane »

Just to re-iterate what I said before:

I like the idea because (and as long as) it doesn't remove the need to do individual, consecutive jumps, as opposed to one long jump. (For instance, in the Escape Velocity series, you could buy a piece of equipment which allowed you to make series of jumps and emerge in your final destination system at once, skipping the intermediate systems altogether. I wouldn't like something like that for Oolite.)

Having individual, consecutive jumps makes you emerge in each of the intermediate systems, which means that in each of the intermediate systems something can go wrong. Something distracts you for 15 seconds, and your next connection wormhole is gone, leaving you stranded where you are. (Technically, you're not stranded, because you still have your tanks full and can continue to jump by yourself. But the nice flow of jumps is broken, and the expensive device is gone.) Failsafe technology is boring. The possibility of failure brings excitement.

I agree with the suggestion to make it a mission equipment rather than something everybody can buy all the time. At least the player could be awarded it first through a mission, before it perhaps becomes a regularly buyable piece of equipment (like the Gal Drive Mod in Cataclysm which allows you to reach isolated systems; first you get it in order to fulfill a mission, afterwards it becomes buyable).

So it's thumbs up from me! :D
Last edited by Commander McLane on Thu Dec 30, 2010 5:39 pm, edited 1 time in total.
User avatar
Phantom Hoover
Dangerous
Dangerous
Posts: 100
Joined: Mon Mar 22, 2010 9:06 pm

Post by Phantom Hoover »

Erm. If it just skips through systems with <= 7 LY jumps, how would you get across, say, the Great Rift in G7?
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:

Post by Commander McLane »

Phantom Hoover wrote:
Erm. If it just skips through systems with <= 7 LY jumps, how would you get across, say, the Great Rift in G7?
You wouldn't. That's not the purpose of this gadget.
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Post by Mauiby de Fug »

I'm quite happy for it only to be awarded after the completion of a mission - for one thing, it would give it some backstory/context. Suppose I'd better get my thinking cap on and come up with one, unless somebody else wants to do it!?

The script itself is very simple - 'tis just attached to a piece of equipment (with a nullAI.plist, which seems to work. I haven't got my head around AIs yet...) with the requisite shipdata, equipment and description plist entries.

Here it is in its entirety at the moment:

Code: Select all

this.name           = "Mauiby's Wormhole Drone";
this.author         = "Mauiby de Fug";
this.description    = "Generate the wormhole chain";
this.version        = "1.0";

var jumpChain;
var chainPos;

this.shipSpawned = function() {
	player.consoleMessage("Wormhole chain sequence activated...", 5);
	jumpChain = System.infoForSystem(galaxyNumber, System.ID).routeToSystem(System.infoForSystem(galaxyNumber, PlayerShip.targetSystem));
	chainPos = 1;
	log("Target system is " + PlayerShip.targetSystem);
	log("Route: " +jumpChain.route);
	log("Distance: "+jumpChain.distance);
	log("Time: "+jumpChain.time);
	log("Chain length: "+jumpChain.route.length);
	this.ship.velocity = player.ship.velocity;
	this.ship.orientation = player.ship.orientation;
	this.ship.position = player.ship.position.add(player.ship.orientation.vectorForward().multiply(4000));
	this.createWormhole();
}

this.shipExitedWormhole = function() {
	log("Am in system: "+System.ID);
	log("Want to go to: "+PlayerShip.targetSystem);
	if (PlayerShip.targetSystem != System.ID) {
		log("Want to create wormhole");
		this.createWormhole();
	}
}

this.createWormhole = function() {
	log("Position in chain: "+chainPos); 
	this.ship.fuel = 7;
	log("Can I jump?");
	log(this.ship.exitSystem(jumpChain.route[chainPos]));
	chainPos++;
}
As you can see, a fair amount of it is just logging, which can be deleted. Although this line is both logged, and implemented, at the same time, which seems strange to me.

Code: Select all

	log(this.ship.exitSystem(jumpChain.route[chainPos]));
I move the "ship" in front of the player for the first wormhole, mainly because it was easier to test. As you can see, I haven't added any useful things to it yet.

Question: when a ship fails to create a wormhole, is there any way to find out why not? I haven't got it to work past 6 or 7 jumps yet, and while that is in no way a bad thing in itself, I don't actually know what the cause is...

Also, feel free to tell me if there's any bad scripting in there, or better ways to achieve the required result! I mainly worked this out to learn, after all...
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

You may want to have some way of checking that the wormhole that the player enters is the one that the device created. At the moment it doesn't seem to discriminate. Indeed with that script active, it will trigger when they pass through any wormhole.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Mauiby de Fug wrote:
Although this line is both logged, and implemented, at the same time, which seems strange to me.

Code: Select all

	log(this.ship.exitSystem(jumpChain.route[chainPos]));
log() is a normal function. In a function call expression, the expressions making up the arguments are evaluated and the result passed to the function. In this case, jumpChain.route[chainPos] is evaluated (retrieving a value from the array), and passed to this.ship.exitSystem(). This returns true, which is then passed to log().
Mauiby de Fug wrote:
Also, feel free to tell me if there's any bad scripting in there, or better ways to achieve the required result! I mainly worked this out to learn, after all...
The values jumpChain and chainPos are declared as vars in global scope, which makes the properties of the global object, which is shared between all scripts. (This is a known deficiency in the JavaScript language itself.) They should either be made properties of this (preferably with a $ or _ in front, as they’re internal), or enclosed in a closure, which looks like this:

Code: Select all

(function () {
var jumpChain;
var chainPos;

this shipSpawned = …
/* rest of code*/
}).call(this);
In this approach, only the code within the anonymous outer function can see the variables, but they continue to exist when the callbacks are called.

You mix PlayerShip with player.ship. The preferred usage is player.ship. Accessing properties of PlayerShip could stop working in future. (Pretend it isn’t there.) In the same way, System.ID should be system.ID.

(PlayerShip and System are the “prototypes” of player.ship and system. In general, the prototype defines methods and properties that are shared by all objects of a certain type. For instance, the Vector3D prototype has the add() method, and every vector inherits it – unless a particular vector is given an add() method of its own. However, you can’t usefully call Vector3D.add() since there’s no actual vector data attached to the prototype. Conceptually, the same is true of PlayerShip, but since there’s only one player ship some of the methods use it directly instead of extracting it from the JavaScript “this” parameter, so calling them on the prototype works. You’ll get bitten if you try to use an inherited method or property, like PlayerShip.position, which is undefined. The situation for System is a bit more complex, but the convention is that you use lowercase system to refer to the current system, and uppercase System for methods that refer to other systems – namely those listed under Static Methods in the wiki.)

Oh, and instead of System.infoForSystem(galaxyNumber, system.ID) you can use system.info (which is the info for the current system).
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16073
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Post by Cody »

I sit and read these ‘technical’ posts, and sometimes a glimmer of comprehension hovers in front of my eyes, the old programmer buried deep in my head stirs and mutters, and I think that I understand… then the mirage dissolves in a puff of anti-logic, and I’m lost again… hey-ho!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8512
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

El Viejo wrote:
I sit and read these ‘technical’ posts, and sometimes a glimmer of comprehension hovers in front of my eyes, the old programmer buried deep in my head stirs and mutters, and I think that I understand… then the mirage dissolves in a puff of anti-logic, and I’m lost again… hey-ho!
I know how you feel! My "proper" programming days are long gone - a bit of bug fixing is all I manage now.
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
drew
---- E L I T E ----
---- E L I T E ----
Posts: 2190
Joined: Fri May 19, 2006 9:29 am
Location: In front of a laptop writing a book.
Contact:

Post by drew »

I was following all the way up to the first bracket.

Cheers,

Drew.
Drew is an author of SF and Fantasy Novels
WebsiteFacebookTwitter
User avatar
Yodeebe
---- E L I T E ----
---- E L I T E ----
Posts: 261
Joined: Mon Oct 13, 2008 7:32 pm
Location: Namab

Post by Yodeebe »

me neither.
i tried it in ROT13, and it made a bit more sense, but not a lot.

Just out of interest though, do those words (in the script) actually do stuff, or are they just names for groups of ... errrr... programming?
Or is it just like a whole language where the words also 'function'?

I don't get how [ship.fly.to.station] makes a ship fly to the station (yay, my 1st oxp? 8) ) . surely it's not exclusive to Oolite?


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

Post by JensAyton »

We really need a tutorial that introduces JavaScript concepts and Oolite scripting as one package. Most of the introductions to JavaScript are either terrible or web-specific (most often both). Unfortunately, I’ve got lots of other things to do in my Oolite time and I’m terrible at explaining things. :-)
User avatar
Yodeebe
---- E L I T E ----
---- E L I T E ----
Posts: 261
Joined: Mon Oct 13, 2008 7:32 pm
Location: Namab

Post by Yodeebe »

don't worry.

i still wouldn't understand anyway. :?
Post Reply