Page 2 of 3

Re: planet numbers for missions

Posted: Sat Apr 30, 2011 2:36 pm
by Kaks
If you look inside shipdata.plist, you should find roles = as part of the asp definition. Here I see:

Code: Select all

roles = "hunter pirate asp-pirate";
That means if you do

"addShips: asp-pirate 40"

you should get 40 asp pirates to appear near the witchpoint.

If you did

"addShips: pirate 40"

you'd get 40 assorted pirate ships.

It's always a good idea to give a ship a unique role, othewise the user might get the 'wrong' ships - I believe there's a number of asp variants out there, some tougher than others...

Re: planet numbers for missions

Posted: Sat Apr 30, 2011 8:27 pm
by CheeseRedux
I think you could just cannibalize the script from the Eagle.oxp
Hang on a sec.

There we go:

Code: Select all

{ 
	"0 129" = 
{
			
			"script_actions" = 
(
				"checkForShips: eagle2", 												
{
					conditions = ("shipsFound_number lessthan 150");
					do = ( "addShipsAtPrecisely: eagle2test 15 wpm 0 0 10" );
				}
			);
		};
	
}

That's a planetinfo.plist in the Oxp's main folder.
You'd have to change the 129 (Zaonce) and obviously the ship type (and number) to add.
You might have to tweak or remove the conditions, but other than that it should work.

Disclaimer: I haven't been anywhere near Zaonce since the days of 1.74, so something could have been changed in the code to make this no longer work without me noticing.

Discaimer2: The code is from eagle2.oxp, which has no license file attached. Selezen is still around though.

Edit: cleaned up a typo or two

Re: planet numbers for missions

Posted: Sat Apr 30, 2011 9:49 pm
by Commander McLane
It's really much easier to do in a JS-script than in any plist.

Perhaps an incentive to learn something new, Staer9. :wink:

Re: planet numbers for missions

Posted: Sun May 01, 2011 11:35 am
by Staer9
Commander McLane wrote:
Perhaps an incentive to learn something new, Staer9. :wink:
haha... you at least would know just how long it takes me to learn something, just think back to the Hauler P30, the problem is I have these great ideas, but they come in a chunk so most don't end up working... or work, but only just. JS-script is currently above me

and where exactly should I put this script?

Re: planet numbers for missions

Posted: Sun May 01, 2011 6:13 pm
by Commander McLane
Staer9 wrote:
and where exactly should I put this script?
Which? The one posted by CheeseRedux?
CheeseRedux wrote:
That's a planetinfo.plist in the Oxp's main Config folder.
Copied with correction.

Step-by-step:
You should already have a folder named 'Config' in your OXP. That's where you have put the shipdata.plist and shipyard.plist (if any). In that same folder you need another text file named 'planetinfo.plist'. The contents of that file is what CheeseRedux posted above.

Re: planet numbers for missions

Posted: Sun May 01, 2011 6:25 pm
by CheeseRedux
Gotta correct your correction there, McLane: The planetinfo.plist from eagle2.oxp sits squarely in its main folder. I freely admit I've no clue if that's where it's supposed to sit, though. It is what it is, however, and as witnessed by all the distraught players who have come to the forum wondering why they always get jumped by a bunch of Eagles when going to Zaonce, its location has not hindered its proper execution.

Re: planet numbers for missions

Posted: Sun May 01, 2011 6:41 pm
by Commander McLane
CheeseRedux wrote:
Gotta correct your correction there, McLane: The planetinfo.plist from eagle2.oxp sits squarely in its main folder.
You're right, it does sit there (just checked). However, it doesn't belong there, but inside Config, if only for clarity.

Wild guess: Oolite would recognize all relevant files in a main folder (AIs, plists, textures, models, images, JS-scripts). The sub-folder structure of an OXP (and of Oolite/Contents/Resources, for that matter) is purely for convenience and tidiness. But since we have it, why not use it?

Re: planet numbers for missions

Posted: Mon May 02, 2011 10:07 am
by Staer9
just tested it with this code:

Code: Select all

{
   "0 45" =
{
         
         "script_actions" =
(
            "checkForShips: asp",                                     
{
               conditions = ("shipsFound_number lessthan 150");
               do = ( "addShips: asp-pirate 40" );
            }
         );
      };
   
}
it didn't work

Re: planet numbers for missions

Posted: Mon May 02, 2011 11:23 am
by Eric Walch
Staer9 wrote:
just tested it with this code:
....
it didn't work
It should work. Because a ship with role 'asp' does not exist, the script should than always return '0' and thus always add the pirates. But what I don't understand is why you check for a 'asp' in the first place? It would make more sense to just write:

Code: Select all

