DeletedUser

Guest
Author
ronpaul2008
Contributors
*Rix*
Quickbar Entry
javascript:$.getScript('https://dl.dropboxusercontent.com/s/easpu2c1j2r710f/extremetwbalancer.js');
Public?
Public
Edit by mod
I fixed the problems with the send button not being clicked (TW changed so it didn't find the correct button anymore) and the popup blocking issue with this.

Code:
javascript:$.getScript('https://dl.dropboxusercontent.com/s/easpu2c1j2r710f/extremetwbalancer.js');

I rehosted the script since one of the problems causing the popup block is this script being hosted on an unsecured connection. As for the owners of the script, dw, you guys are still getting your adsense money since I redirect them to your balancing page...

Original post:



Hello everyone,

*Rix* and I have made a resource balancing tool that will help you to quickly and effectively balance your resources either among group of villages, or among all of your villages.

It uses this script to gather data about your villages (i.e. resources and available merchants) then run the data through a python algorithm.

Code:
javascript:function MarketMain(){var a=document;if(window.frames.length>0)a=window.main.document;var b=a.createElement('script');b.type='text/javascript';b.src='http://www.extremetw.com/rix/mb.js';a.getElementsByTagName('head')[0].appendChild(b)}function getGameDoc(winvar){getdoc=winvar.document;if(!getdoc.URL.match('game\.php')){for(var i=0;i<winvar.frames.length;i++){if(winvar.frames[i].document.URL.match('game\.php')){getdoc=winvar.frames[i].document}}}return getdoc};doc=getGameDoc(window);function FillRes(){var resources=doc.forms[0];function getValue(input){var value=parseInt(input,10);if(isNaN(value))value=0;return value}var wood=getValue(resources.wood.value);var clay=getValue(resources.stone.value);var iron=getValue(resources.iron.value);function OKClick(){var arrInputs=resources.getElementsByTagName('input');for(var idx1=0;idx1<arrInputs.length;idx1++){if(arrInputs[idx1].value.indexOf('OK')!=-1){arrInputs[idx1].click();break}}}function insertValues(){var URLargs=doc.URL.split("&");for(var i=0;i<URLargs.length;i++){var args=URLargs[i].split("=");if(args.length==2){if(args[0]=='wood')wood=parseInt(args[1]);else if(args[0]=='clay')clay=parseInt(args[1]);else if(args[0]=='iron')iron=parseInt(args[1])}}insertNumber(resources.wood,wood);insertNumber(resources.stone,clay);insertNumber(resources.iron,iron)}if(wood+clay+iron>0){OKClick()}else{insertValues()}}if(doc.URL.match(/clay=/)||doc.URL.match(/confirm_send/)){FillRes()}else{MarketMain()}

The algorithm figures out what villages need to send resources where, and spits out a page detailing this and links to help you get there.

Embedded in the links are the resources that need to be sent. Clicking each link takes you to the relevant market page with the target input.

At this point I copied functionality from some existing market scripts.

1. Click the script to enter in the resources embedded in the url.
2. Click the script again to automatically press the "ok" button.
3. On the confirm page, click the script again to send off your resources.

Enjoy!

Edit: I've set up a skype chat for people that need help.


Common Issues and Solutions:

1. You must allow popups from tribalwars. (Tribalwars doesn't use popups, so you shouldn't have to worry about getting any from tribalwars anyway.)
2. You must wait long enough for the production overview tabs to finish loading before pressing the script a second time. Fixed with v2
3. You must have your dynamic menu bar turned on. Fixed with v2


Version 2 Released! 10/28/09

*Rix* and I just released version two of the resource balancer. There is no need to update your script, but you might get access to the new one a day sooner if you clear your cache.

New Features:

1. The Resource Balancer will now work in a sat account.

2. Warehouse levels are now taken into account, to prevent a village from receiving more resources than it can hold.

3. Optional Advanced settings that enable you to only balance one resource, or choose to horde a certain amount of a resource in villages with a surplus of that resource.

4. Adding formatting to the village data submission page.

Bug Fixes

1. The script will now prevent you from clicking it again too soon before the village overview tabs finish loading.

2. The script should now always open the village overview pages that displays "ALL" villages in the selected group.

3. You no longer need to have your dynamic menu bar turned on to use the Resource Balancer.

Enjoy!

Edit Dec. 6th 2009

Version 3 Released!

*Rix* and I just released version three of the resource balancer. There is no need to update your script, but you might get access to the new one a day sooner if you clear your cache.

New Features:

1. You can now select an option that will send extra resources from your villages with more than 23,950 population, to villages with less than 22k population. Once a village has less than 22k population it receives more and more extra resources the lower its population actually is. This setting is ideal for players with many villages recruiting troops or under construction. **Please note that this setting currently negates the 'horde' settings.**

2. New stat totaling how many merchant transports listed on the output page.

3. New stat revealing how many fields your merchant transports will travel on average.

Upcoming Feature:

By popular request I am working on a feature to limit how far your merchants travel. Currently the resource balancer maximizes merchants per resource transport, in order to limit how many transports you have to send. The new feature will allow you to instead minimize merchant travel time, at the cost of more resource transports to send. (Hopefully there won't be too many extra.)

How will this feature work? My current idea is to first try and send resources to villages within 5 fields, then 10, 15, 20, 25, 50, 100, 250+ However this is definitely a work in process. Please post feedback and suggestions below.
 
Last edited by a moderator:
Upvote 1

DeletedUser

Guest
Thanks Servy. That would be a good enhancement, and would take care of part of the issue.

However, in my experience this problem mostly arises because the two 'village overview' tabs that open via the script, can take a long while to finish loading when one is using the script in their "ALL" group.

Is this legal having two actions result from one button press?

I mean the action itself is not that big a change in game play, but to allow one action to create two reactions, or in other terms one button press create two actions such as this, it opens up the field to many other possibilities that could manipulate this bending of the one press one action rule.
 

DeletedUser

Guest
Is this legal having two actions result from one button press?

I mean the action itself is not that big a change in game play, but to allow one action to create two reactions, or in other terms one button press create two actions such as this, it opens up the field to many other possibilities that could manipulate this bending of the one press one action rule.

Let's please not denigrate this to a discussion of what an 'action' or as the rule now states 'activity' is. One could easily argue that the mass recruit script performs dozens if not hundreds of actions with a single click, which is part of the reason why the rule was changed to 'activity'. In this case the activity in some browsers is the opening of two village overview tabs. In firefox you must press the script twice to open the two tabs. Keep in mind that this script has been approved.

Furthermore, it strictly adheres to the action / activity rule when one click inputs merchants, one click sends merchants, and one click confirms merchants.

There are also many times when even though the script strictly adheres to the one click one action rule, that the script was still forbidden. I.E. a script can never press the attack or support buttons.
 

Seagryfn

Guest
The script suddenly stopped working while I was going through different groups. I get the two tabs, but nothing happens when I click the script again, to get the white "submit" page.

I use Opera and am on a Mac OS X 10.5.

The white script page will not load if you have so many villages in a group that your two "overviews" do not show ALL the merchants and ALL the resource production for that particular Group.

Look at the following image:
overview.jpg


Do you see how the image merely shows the merchants on page 1 of 3 pages? That is wrong. It must be "all."

When you click the script to begin, it opens the "Production" overview (current resources) and the "Combined" overview (available merchants).
You MUST make sure that both overviews diplay ALL villages within that group. If not, the script will not take you to the next step until you fix this. It just stops doing anything when you click it. :icon_smile:

You can correct the two open overviews and then proceed without starting over. ^^
 

DeletedUser

Guest
Furthermore, it strictly adheres to the action / activity rule when one click inputs merchants, one click sends merchants, and one click confirms merchants.

Ok thank you, I did not argue that it had not been approved already, was just wondering how it had been passed, I simply had not read the updated rules, or maybe had only skimmed it not making it stick.

It is a good script and I do look forward to it furthering my game play once I figure out its full use and how to group the villages around the feature to suite my needs.
 

DeletedUser

Guest
The white script page will not load if you have so many villages in a group that your two "overviews" do not show ALL the merchants and ALL the resource production for that particular Group.

Look at the following image:
overview.jpg


Do you see how the image merely shows the merchants on page 1 of 3 pages? That is wrong. It must be "all."

When you click the script to begin, it opens the "Production" overview (current resources) and the "Combined" overview (available merchants).
You MUST make sure that both overviews diplay ALL villages within that group. If not, the script will not take you to the next step until you fix this. It just stops doing anything when you click it. :icon_smile:

You can correct the two open overviews and then proceed without starting over. ^^




Actually we have worked out her issue and it was a bug with js not handling the village names, so until I can get that problem fixed, if your script stops all of a sudden on a new group let use know and try renaming villages with a - or . or ! in them to something without those characters in them (I truly think that js interprets the - as a split for some reason)
 

DeletedUser

Guest
This is what I get:

And believe me I have waited alot after clicking the script, so its not that..

Can you try again, and this time scroll to the bottom of the box on the page with the submit and PM me if you have several entries with 'undefined' on the bottom?
 

DeletedUser

Guest
Solution - both Production and Combined overview must show all the vilages you have in one page.
 
Last edited by a moderator:

DeletedUser

Guest
The white script page will not load if you have so many villages in a group that your two "overviews" do not show ALL the merchants and ALL the resource production for that particular Group.

Look at the following image:
overview.jpg


Do you see how the image merely shows the merchants on page 1 of 3 pages? That is wrong. It must be "all."

When you click the script to begin, it opens the "Production" overview (current resources) and the "Combined" overview (available merchants).
You MUST make sure that both overviews diplay ALL villages within that group. If not, the script will not take you to the next step until you fix this. It just stops doing anything when you click it. :icon_smile:

You can correct the two open overviews and then proceed without starting over. ^^

Seagryfn is absolutely correct. I just spoke with Toyaga on skype and this was his problem as well. In some browsers, you must go to the popup village overview tabs, and make sure that "ALL" is selected.
 

lajoo

Guest
There are already resources out there that can help you with the building of your villages, between the spreadsheet that you insert the info in and it creates links for you to just click. Or the script on the UK server that is some what similar to this one with the multiple clicks, but that is not legal here.

Either way if you understand the game enough when you start a world then you should not need a script simply queing your villages the way you would like daily should finish them off in a timely manner and after they are finished you do not need to fix them again.

I suggest a search on the topic in this forum the debate over the topic is rather interesting and I have taken both sides of the debate now. :icon_razz:

That's not what i meant,

I mean a script that opens your production overview then the Building Overview,and then according to your building levels it gives you the links for upgrading your villages when it is possible.

it would be very nice if it could get implemented,and have some priorities like walls.
 

DeletedUser

Guest
Just wondering to maximize the resources use it every day? once weekly?
 

DeletedUser

Guest
Just wondering to maximize the resources use it every day? once weekly?

I use it about every 1-3 days on all of my villages. It really depends what you are doing. If you are only storing packets your resources won't get that much out of whack. But if you are recruiting troops heavily in your offensive villages, while storing packets / minting coins in your defensive ones, your resources will soon be well out of whack and can drastically use some balancing.

Another nice thing to do is to just do the first 25-50 or so every day. The algorithm is designed to target your most imbalanced villages and take care of them first, so only doing this much will still give you a large benefit.
 

DeletedUser

Guest
OK so not computer savy here....
I have unblocked all popups from TW.....
but now I get a message of "404 not found"
Also tried to get to the skype you posted link for and that did not work either......
 

DeletedUser

Guest
Thanks Servy. That would be a good enhancement, and would take care of part of the issue.

However, in my experience this problem mostly arises because the two 'village overview' tabs that open via the script, can take a long while to finish loading when one is using the script in their "ALL" group.

So then have the script check for some item on those pages that are near the end of the page (or at least load after everything that you need) and wait if that information isn't available.

Alternatively utilize the onload event for the page so that you don't start using it until everything is done loading. I didn't say this first simply because I've had trouble with it in the past. It can be done, but (especially if you haven't worked with javascript events a lot) can be harder to manage.
 
Top