[Announcement] Script using API for automatically loading planet data into the VGAP calculator

« Back to Chat

2797 days, 14 hours, 2 minutes ago
View oliphaunt's profile
oliphaunt
[Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
Two days ago, joshua informed us that an API has been made available.  Like many others, I'm a great fan of the VGAP calculator at http://www.vgaplanets.ca/vgapcalc.php.  I wanted to be the first to write a script that automatically loads planet data from your game into the calculator.

So here it is, still very alpha: "Load Planet Data", http://userscripts.org/scripts/show/121155.
I tested it only in Firefox, but it might work in Chrome as well.

Right now, you have to modify the script's source to add your API key and a specific game ID.  That will get easier soon; I just wanted to publish this before going to bed. :-)  Here's how you obtain an API key (note that you must use http, not https).  If that's a bit too much hassle, I understand; I'll get around to making it easier soon after Christmas.

Any suggestions are welcome! :-)

By the way, as I noted in my comment on the news item, right now the forum doesn't seem to have an appropriate section to publish / talk about user-supplied scripts using the Nu API.

Have fun and good night! :-)
2797 days, 8 hours, 38 minutes ago
View vepr's profile
vepr
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
Hey Oliphaunt.
For the technically challenged among us, can you please post a bit of a more detailed explanation on how to use the script.

i downloaded and installed it, as well as installing greasemonkey.  now what?  how do you add the api key and game id?
2797 days, 6 hours, 49 minutes ago
View oliphaunt's profile
oliphaunt
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
Edit: I've made this a lot easier... stand by.

Hi vepr, thanks for your interest. :-)

I agree, it's still a bit (too) involved.  Also, I've had reports that it doesn't work (yet) in Chrome.

You could wait a couple of days but if you're eager, you can obtain your API key by using e.g. cURL (if you're using a linux distro like ubuntu, there's a package available you can easily install).  Then run on a command prompt:

curl -d username=vepr -d password=secret http://api.planets.nu/login

Once you have that key, you have to edit the greasemonkey script's source.
  1. In Firefox: Tools -> Greasemonkey -> Manage User Scripts...
  2. Right-click "Load Planet Data" and select Edit (or choose Options and then Edit)
  3. Enter your API key and your game ID (usually a 5-digit number) near the top of that file and save.
Now when you go to the VGA Planets calculator, it will load your planet data from the game you selected (look for a cyan box).

Of course you shouldn't have to edit the source, but as I said -- this is alpha.  Hope this makes it work for you! 

Cheers,
oliphaunt
2797 days, 4 hours, 57 minutes ago
View oliphaunt's profile
oliphaunt
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
I just published version 0.2.  No more modifying the source or looking up the API key yourself; you just provide your planets.nu credentials one time.  Also, you can now enter a game ID when you open the calculator to load your planets from that game.  Next up (really after Christmas this time) is to offer a drop-down menu to select a game.

I've still only tested it in Firefox.  Get it here: http://userscripts.org/scripts/show/121155
2797 days, 2 hours, 49 minutes ago
Profile Image
streu
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
oliphaunt:
> I wanted to be the first to write a script that automatically loads planet data from your game
> into the calculator.

Well, if you wanted to be first, I have to disappoint you, because I've been loading stuff from Nu into VGAP tools since August, and had posted a tool to do that a few days before the API (coincidence?) on the utilities thread :-)

It's here. It loads combat into PlayVCR. It does, obviously, not use the API. It requires Perl. I'm not sure yet how I'll continue it.


--Stefan
2797 days, 2 hours, 47 minutes ago
View oliphaunt's profile
oliphaunt
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
Version 0.4 is available.  The script now also works in Chrome and you can switch games (but you still need to enter game ID).  Somehow in Chrome, the first time you fill out the field after loading the page is ignored and you have to enter it a second time.  Not sure yet what's up with that, but just enter your credentials / game ID twice and then it works like a charm.

I'm really postponing further work on this till after Christmas :-)
2797 days, 2 hours, 45 minutes ago
View oliphaunt's profile
oliphaunt
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
Stefan: ah, cool!  You beat me to that :-)

I read about the pcc2 PlayVCR simulator before, haven't yet tried it  This makes it a lot more attractive :-) 
2796 days, 19 hours, 50 minutes ago
View mthomas47's profile
mthomas47
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
You might want to post a little more description of what this actually does, for those of us who don't understand what you are doing. I tried it out and was very pleased with the ease of installation and result but had no idea what was going to happen before doing it. Congrats and let's hope this is the beginning of a whole lot more!
2796 days, 3 hours, 48 minutes ago
View oliphaunt's profile
oliphaunt
RE: [Announcement] Script using API for automatically loading planet data into the VGAP calculatorWrite Reply
Thanks!  And you're quite right about the missing description.

First version of description (which I'll also add at userscripts.org):

The VGA Planets tax & happiness calculator is a great tool for managing and planning the economy of one's space empire.  When using it, I found myself repeatedly switching between the game and the calculator to copy and paste data from one of my planets.

This script (available at userscripts.org) uses the planets.nu API to add functionality to the calculator. After logging in and selecting a game you're involved in, it adds a drop-down selection box for owned planets and then automatically fills in the calculator's fields with data (temperature, #colonists, #structures, natives etc.) from the selected planet.

Any suggestions and feature requests are welcome.  Current wish list: - offer a list of games instead of requiring manual entry of game ID
- load data for hissing ships in orbit around a planet
- search for planets by name or ID