These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Assistance with google sheets script required

First post
Author
Slarti Bart Fast
Pure Victory
#1 - 2015-06-30 12:11:57 UTC
I am having issues with a google script on my spreadsheet.
The script pulls in BPOs/BPCs owned by a character or corp.
The script itself works fine, but I would like to have it sort the Blueprints by name - It currently seems totally random.
If I try in the sheet to sort by name ( Data >>> Sort by OR Data >> sort range), then it works for a fraction of a second, and then rearranges itself.
I figure the best way to fix this would be to edit the script itself, but have no idea where to put the sorting code.

Here is the current, working script.

/*
Call this function like:
=loadBlueprints("corp",4324234,"7okqZ1gOyG43243243242342qb2wkyd21C",90926985)
and get all your blueprints loaded into the sheet. I'd suggest doing it on a blank sheet,
rather than in a sheet you have useful information on.
It's 'blueprint ID','location ID','Typeid of blueprint','name of blueprint','which hangar it's in',
'quantity. -2 for a BPC, -1 for a BPO, a number for stacked BPOs',TE,ME,'runs, -1 for a BPO'
*/
/**
* Creates a table of information on blueprints retrieved from the EVE API.
* @param {string} type This should be set to "char" or "corp" depending on the type of API key in use.
* @param {number} keyID This should be set to the keyID given by your API key.
* @param {string} vCode This should be set to the verification code given by your API key.
* @param {number} characterID This should be set to the specific character for which you would like to retrieve the blueprint data.
* @returns A table with information in the following order: 'blueprint ID','location ID','Typeid of blueprint','name of blueprint','which hangar it's in', 'quantity. -2 for a BPC, -1 for a BPO, a number for stacked BPOs',TE,ME,'runs, -1 for a BPO'
* @customfunction
*/
function loadBlueprints(type, keyID, vCode, characterID){
  var blueprints= new Array();
  var url = "https://api.eveonline.com/"+type+"/Blueprints.xml.aspx?keyID="+keyID+"&vCode="+vCode+"&characterID="+characterID;
  var parameters = {method : "get", payload : ""};
  var xmlFeed = UrlFetchApp.fetch(url, parameters).getContentText();
  var xml = XmlService.parse(xmlFeed);
 
  if(xml) {
    var rows=xml.getRootElement().getChild("result").getChild("rowset").getChildren("row");
    for(var i = 0; i < rows.length; i++) { 
      blueprint=[
                 rows[i].getAttribute("typeName").getValue(),
                 rows[i].getAttribute("quantity").getValue(),
                 rows[i].getAttribute("materialEfficiency").getValue(),
                 rows[i].getAttribute("timeEfficiency").getValue(),                 
                 rows[i].getAttribute("runs").getValue()]
      blueprints.push(blueprint);
    }
  }
return blueprints;
}



Any assistance would be greatly appreciated.
Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#2 - 2015-06-30 16:04:59 UTC
two options. either sort the blueprints array before you return it, or

=sort(loadBlueprints(all the stuff you'd normally put in),column to sort on,true)

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter

Slarti Bart Fast
Pure Victory
#3 - 2015-06-30 16:12:48 UTC
Steve Ronuken wrote:
two options. either sort the blueprints array before you return it, or

=sort(loadBlueprints(all the stuff you'd normally put in),column to sort on,true)


perfect.
Worked like a charm using the =sort(loadBlueprints(XXXXXXXXXXXX),1,true)

Thankyou very much ;)