Then wood, starts by using resources to so we are only looking at that section of the DOM tree, it gets element s (returns an array) by class name now by limiting it to resources I knew there was only 1 match (the one we want) so get index 0. So resources gets the resource section of the report. Wood = resources.getElementsB圜lassName('wood').(/+/) Resources = document.getElementById('attack_spy_resources') I'm going to just link more intelligent people than me put it way better than I ever could.Īnyway just a tw example on a report (there is prolly a much better way to do this but am not thinking too good today): This is how you manipulate things on the page (get resource count from reports etc). I'm not gonna expand much here because of laziness, cookies setting/getting is fairly straightforward (although it's easy and neater with jQuery's $.cookie() but I'll mention jQuery in a bit!) There's a few scripts floating out there that just have hard written dates as the expiry, and these break. What you suggest would work for what you want. That's a trivial example but it does allow you to see what your code is doing, and can be very useful for finding where things have gone wrong. Press F10 and now enter b again and you should get 2. Doing the same with b, you'll get undefined, because at that point in time it hasn't been defined. Get rid of that debugger by resuming execution (Īnd in the console enter a, it will give you 1. To step into that function press F11 instead. The curved arrow (F10) moves forward a line, do note however it won't step into functions so say you have a function call:į10 will not go into that function and allow you to go through it too, it will just execute it. The blue button that looks kinda like a sign to play something resumes execution (F8). The hardest thing about this and why I want to learn to script is because I have to manually update my list from scouting reports too keep it up to date. I can sort the village list by distance from my farming village, income per hour, whether it has a * or not, or by wall level. Where I have the coordX,coordY space wood,clay,iron: space wall space wallLevel *to mark best villages followed by any notes I want. In fact my current code which I use to store information about farming villages reads a line like this: Finally, my main question about the second script is: How do you grab numbers from the scout report page? My only experience with reading pages is with java when you can scan through a text file line by line and character by character. I can look up the method online probably but to put the cookie expiry in the future could I just add 2 hours to the current time? It shouldn't take more than 2 hours to cycle through all my farms using a script if I can do it manually in about 90 minutes. Is there something similar for javascript? Also, I am unfamiliar with creating cookies. Some last questions: what is the best way to debug when coding javascript? When using java I just print variables and expressions to the compiler console to double check. I'm pretty busy this week with midterms but will try to tackle it next weekend. Obviously doesn't work, but for learning JS purposes it doesn't need to. The functions are fairly self explanatory in terms of their names, so that should help. As you can apparently already program the only issue with it should be syntax which you can google. Read it and highlight anything you don't understand. Am not going through that one, it's a lot longer and more tedious. Is there anything you don't understand about it after that?Įdit: just realised there was a second script on the page. That was more thorough than I intended actually. Insert the values into the rally point form. Also, does anyone know why most old scripts are broken? Is it due to an update to tribal wars?Īnd if anyone asks why the question is here and not in the scripting forum, activity here is a lot higher and so are my chances of getting a current answer. If possible could a scripter or someone who knows javascript go line-by-line through the code of a basic farming script and explain how each step works? That would probably be the best way for me to learn to script.Īlso, what is the most advanced script that tribal wars will approve for use? Could a script do everything except click attack or do you have to fill in troops manually? If not, how much can it do to speed up my farming? I want to write the script to work with non-premium accounts. I've finished the javascript tutorial at code academy. I am experienced in java coding but don't have much experience in javascript. One script to send out Light cavalry with a scout and another to send out light cavalry and a scout to pick up all resources left behind in the first attack plus resources generated while the second attack is en route. I'd love to write scripts similar to the one at this link:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |