I want to move the player ship via .js - SOLVED
Moderators: winston, another_commander
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
I want to move the player ship via .js - SOLVED
... how do I do that?
Had a look at Frame's save anywhere but did not become any wiser because of it, and couldn't find the old solar systems concept study any more.
Would be happy if someone helped me out
L
Had a look at Frame's save anywhere but did not become any wiser because of it, and couldn't find the old solar systems concept study any more.
Would be happy if someone helped me out
L
Last edited by Lestradae on Fri Aug 28, 2009 12:17 pm, edited 1 time in total.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Code: Select all
player.ship.position = system.sun.position; // For example
E-mail: [email protected]
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
What is probably equal toAhruman wrote:Code: Select all
player.ship.position = system.sun.position; // For example
Code: Select all
player.ship.temperature = player.ship.maxTemp * 10 000
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Look at the planetfall script. I do that very thing on launch from the temporary station.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
...
Eric Walch wrote:What is probably equal toAhruman wrote:Code: Select all
player.ship.position = system.sun.position; // For example
Code: Select all
player.ship.temperature = player.ship.maxTemp * 10 000
You people are evil
Edit: Is this the new trumble recipe? "Do this and we promise you will never, ever have troubles with trumbles again"
@T: Thanks, will have a look into the planetfall script then!
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
..
OK, so I don't get it.
If I write a .js that goes like this:
... that should move any docked ship 10 kms away from any dockable object, into the launch direction - shouldn't it?
L
If I write a .js that goes like this:
Code: Select all
this.shipWillLaunchFromStation = function()
{
let launchPosition = player.ship.position.add(launchVector.multiply(10000));
this.setPos(player.ship,launchPosition);
}
L
They're in my planetfall scripting, defined elsewhere in it.
You've been a little too specific in your borrowing
You've been a little too specific in your borrowing
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
..and setPos is used there to make the oxp compatible with both 1.72 & 1.73 at the same time.
You could definitely have borrowed from another part of planetfall.
If you're not bothered by 1.72 compatibility, something that should work ok when 1.73 is released is:The code above should magically move your ship 10 m forward, in the direction you're facing.
If you keep using launchVector as defined inside planetfall, you'll always move directly away from the planet, no matter where you are, no matter what direction you're facing.
L, I suggest you read & reread the vector3d & quaternion pages on the wiki (accessible via this page) until they start to make sense.
It's really easy to get lost with this stuff otherwise!
Hope this helps
Kaks
You could definitely have borrowed from another part of planetfall.
If you're not bothered by 1.72 compatibility, something that should work ok when 1.73 is released is:
Code: Select all
player.ship.position=player.ship.position.add(player.ship.orientation.vectorForward().multiply(10))
If you keep using launchVector as defined inside planetfall, you'll always move directly away from the planet, no matter where you are, no matter what direction you're facing.
L, I suggest you read & reread the vector3d & quaternion pages on the wiki (accessible via this page) until they start to make sense.
It's really easy to get lost with this stuff otherwise!
Hope this helps
Kaks
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
.
What I still don't get:
... does not move the ship 8 kilometres forward at launch.
I am on trunk SVN 2309 currently. There is no error entry in the log that the vector properties would be undefined. I assume that the length of the vector are the 8000 and that the "vectorForward" part tells the direction already (? ... or not?) that could also be defined via Vector3D or Quaternion coordinates - correct?
Or do I still have to define these coordinates for the above and therefore have to define the "launchVector"?
I am really puzzled as to what is java script, what is Oolite's internal "function call" methods and what are variables that T has defined for his planetfall ...
L
Code: Select all
this.shipWillLaunchFromStation = function()
{
player.ship.position = player.ship.position.add(player.ship.orientation.vectorForward().multiply(8000))
}
I am on trunk SVN 2309 currently. There is no error entry in the log that the vector properties would be undefined. I assume that the length of the vector are the 8000 and that the "vectorForward" part tells the direction already (? ... or not?) that could also be defined via Vector3D or Quaternion coordinates - correct?
Or do I still have to define these coordinates for the above and therefore have to define the "launchVector"?
I am really puzzled as to what is java script, what is Oolite's internal "function call" methods and what are variables that T has defined for his planetfall ...
L
-
- Quite Grand Sub-Admiral
- Posts: 6671
- Joined: Wed Feb 28, 2007 7:54 am
shipWillLaunchFromStation should be ok in general, that's where I do it for Planetfall (for a similar job, or else you launch to just in front of the station and then visibly move, which looks rather odd.
I think the problem might be that vectorForward() may not yet be defined in this case. When I do it I'm not using that, but a specifically defined vector from the planet I landed on to the player position.
Try adding
Or a log equivalent (replace player.consoleMessage with log) and see if the vector is defined. I get the feeling it may not be, hence you're moving the player by 8km * 0, hence they're going nowhere.
I think the problem might be that vectorForward() may not yet be defined in this case. When I do it I'm not using that, but a specifically defined vector from the planet I landed on to the player position.
Try adding
Code: Select all
player.consoleMessage("Vector forward = " + player.ship.orientation.vectorForward() );
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
..
OK guys, solved it!
Actually, the handler change suggested by A_C did the trick. Now all is working as intended, and I am happy to report that the OSE transfer shuttle for ships too big to dock convincingly is in!
Now there are no NPCs crash-docking any more, and players with carriers have the transfer shuttle. Can't believe all solved now. Was only possible via the help of many people here - T's & Eric's bigShips script for traders, Eric's advice as to give GalCop carriers the hunter role to stop them from docking/launching too, and now without Frame, Thargoid, Kaks & another_commander and the people who put "targetStation.dockPlayer()" into the trunk the transfer shuttle wouldn't have been possible.
Thanks everyone!
The transfer shuttle as equipment now looks like this:
... its preinstalled on the real monster ships such as Dredgers ...
and the finished and working transfer shuttle script now reads:
Cheers
L
Edit: Forgot to mention, the carrier "releases the transfer shuttle" aka docks via requesting docking clearance!
Actually, the handler change suggested by A_C did the trick. Now all is working as intended, and I am happy to report that the OSE transfer shuttle for ships too big to dock convincingly is in!
Now there are no NPCs crash-docking any more, and players with carriers have the transfer shuttle. Can't believe all solved now. Was only possible via the help of many people here - T's & Eric's bigShips script for traders, Eric's advice as to give GalCop carriers the hunter role to stop them from docking/launching too, and now without Frame, Thargoid, Kaks & another_commander and the people who put "targetStation.dockPlayer()" into the trunk the transfer shuttle wouldn't have been possible.
Thanks everyone!
The transfer shuttle as equipment now looks like this:
Code: Select all
<array>
<integer>0</integer>
<integer>500000</integer>
<string>Transfer Shuttle</string>
<string>EQ_SHUTTLE</string>
<string>A transfer shuttle that can be used as a ferry for the Commander, crew and cargo of vessels which are too big or impractical to dock at stations or other carriers in the conventional way. Your carrier will be parked a few kilometres away, awaiting your return.</string>
<dict>
<key>available_to_all</key>
<true/>
<key>requires_cargo_space</key>
<integer>600</integer>
</dict>
</array>
and the finished and working transfer shuttle script now reads:
Code: Select all
this.name = "Transfer Shuttle Script";
this.author = "Frame, Lestradae & some help from Thargoid, Kaks & another_commander";
this.copyright = "All";
this.description = "Enables the player to dock player carriers at any station or NPC carrier with an intermediate Transfer Shuttle";
this.version = "0.1";
this.shipLaunchedFromStation = function()
{
if(player.ship.hasEquipment("EQ_SHUTTLE"))
{
player.commsMessage("Commander " + player.name + ", your transfer shuttle has been released from its docking clamps and is ready for liftoff. Have a safe journey to your carrier.");
player.ship.position = player.ship.position.add(player.ship.orientation.vectorForward().multiply(4000))
}
}
this.playerRequestedDockingClearance = function()
{
if(player.ship.target) //no target no game, so it needs only to be in scanner range
{
this.targetStation = player.ship.target
if(player.ship.hasEquipment("EQ_SHUTTLE"))
{
player.commsMessage("Commander " + player.name + ", your transfer shuttle has been given docking clearance. Have a pleasant flight and please dock in the appropriate hangar section.");
this.targetStation.dockPlayer();
}
}
}
L
Edit: Forgot to mention, the carrier "releases the transfer shuttle" aka docks via requesting docking clearance!
i would make the EQ_SHUTTLE less generic and call it EQ_LESTRADAE_SHUTTLE though
Bounty Scanner
Number 935
Number 935
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
I would also remove the "available_to_all" in the equipment definition.Frame wrote:i would make the EQ_SHUTTLE less generic and call it EQ_LESTRADAE_SHUTTLE though
Code: Select all
<array>
<string>Transfer Shuttle</string>
<string>EQ_SHUTTLE</string>
<dict>
<key>available_to_all</key>
<true/>
<key>requires_cargo_space</key>
<integer>600</integer>
</dict>
</array>
UPS-Courier & DeepSpacePirates & others at the box and some older versions