Post doesn't exist
Still buggy
|
|
Sadly, this version doesn't work at all. :-( After some debugging, I traced the problem to the following: Replace for (var i in values) with for (var i = 0; i < 3; i++) Also, don't forget that the user could be playing in more than one universe. Currently, the cookie stores the coordinates of each planet and its resource production - but it doesn't store the server/universe. This could lead to errors, if the player has planets at the same coordinates in different server/universes. |
|
|
Another problem is that the ticker doesn't tick when the Resources page is being viewed - although I couldn't figure out why not. (It resumes ticking when anything else is being viewed and, yes, it handles moons correctly.) |
|
|
the reason my for loop only goes to 3 is because we want to exclude dark matter and energy. The universe thing is valid, and affects all of my scripts, so that'll be an update I need to do. All of these issues also affect the other script, right? |
|
|
I'm not sure what you mean by "all these issues" and "the other script". The cookie not storing the server/universe - yes, this affects your other scripts; sorry that I didn't think about it earlier. The incorrect "for" loop is a bug, which exists only in this script (and prevents the script from working at all). The other version (that updated the resources by 1 whenever possible) didn't have this problem and worked (although screwed up the timers of the flights). The cookie thing is not so important (how often would a player have planets at the same coordinates in different server/universes?) and can wait but the for loop really needs to be corrected ASAP. The tickers not ticking on the Resources page - yes, I think this problem also existed in the other version. Would be nice to have it fixed - but I couldn't determine where the bug is, so I can't help, sorry. setInterval *does* make incrementRes to be called even on the Resources page (I checked), so I don't know why the resources are not incremented there... |
|
|
What happened after you reach storage limit? :P And do you know about GM_setValue / GM_getValue API? Some code snippets which should help:
// Get universe number.
MatchTab = location.href.match('uni([0-9]{1,2}).');
var uni = MatchTab[1];
// Get planet [G:S:P].
var opt = document.getElementsByTagName ('option');
for (var i=0; i<opt.length; i++)
{
if (opt[i].selected)
{
var coord = opt[i].innerHTML.substr ( (opt[i].innerHTML).indexOf ("[") );
MatchTab = coord.match('([0-9]{1}):([0-9]{1,3}):([0-9]{1,2})');
var Coord_g = MatchTab[1];
var Coord_s = MatchTab[2];
var Coord_p = MatchTab[3];
break;
}
}
|
|
|
Andorian (hi!) is right - the ticker keeps ticking after the storages are full. In order to fix this, you have to take the maximum capacity of each kind of storage and save it in a cookie. Finding the capacity is easy. Once you've found the "total production" th line, the th line with the storage capacities is 2 lines above. Then just parse the innerHTML of its font tags, having in mind that it uses 'k' to abbreviate multiples of 1000: var header = fields [i].getElementsByTagName ('th');
if (header.length != 0 && header [0].innerHTML.match (':'))
{
for (var j = 0; j < 3; j++)
{
storage [j] = parseInt (fields [i - 2].getElementsByTagName ('font') [j].innerHTML.replace (/\./g, '').replace (/k/, '000'));
}
break;
}
(The above assumes that you have declared a three-element array named "storage".) Then in incrementRes, instead of
use if (res [i] < storage [i]) values [i].innerHTML = addDots (Math.round (res [i])); However, meanwhile the array storage would have lost its values, so you have to save them in the cookie as soon as you determine them and then read them from there. Andorian's code given above for determining the exact coordinates of a planet is a bit of an overkill, IMHO - you don't need each part of the coordinates and you need more than the universe number. (Besides, not all universe URLs begin with "uni" - for instance, the Polish ones begin with "s".) Since you have to save *both* the server and the universe number (a user might have planets at the same coordinates in the same universes on different servers), it is easier to save in the cookie the whole part of the URL between "http://" and "/game" - e.g., "uni23.bg.ogame.org". One more thing - I would suggest avoiding GreaseMonkey-specific APIs like GM_setValue / GM_getValue. Without them, chances are that your script will work for Opera, too. With them, it won't - guaranteed. |
|
|
Sorry Vess, I had misunderstood what you said about the for-loop. The script worked fine for me, dunno why it didn't for you, but I made the change as you said and so hopefully that's better now =)
|
|
|
Found a very simple and elegant solution to the "ticking after the storage space is full" bug. ;) No need to save the storage capacities in a cookie - you can simply use the fact that the game already knows whether the storage is full or not. In your script, replace the line values [i].innerHTML = addDots (Math.round (res [i])); with if (values [i].color != '#ff0000') values [i].innerHTML = addDots (Math.round (res [i])); |
![]() ![]() |
Thanks for the tip!
|