{
   "0 45" =
{
         
         "script_actions" =
         (
                 "addShips: asp-pirate 40"
         );
      };
   
}
The only reason for counting ships in planetInfo is to prevent double additions when the player adds two copies of the oxp to the addOn folder. But than you should at least count the ships you intend to add and not any other ship.

Re: planet numbers for missions

Posted: Mon May 02, 2011 12:09 pm
by Kaks
One other thing to bear in mind is that you might be checking for a different planet to the one you've just jumped in! Internally planet numbers & galaxy numbers always start with 0, however some charts start with the more human-compatible 1, which shifts all planet numbers by one!


Using the js console, I got this info for you:

> System.systemNameForID(45)
Socelage

> System.systemNameForID(44)
Esesla

Hope it's useful.


PS: just one more thing: use the Force, Luke! :P
Since we got the js console working on all platform, just about any OXP maker has been finding it extremely useful for debugging their own OXPs! ;)

Re: planet numbers for missions

Posted: Mon May 02, 2011 1:01 pm
by another_commander
Kaks wrote:
PS: just one more thing: use the Force, Luke! :P
Since we got the js console working on all platform, just about any OXP maker has been finding it extremely useful for debugging their own OXPs! ;)
This. In my opinion, anyone writing OXPs and not using the JS Debug Console are just making lives hard for themselves.

Also, I fully recommend completely dropping the backwards legacy scripting style. The time spent on learning the basics of JavaScript is time well spent and will pay off at the long term, since there is just so much one can do with JS that legacy can't even begin to imagine.

Re: planet numbers for missions

Posted: Mon May 02, 2011 2:04 pm
by Switeck
This code was made for something in Galaxy 8, at systems near Oresrati (whose system.ID = 162). But I'll toss in some other stuff just to hopefully make this useful to you.
&& = and
|| = or
() works the same in if statements as it does for algebra.
Basically the if statement says:
If the system's sun exists (= true) AND in galaxy 8 AND in either system 121 OR 9 AND there's fewer than 2 asp-pirate ships already...
Then add 40 asp-pirate ships around the witchpoint beacon (location 0 along the route). Location 1 along the route would probably be touching the planet's surface.

Code: Select all

this.shipWillLaunchFromStation = this.shipExitedWitchspace = function()
{
// galaxyNumber starts at 0 = galaxy 1, so 7 = galaxy 8
// the system.ID number should be: 121 = Aatedire  ...but 9 may not be Leater!
	if(system.sun  && galaxyNumber == 7 && (system.ID == 121 || system.ID == 9) && system.countShipsWithRole("asp-pirate") <2)
	{
		system.addShipsToRoute("asp-pirate", 40, 0); // to be right near the witchpoint buoy
	}
}
You could instead use:
system.addGroupToRoute("asp-pirate", 40, 0, "wp");
...If you wanted them to fight together as a more organized group, as opposed to 40 lone ships.

Re: planet numbers for missions

Posted: Mon May 02, 2011 5:51 pm
by Staer9
Kaks wrote:
Using the js console, I got this info for you:

> System.systemNameForID(45)
Socelage
ARHHHH so therefore the question I was asking at the begining STILL hasn't been answered and the wiki is therefore incorrect. All I want to know is what number reidquat is, and if it isn't 45 (which the wiki says it is) then what is it???

@switeck, that was helpfull, but what do I call it and where do I put it (in the oxp folder) if I change galaxy to 1 and planet to riedquat (whatever number it is)

Re: planet numbers for missions

Posted: Mon May 02, 2011 5:59 pm
by Smivs
Hi Stear9, try this.

Code: Select all

// Standard attributes 
this.name           = "spawn-asps_script"; 
this.author         = "Smivs"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0"; 
this.description    = "Script to spawn 40 asps on exiting witchspace at Riedquat." 

// Configuration
this.role = "asp-pirate"; 
this.count = 40;

this.shipWillExitWitchspace = function() 
{
   if (galaxyNumber == 0 && system.ID == 46)
        {
        system.addShips(this.role, this.count, player.ship.position, 10000);
        }
};
I think it wasn't helping that you've got the wrong planet number - Riedquat is 46 not 45.

It won't just work if placed in AddOns as it is. Place it in a folder called 'Scripts', and then in the Config folder, add a world-scripts.plist like this

Code: Select all

/*
   asps
*/
( 
   spawn-asps_script.js
)
so if you just want to try it (it does work!) make an OXP. A folder called 'asps.oxp' or whatever containing a Config folder with the worldscripts.plist, and a Scripts folder containing the 'spawn-asps_script.js'.

Re: planet numbers for missions

Posted: Mon May 02, 2011 6:17 pm
by Staer9
Thank you so much Smivs :D

by the look of it that is script.js rather than planetinfo.js so I will move it and test it.
I also added an extra line so it should write in the log the "Generated 40 asps for commander testing purposes"

presumably that goes in the Config folder of the oxp