Page 49 of 119
Re: Scripters cove
Posted: Fri Jul 13, 2012 4:40 pm
by Thargoid
Replace vectorForward with either vectorRight or vectorUp. vectorForward is along the Z-axis (around which the station rotates anyway), so a rotation there won't help. But a rotation of Pi radians (aka 180 degrees) around either of the other two should do what you want.
Re: Scripters cove
Posted: Sat Jul 14, 2012 5:30 am
by Wildeblood
That worked a treat. Thank you, Thargoid.
Re: Scripters cove
Posted: Sun Jul 15, 2012 11:42 am
by BuggyBY
Thargoid wrote:Replace vectorForward with either vectorRight or vectorUp. vectorForward is along the Z-axis (around which the station rotates anyway), so a rotation there won't help. But a rotation of Pi radians (aka 180 degrees) around either of the other two should do what you want.
Shouldn't a 180 degree rotation point the ship back into the docking bay?
Re: Scripters cove
Posted: Sun Jul 15, 2012 12:30 pm
by Thargoid
He was spinning the station about (before launch), not the launching ship.
Re: Scripters cove
Posted: Mon Jul 23, 2012 2:34 am
by Wildeblood
Thargoid wrote:He was spinning the station about (before launch), not the launching ship.
Priority Launch READ ME wrote:Place the Priority Launch OXP into your "AddOns" folder. At the main stations of planets with technical level 4 or higher, the station master will - for a small fee - re-align the space station to allow you an unimpeded launch in a direction away from the planet, directly into deep space. Station re-alignment takes 15 minutes of game time, but happens immediately for the player (similar to instant docking, which takes 20 minutes of game time).
This is quite handy for getting screen-shots of the station with the planet in the background, as well as for when I'm just being impatient. The next step to making it a polished OXP is making sure it only appears in the F3 screen at main stations, not at OXP stations. Is there a condition I can put in the equipment definition, or do I have to mess around giving it a script-changed tech level, and if the latter, how do I do that?
Re: Scripters cove
Posted: Mon Jul 23, 2012 5:25 am
by Thargoid
You can use conditions in Equipment.plist to achieve that. Specifically "conditions" = ( "dockedAtMainStation_bool equal YES" );
will limit it to main station only (you can limit the tech level in the normal way by the equipment's tech level, or alternatively with "systemTechLevel_number morethan 3"
as an additional condition above). You can set multiple conditions in the array in the normal way, just comma-separate them.
It's coded in legacy scripting there (more full details are on this page on what is available). As yet that is the only way to do it for such conditions (in equipment and also in shipdata.plist conditions) but that may well be updated soon.
Links are to Maik's backup wiki as the main one is still down.
Re: Scripters cove
Posted: Mon Jul 23, 2012 8:35 am
by Wildeblood
Thanks again, Thargoid. I've added Priority Launch to my
cutesy tweaks list.
Re: Scripters cove
Posted: Thu Jul 26, 2012 9:52 am
by Smivs
Quick question...using this code in a worldscript (to add a station of sorts), how do I align it so the dock is facing the sun?
Code: Select all
system.addShipsToRoute(this.role2, this.count1, 0.8, "ws");
Re: Scripters cove
Posted: Thu Jul 26, 2012 11:38 am
by Commander McLane
Code: Select all
// next line spawns the entity and puts it in a local variable 'myShip'
var myShip = system.addShipsToRoute(this.role2, this.count1, 0.8, "ws")[0];
// next line sets up a vector myShip --> sun
var targetVector = system.sun.position.subtract(myShip.position).direction();
// next line aligns the heading to the targetVector by rotating
myShip.orientation = targetVector.rotationTo(new Vector3D(0,0,1));
Re: Scripters cove
Posted: Thu Jul 26, 2012 12:05 pm
by Smivs
Thank you

Re: Scripters cove
Posted: Sun Jul 29, 2012 9:27 am
by Pleb
I'm trying to switch the AI of all ships in the system that have a particular role but am not having much luck.
Code: Select all
//Switch AIs on VirgoTech Inc. ships to attack Player:
this._virgotechShipsArray = system.shipsWithRole("virgotech_defender");
var i = 0;
var count = this._virgotechShipsArray.length;
for (i=0; i<count; i++)
{
this._virgotechShipsArray[i].setAI("traitor_pirateAI.plist");
}
Does anyone know where I'm going wrong? This only makes one ship change its AI but the rest are the same...

Re: Scripters cove
Posted: Sun Jul 29, 2012 9:54 am
by Commander McLane
Your code should be fine, and it's working here.
One suggestion, though: if you want to change the ships' AI
permanently,
switchAI()
is what you're looking for.
setAI()
only adds the new AI on top of the current AI which is pushed to the AI stack. Thus the next
exitAI
command in your new AI will take the ship back to its original AI.
switchAI()
on the other hand erases the AI stack, making it impossible for the ship to fall back to its original AI.
Re: Scripters cove
Posted: Sun Jul 29, 2012 10:18 am
by Commander McLane
Okay, here's a tricky one: is there a way to transfer information across a
startUp
event?
What do I want to do? There are several ways for the Asteroids3D-minigame to end:
- The player can destroy all the objects = game successfully ended;
- The player can dock while there are still objects left = game abandoned;
- The player can jump out while there are still objects left = game abandoned;
- The player can be killed during the game = new start at the last save game.
Asteroids3D.oxp has code to deal with the first three cases. For each case an appropriate mission screen is shown on next docking.
My question is: is it possible to show a mission screen in the last case as well? This means that the JS-engine somehow would have to know that the last player death did not occur during normal game play, but during an Asteroids3D-minigame. However, the
startUp
event removes all traces of what has happened before, clearing all variables, removing all objects and creating the Ooniverse anew from scratch. That's what it has to do, of course. But is it possible to circumvent this in any way for this special case? One possible way is not viable: I do
not want the player to save their game after starting the Asteroids3D-minigame, and I absolutely don't want to
force a save upon them. So I cannot use a
missionVariable
.
I don't see a solution to this (very special, I admit) problem, but perhaps one of you very clever people does?
Re: Scripters cove
Posted: Sun Jul 29, 2012 4:47 pm
by Svengali
Commander McLane wrote:Okay, here's a tricky one: is there a way to transfer information across a startUp
event?
If I get this right the only thing you can check is the player.ship.status. It is not failsafe though as the status changes.
Code: Select all
if(player.ship.status==='STATUS_DEAD') ...
Re: Scripters cove
Posted: Sun Jul 29, 2012 6:23 pm
by JensAyton
Commander McLane wrote:Okay, here's a tricky one: is there a way to transfer information across a startUp
event?
If so, it’s a bug.