|Here's an add-on for the coders and those familiar with the objects returned by the API. It adds a filtering mechanism to the ship/planet/base list to find matches based on arbitrary criteria you provide. Very powerful, but a little dangerous too. Be very careful, and know what you are doing, it is quite possible to screw things up (since we're running the code you put in), ie. if you enter:|
return ship.mission = "HYP";
return ship.mission == "HYP";
you will likely set all of the FCs for all of your ships to HYP, which may not be what you intended.
Maybe test it out on some finished games or games where possibly having to reset the turn is not a big deal. I'd like to put in a method to save preset filters, but for now you have to type them in.
Anways, here's the notes I included with the script, which hopefully explain how to use it somewhat:
1. Adds a "Filter" checkbox and textarea to lists. When the checkbox is checkedhttp://userscripts.org/scripts/show/132440
the code in the textbox will be run to evaluate each item for inclusion on
the filitered list, as follows:
which takes one parameter (ship, planet, or starbase respectively) and
returns a value which can be evaluated as a boolean represnting inclusion.
Example, ship filter, filters all ships with FC equivalent to "HYP":
return ship.friendlycode.toUpperCase() == "HYP";
Example, planet filter, filters all planets able to build a base:
return (planet.duranium >= 120 && planet.tritanium >= 402 &&
planet.molybdenum >= 340 && planet.megacredits >= 900 &&
!planet.buildingstarbase && vgap.getStarbase(planet.id) == null);
Example, starbase filter, filters bases with no ships in orbit:
planet = vgap.getPlanet(starbase.planetid);
return vgap.shipsAt(planet.x, planet.y).length == 0;
2. When a filter is active, the "back" and "next" controls on the map
will only iterate through the filtered set. All/idle will be selected
on the filtered set as well.