Ogame In-flight Resources

By Oliver Jensen Last update Jul 24, 2009 — Installed 1,046 times.

Doesn't work properly

in
Subscribe to Doesn't work properly 14 posts, 3 voices



Vess Scriptwright
OperaWindows

To begin with, something is wrong with the format. In my case, the title "Deuterium" in the table header, as well as the number for it in the table, is not in a third column to the right but under "Metal". I guess something is wrong with the computation of the table width. But this is the minor problem.

The big problem is that the script does not take into account the resources in all flying fleets. Why are you looking only at the object class "flight"? The fleet classes "holding", "return" and probably others can carry resources too!

For a much more sophisticated script of this kind (does everything but takes out the cat), see this one:

http://userscripts.org/scripts/show/42338

Still, don't get discouraged - yours is short and sweet; I'd much rather see it fixed to work properly; no need for the extra features that other script provides.

P.S. OK, the table width problem is easily fixed - when computing "width", subtract 10 instead of 6.

However, the general logic of the script is horribly buggy. :-( Not only it doesn't account for the resources on the returning fights - sometimes it fails to calculate even the resources of the outgoing flights! I'm not sure exactly when it happens - in my case it was showing the resources on the outgoing flights just fine, until I launched an expedition fleet. Perhaps you should parse a different class element (owndeploy, owntransport, etc.). Tell me, if there is anything I can do to help you debug and fix the script.

 
Vess Scriptwright
OperaWindows

OK, I see what the problem is.

By doing

var flights = document.getElementsByClassName ('flight');

you expect to get both elements like

<tr class='flight'>

and ones like

<span class='flight owndeploy'>

Furthermore, you expect that they always come in pairs and that the second one has always 5 "a" elements, and that the last one contains information about the carried resources. Sadly, these assumptions are wrong.

First of all, an ougoing expedition has only 4 "a" elements. This screws up the logic and the script aborts when it tries to access the 5th element. This can be fixed by using


if (flights [i].getElementsByTagName ('a').length < 5)
continue;
else
var title = flights [i].getElementsByTagName ('a') [5].title;

instead of

var title = flights [i].getElementsByTagName ('a') [5].title;

Unfortunately, this still doesn't solve the other problem - that a returning fleed might carry resources. You'll need another loop for class "return" - and will have to figure out how to parse these elements both when there are and when there aren't any carried resources.

I suggest that you do *very* thorough testing - with *all* kinds of flights (espionage, colonization, harvest, transport to self, transport to somebody else, transport from somebody else, attack, deploy, ACS-Attack, ACS-Defend, expedition, etc.), both outgoing, returning and holding (when appropriate), both with and without resources. Until you've tested all the possible combinations, there is significant probability that there are more bugs in the script and it will fail in unexpected ways.

 
Oliver Jensen Script's Author
MozillaX11

Thanks for the report! I had only tested it ‍with transport missions as i must admit i've been neglecting my ogaming and haven't sent out an attack fleet in a while. I'll get right on this :)

 
Vess Scriptwright
OperaWindows

OK, I think I got it to work properly now. If you give me some e-mail address, I'll send you my version of it.

One remark: if you meant to list the resources by mission type (e.g., Transport, Harvest, Deploy, etc.), you're doing the wrong way.

var type = elements[0];

will always return "Transport". To get the mission type properly, use

var type = flights [i].getElementsByTagName ('a') [4].innerHTML;

instead. (I also find it useful to prepend ">" or "<", depending on whether this is an outgoing - "flight" - or returning - "return" - mission.)</p> <p>If you do this, though (separate the resources by mission type), you also need to insert one additional row, for the totals. This is all done in my "local" version of your script.

There are a couple of other things I'd like to see done - but I couldn't figure out how to do them myself:

1) The whole table is centered - this is the style that OGame uses. Would be nice if only the cells that contain the numbers corresponding to the carried resources, are right-aligned.

2) I'd prefer to see the whole table with the resources in flight moved to the bottom of the main table, instead of being at the top. After all, the information about the flights is more important. I tried to insert it at table.rows.length - but it didn't work. I guess I should try some magic with appendChild instead of insertRow...

 
Oliver Jensen Script's Author
MozillaX11

Hi

Thanks! My address is ojensen@students.colgate.edu

I thought it'd be better at the top as there will be relatively few lines of it, whereas there can be lots of lines of fleets. However, if we stick it at the bottom, we can make it a separate table. This means that we can put each resource into a separate table cell (we couldn't before as the 4th cell's width is defined by the cell with the pictures of all your planets and is way too big) which will solve all the align issues and make the thing look better anyway.

 
Vess Scriptwright
OperaWindows

Sent. I'm afraid I don't understand your comment about having to put it in a separate table at the end, in order to change the column format. The other script that I pointed you to (that shows the resources in flight) manages to present a rather sophisticatedly formatted table between the "Events" row and the flights. It even opens and closes at the click of a mouse - try it and you'll see what I mean. (I still like yours, though. It's shorter, faster, and practically language-independed without having to provide multi-language translation inside.) I think it achieves this by creating a separate "span";

 
pincopallino Scriptwright
FirefoxWindows

could you modify the script so as to display all the incoming? (transport, attack, collection (i use google translate riciclare, i don't know the traduction.), etc..)

 
Vess Scriptwright
OperaWindows

pincopallino, no need for translation - except for the title ("In-flight resources"), the script is language-independent.

Yes, he does have to display the resources of all returning and holding fleets - not just the outgoing ones. I've sent him a version that does that - all he has to do is incorporate the changes to his script.

 
pincopallino Scriptwright
FirefoxWindows

i didn't tell about the translation, i told about my english, i don't know the english for "reciclare"

well, where is the script modify??

 
Vess Scriptwright
OperaWindows

pincopallino, sorry I misunderstood you. The English word you're looking for (well, the one OGame is using anyway) is "harvest".

The script doesn't really have to recognize the flight type explicitly - this is done sort of automatically from the information about the flight. Currently, the problem of the script is that it examines only the outgoing flights (of any type) and that it expects any such flight to contain at least 5 "a" elements. What has to be done is make the script examine also the "returning" and "holding" flights (since they can carry resources too) and to skip over the flights that have less than 5 "a" elements (they don't carry any resources anyway).

As for why the author hasn't posted a corrected version of the script yet - perhaps he's busy with other things. Have some patience. :-)

 
pincopallino Scriptwright
FirefoxWindows

o yes, but this script is really useful, I miss so many minutes to calculate all the resources that I come from attacks and transport ...

 
Vess Scriptwright
OperaWindows

OK, pincopallino, while we're waiting for Oliver to fix his script, I've made my version available on-line. Does it do what you want?

 
Oliver Jensen Script's Author
FirefoxX11

Apologies for taking so long. Thanks for the script, Vess. I've updated it to your version. For the moment I've left the columns center-aligned, but may change that soon.

 
Vess Scriptwright
OperaWindows

OK, I figured out how to put the information in a sub-table, so that the numbers can line up. I've also improved the code a bit. See the latest version.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel