planetinfo.plist problem

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

Moderators: winston, another_commander

Post Reply
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:

planetinfo.plist problem

Post by drew »

I'm trying to get my tianve.oxp to say "Welcome commander..." or similar when you launch from station, or arrive via witchspace...

So far my planetinfo.plist looks like this....
{
"tianve_pulsar" = {
position = "pwm -537195 138382 995170";
radius = 500;
orientation = "1.0 1.0 0.0 0.0";
texture = "tianve_pulsar.png";
seed = "1 2 3 4 5 6";
"polar_color_factor" = 0.2;
"rotational_velocity" = 10;
};


"0 246" = {
"description" = "Tianve is most noted for its famous pulsar, the top tourist attraction in the North East quadrant. Visiting by Liner is recommended, but rental vessels are available as a cheaper option. Tianve is also home to the famous Elite Combateer 'Rebecca Weston' (Details can be found in the Oolite Novella, Status Quo). Zero-Gee Cricket is banned on Tianve at the request of the native feline population.";
"sky_blur_alpha" = "0.85";
"sky_blur_cluster_chance" = "0.55";
"sky_blur_scale" = "25";
"script_actions" = (
debugOn,

"addShipsAtPrecisely: station-pulsar 1 pwm -527974 137501 979090",
"addShipsAtPrecisely: tianveliner-moving 4 pwm 17900 88100 30100",
"addShipsAtPrecisely: tianveliner-moving 4 pwm -17331 88768 88481",
"addShipsAtPrecisely: tianveliner-moving 4 pwm -266833 112575 523650",
"addShipsAtPrecisely: tianveliner-moving 4 pwm -527974 137501 979090",
"addShipsAtPrecisely: tianveliner-moving 4 pwm -527792 127345 1006790",
"addShipsAtPrecisely: trader 15 pwm -546257 138914 1011767",
"addShipsAtPrecisely: shuttle 10 pwm 17100 88593 30457",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 17900 88100 30100",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 17940 88300 30180",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 17980 88500 30260",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 18020 88700 30320",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 18060 88900 30400",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 18100 89100 30480",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 18140 89300 30560",
"addShipsAtPrecisely: tianveliner-stationary 1 pwm 18180 89500 30640",
"addMoon: tianve_pulsar",

{
"welcome_to_tianve" = (
{
conditions = (
"status_string equal STATUS_LAUNCHING"
);
do = (
"commsMessage: Welcome to Tianve, Commander!"
);
}
);
},

debugOff

);
};

}
But the conditional statement doesn't work.. What's wrong?!? The output from stderr is...
2008-10-14 21:43:53.406 oolite.exe[688] [script.debug.syntax.badConditional]: SCRIPT ERROR no 'conditions' in {welcome_to_tianve = ({conditions = ("status_string equal STATUS_LAUNCHING"); do = ("commsMessage: Welcome to Tianve, Commander!"); }); } - returning YES.
Could somebody write me a nested statement that says "Welcome to Tianve, Commander" when you launch or arrive via witchspace?

Cheers,

Drew.
Drew is an author of SF and Fantasy Novels
WebsiteFacebookTwitter
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

This is most simply done with a world script rather than planetinfo.plist. There are specific functions for launching (from anything, you need to add a little check for the main station), for arrival from witchspace and others.

Have a look at the script in the new Famous Planets, that does exactly what you're trying to do (for the Famous Planet systems) and you'll see what I mean.

This page in the wiki covers the scripting handles you need.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

Something like this (change the header info to something more appropriate):

Code: Select all

this.name      = "Tianve_messaging"; 
this.author    = "Thargoid"; 
this.copyright = "© 2008 the Oolite team.";
this.description = "Code for Drew";
this.version   = "1.0";

this.shipWillLaunchFromStation = function(launchStation)
{
  if(launchStation == system.mainStation && system.ID == 246 && galaxyNumber == 0)
  {
  player.consoleMessage("Leaving Tianve main station.",5);
  }		       
}

this.shipExitedWitchspace = function() 
{
  if(system.ID == 246 && galaxyNumber == 0)
  {
  player.consoleMessage("Welcome to Tianve.",5);
  }		       
}
You can either save this as script.js and put it in the config folder of the OXP, or give it whatever name you like (with a .js extension), put it in the OXPs Scripts folder, and then use a WorldScripts.plist in the config folder to point to it.

Tianve is planet number 246, and is in galaxyNumber 0 (ie Galaxy 1, as the count starts from zero).
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Drew, I see no bug in the script. But the condition test will never pass. The planetInfo is only executed when the system is build. That is on loading a saved game and on jumping. Further commsMessage has a distance check. Better replace it with: consoleMessage6s. Than you will get:

Code: Select all

"addMoon: tianve_pulsar",
"consoleMessage6s: Welcome to Tianve, Commander!",
I have not tested it but I think it should work. But doing it with JS as Thargoid suggest is much more flexible. Above code is only sensible if it should also run on Oolite 1.63+
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

So using planetinfo.plist will work on witchspace arrival, but not on station launch (correct?). I think Drew wanted both?

And Eric is correct about the version limitation of the worldscripting, but it's not a very difficult limitation.
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 »

@Eric - Thanks for that! I really need to get my head around the javascript stuff...!

@Thargoid - Great - I'll give that a whirl tonight! Most of the rest of the OXP is working now, so this will be some of the icing on the cake for me.

I just need to get some more player interaction with the stuff that's going on and I'll be ready for a new release.

Thanks for all your help!

Cheers,

Drew.
Drew is an author of SF and Fantasy Novels
WebsiteFacebookTwitter
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 »

Brill! Works a treat!

Just got to get my billboards working and I'm there!

Cheers,

Drew.
Drew is an author of SF and Fantasy Novels
WebsiteFacebookTwitter
Post Reply