1. New to the forums? Check out our Mentorship Program!
    Our mentors will answer your questions and help you become a part of the community!
  2. Welcome to Smogon Forums! Please take a minute to read the rules.

Analysis Links Project (with script)

Discussion in 'Technical Projects' started by firecape, Jul 27, 2012.

  1. firecape

    firecape This is the end...
    is a Forum Moderator Alumnusis a Contributor Alumnus

    Joined:
    Mar 17, 2010
    Messages:
    1,048
    Ok, so this is the moment all you slaves have been waiting for! Please be sure to carefully read this post before attempting to help out. Your slave labor is appreciated but if you make a mistake you get the whip you've probably done more harm than help :(. There will be a full tutorial, but feel free to ask me any questions (no matter how stupid, lol) on IRC if you want to make sure you're doing it right! I know this is tl;dr but I promise its not that complicated at all to run, and I just want to make sure everything is clear.

    Now you will need the following to help out:
    • A badge (sorry, but it just cuts efficiency a ton otherwise)
    • Any program that makes .txt files. There is good chance your computer comes with one. Notepad is an example of one.
    • mIRC

    This is a script made for mIRC if you haven't gathered from the thread title, so it's necessary to help out. I'm not really good at scripting other than with mIRC and most suggestion box ideas turn into something like "Oh that would be a good idea if someone did it," So I decided fuck it I'm going to just make an mIRC script for it.

    Ok so I'm not going to give you a tutorial for getting mIRC up and running, so I assume it's up and connected at this point. I'll preface this by explaining how the script works a bit. Any word that is capitalized is referenced among the list of moves, Pokemon, and competitive items (a lot of items aren't included) that are stored in .txt files. It takes about 10 seconds to run for a full analysis. During these 10 seconds, your mIRC client will go unresponsive as the script processes. Don't panic, but if for some reason you need to stop the script there is a "break" button on most computers. It's usually in the top right corner, and it will halt the script. Ok so now onto actually getting the files it references in place. These are simple .txt files placed into the mIRC directory. To open this, simply type "//run $mircdir" into any active window in your mIRC client. Now for the actual text files; you will need to make 5 in total. Make the first one and title it "pokemonlist". Copy and paste this pastebin into pokemonlist.txt. Then, drag and drop the text file from wherever it default saved to your mIRC directory which we opened a little while back. If you want to check if you did this right, type "//echo -a $read(pokemonlist.txt,1)" into any active window, and it should return "arceus-bug". Sometimes copy/pasting from pastebin can fuck up the text; to check if it did, type "//echo -a $read(pokemonlist.txt,w, arceus-bug)" into any active widnow. It should return "arceus-bug" again. If not, open your notepad file and click ctrl + a. If you see it highlight a shitload of spaces after the Pokemon names, you're going to have to manually remove all those spaces for the script to work :(.

    Ok, so follow the same procedure for every file. I'll just list the correct thing to name the .txt file followed with the corresponding pastebin. You should know if you're doing it right from checking the first one. If you want to check each subsequent one for some reason, all you need to do is type "//echo -a $read([text file name].txt,1)". Then "//echo -a $read([text file name].txt,w, [what the previous command returned])".

    Here are the files:

    Ok so now that you have the file time for the actual script. Here it is:

    Code:
    alias insertlinks {
      if (!$1) { echo -a syntax is /insertlinks [Pokemon/move/item (use _ for spaces)] [tier (for pokemon only, optional)] }
      set %pokemon $$1
      set %tier $2
    dialog -md table table }
    dialog table {
      title "insert links by firecape"
      size -1 -1 270 335
      option dbu
      edit "", 1, 2.5 10 270 300, multi, vsbar, hsbar
      text "Paste Here", 2, 112 1 50 9, center
      button "Done", 5, 80 313 125 12, ok
    }
    on *:dialog:table:sclick:5: {
      write -c linked.txt
      var %tableline 1
      var %word 1
      var %used %pokemon
      while (($did(table,1,$calc(%tableline + 1))) || ($did(table,1,%tableline))) {
        if (($left($gettok($did(table,1,%tableline),1,32),3) == <p>) && ($did(table,1,$calc(%tableline + 1) != $null))) { var %pp on }
        if ($gettok($did(table,1,%tableline),1,32) == [SET]) {
          var %line 1 
          var %used %pokemon
          while ($gettok($did(table,1,%tableline),1-2,32) != [SET COMMENTS]) {
            write -l $+ %tableline linked.txt $did(table,1,%tableline)
            if ((%line > 2) && (%line < 7)) {
              var %i 1
              var %moves $replace($gettok($did(table,1,%tableline),3-,32), $+ $chr(32) $+ / $+ $chr(32) $+ ,/)
              var %nmoves $numtok(%moves,47)
              while (%nmoves >= %i) {
                var %currentmove $gettok(%moves,%i,47)
                if (Hidden Power isin %currentmove) { var %used %used Hidden_Power | var %h yes }
                if (!%h) { var %used %used $replace(%currentmove,$chr(32),_) }
              inc %i }
            }
            if (%line == 7) { var %used %used $replace($gettok($did(table,1,%tableline),2-,32),$chr(32),_) }
            inc %tableline
            inc %line 
          unset %h }
        }
        if ($did(table,1,%tableline) == [Other Options]) { var %used %pokemon }
        if ($did(table,1,%tableline) == [Checks and Counters]) { var %used %pokemon }
        if ($gettok($did(table,1,%tableline),1-2,32) == <ul class="damage_calculation">) {
          while ($gettok($did(table,1,%tableline),1,32) != </ul>) { write -l $+ %tableline linked.txt $did(table,1,%tableline) 
          inc %tableline }
        }
        while ($gettok($did(table,1,%tableline),%word,32)) {
          if ($left($gettok($did(table,1,%tableline),%word,32),3) == <p>) { var %p <p> }
          if ($left($gettok($did(table,1,%tableline),%word,32),1) == $chr(40)) { var %p $chr(40) }
          while (($left($gettok($did(table,1,%tableline),%word,32),1) islower) && ($gettok($did(table,1,%tableline),%word,32)) && (!%p)) { 
            var %writtenline %writtenline $gettok($did(table,1,%tableline),%word,32) 
          inc %word }
          var %what $gettok($did(table,1,%tableline),%word,32)
          var %arceus %what $gettok($did(table,1,%tableline),$calc(%word + 1),32)
          var %arceuswithout $remove(%arceus,$chr(44),.,;,:,</p>,<p>,!,?,$chr(41),$chr(40))
          var %move %what $+ _ $+ $gettok($did(table,1,%tableline),$calc(%word + 1),32) 
          var %movewithout $remove(%move,$chr(44),.,;,:,</p>,<p>,!,?,$chr(41),$chr(40),'s)
          var %hijumpkick %movewithout $+ _ $+ $gettok($did(table,1,%tableline),$calc(%word + 2),32)
          var %hijumpkickwithout $remove(%hijumpkick,$chr(44),.,;,:,</p>,<p>,!,?,$chr(41),$chr(40),'s)
          var %whatwithout $remove(%what,$chr(44),.,;,:,</p>,<p>,!,?,$chr(41),$chr(40),'s)
          if (%movewithout === Toxic_Orb || %movewithout === Absorb_Bulb || %movewithout === Toxic Plate) { var %m on }
          if (%hijumpkickwithout === Hi_Jump_Kick) { 
            if (!$findtok(%used,Hi_Jump_Kick,32)) {
              var %writtenline %writtenline $iif(%p != $null,%p,$null) $+ <a href="/bw/moves/Hi_Jump_Kick"> $+ %hijumpkick $+ </a> 
              var %linked on
              var %used %used Hi_Jump_Kick
            var %hjk on }
            if (!%hjk) { var %writtenline %writtenline Hi Jump Kick
            var %linked on }
          var %hjk on }
          if (($read(arceuslist.txt,s, %arceuswithout $+ )) && (!$findtok(%used,$replace(%arceuswithout,$chr(32),_),32))) {
            var %used %used $replace(%arceuswithout,$chr(32),_) 
            var %writtenline %writtenline $iif(%p != $null,%p,$null) $+ <a href="/bw/pokemon/ $+ $read(arceuslist.txt,s, %arceuswithout $+ ) $+ "> $+ $remove(%arceus,%p) $+ </a> 
            var %arceusused on
          var %linked on } 
          if (($read(pokemonlist.txt,w, %whatwithout $+ )) && (!$findtok(%used,%whatwithout,32)) && (%arceusused != on)) {
            var %used %used %whatwithout
            var %writtenline %writtenline $iif(%p != $null,%p,$null) $+ <a href="/bw/pokemon/ $+ %whatwithout $+ $iif(%tier == $null,$null,/ $+ %tier) $+ "> $+ $remove(%what,%p) $+ </a>
          var %linked on }
          if (($read(itemlist.txt,w, %movewithout $+ )) && (!$findtok(%used,%movewithout,32))) {
            var %used %used %movewithout
            var %writtenline %writtenline $iif(%p != $null,%p,$null) $+ <a href="/bw/items/ $+ %movewithout $+ "> $+ $remove($replace(%move,_,$chr(32)),%p) $+ </a>
            var %linked on
          var %itemused on }
          if (($read(itemlist.txt,w, %whatwithout $+ )) && (!$findtok(%used,%whatwithout,32)) && (%itemused != on)) {
            var %used %used %whatwithout
            var %writtenline %writtenline $iif(%p != $null,%p,$null) $+ <a href="/bw/items/ $+ %whatwithout $+ "> $+ $remove(%what,%p) $+ </a>
          var %linked on }
          if (($read(movelist.txt,w, %movewithout $+ )) && (!$findtok(%used,%movewithout,32)) && (!%m)) {
            var %used %used %movewithout
            var %writtenline %writtenline $iif(%p != $null,%p,$null) $+ <a href="/bw/moves/ $+ %movewithout $+ "> $+ $remove($replace(%move,_,$chr(32)),%p) $+ </a>
            var %linked on
          var %moveused on }
          if (($read(movelist.txt,w, %whatwithout $+ )) && (!$findtok(%used,%whatwithout,32)) && (%moveused != on) && (!%m)) {
            var %used %used %whatwithout
            var %writtenline %writtenline $iif(%p != $null,%p,$null) $+ <a href="/bw/moves/ $+ %whatwithout $+ "> $+ $remove(%what,%p) $+ </a>
          var %linked on }
          if (%linked != on) {
            var %writtenline %writtenline %what
            var %linked off
          }
          if ((%moveused == on) || (%itemused == on) || (%arceusused == on)) { inc %word 1 }
          if (%hjk) { inc %word 3 }
          else { inc %word }
          var %linked off
          var %moveused off
          var %itemused off
          var %arceusused off
          unset %hjk
          unset %p
          unset %m
        }
        if (%pp != on) { write -al $+ $iif(%ppp == on,$calc(%tableline - 1),%tableline) linked.txt $replace($replace($replace($replace($replace($replace($replace($replace($replace($replace($replace($replace($replace(%writtenline,$chr(44) $+ </a>,</a> $+ $chr(44)),.</a>,</a>.),;</a>,</a>;),:</a>,</a>:),<p></a>,</a><p>),</p></a>,</a></p>),!</a>,</a>!),?</a>,</a>?),$chr(41) $+ </a>,</a> $+ $chr(41)),!</p></a>,</a>!</p>),?</p></a>,</a>?</p>), $+ $chr(32) $+ $eval($+,0) $+ $chr(32),$null),.</a></p>,</a>.</p>) }
        inc %tableline 1
        if (%ppp == on) { unset %ppp }
        if (%pp == on) { var %ppp on }
        if (%pp != on) { var %writtenline $Null }
        if (%pp == on) { var %writtenline %writtenline $eval($+,0) }
        unset %pp
      var %word 1 }
      run linked.txt
      unset %tier
      unset %pokemon
    }
    
    Copy and paste it to your "remote" section of mIRC. If you don't know where that is, it can be opened by pressing "Alt + R" when mIRC is your active window. To run it, type "/insertlinks [Name of Pokemom/item/move you are inserting the links into. If the item or move has spaces, replace them with _. (Eg Ghost Arceus = Ghost_Arceus, Air Balloon = Air_Balloon)] [Tier (Include this parameter only for Pokemon (use the abbreviation that appears at the end of the link on the dex, eg ou/uu/ru/nu/lc/vgc2012))]. Here's an example run:

    I want to do OU Abomasnow, so I go to it's OU scms page (http://www.smogon.com/scms/revision/89550/edit) and copy the entire analysis. Then, I type "/insertlinks Abomasnow OU" into any active mIRC window. A dialogue box will pop up. Paste the entire thing into it. Now I'm just going to bring up the a fault with the script that I cannot fix because it is mIRC's fault (to my knowledge, at least).
    Show Hide
    [​IMG]

    Notice the highlighted portion and how it goes onto a second line? mIRC apparently has a character limit per line in dialogue boxes. That break causes the script to insert a return there when it spits it out. I have fixed this so it won't affect you in most cases. The only time this will be an issue is if a Pokemon/move/item is the word cut off. If this is the case, you will manually have to link it. In other words just <a href="/bw/[type of thing, eg move, pokemon, or item]/[name of pokemon, move, or item, with _ used over spaces]/[tier (if applicable)]">Pokemon/move/item name</a>. So <a href="/bw/pokemon/abomasnow/ou">Abomasnow</a>. Now all you have to do is paste the raw scms version into the box and click done. Wait 10-15 seconds and a notepad file will pop up with the linked version done.

    A few things to note before you start. It's quite possible something I haven't forseen won't work. I have tested it extensively and weeded a lot of this out but there still may be some things I have not thought of. For instance, Toxic Orb didn't work until recently because the script saw "Toxic" and just linked to the move. High Jump Kick didn't work before because it was three words (Roar of Time still doesn't work because it has no competitive use whatsoever and I didn't feel like putting it in like I did for Hi Jump Kick). Some things that are not bugs and don't need to be reported:

    • It will only link to the first mention of a Pokemon/item/move per set. After that it ignores all mentions of this word. There's no reason to link to something multiple times.
    • It won't link to the Pokemon/item/move you specified when you ran it for obvious reasons
    • It won't link to any move or item in the actual set, because those are already linked automatically.
    • Only competitive items are linked (you can check which ones those are in the pastebin of items)
    • Abilities aren't linked
    • Anything in damage calculations (eg anything within the tags <ul class="damage_calculation"></ul> are not linked. If you see a damage calculation with incorrect format please fix it! There are actually a surprising amount of incorrectly formatted damage calcs on site (I've fixed all that I've seen so far), and this will mess with the script. A very common mistake that is extremely easy to miss is <ul class="damage_calculations">, so watch out for this! Also, curly quotes mess them up too.

    I'm going to say this one more time: I'm am not very good at scripting and don't claim to be. If someone who is would like to write an actual script for this, go right ahead. Until then, this cuts down grunt work a huge amount and saves a large amount of time, even if it is quite possibly imperfect. I would strongly suggest anyone that starts running this check the first few times for mistakes (though I've run it numerous times for this purpose). As a side note of sorts this will not work well with articles.
  2. firecape

    firecape This is the end...
    is a Forum Moderator Alumnusis a Contributor Alumnus

    Joined:
    Mar 17, 2010
    Messages:
    1,048
    Going to do this in a semi-orderly fashion so reserve mons before you start with them. Reserve alphabetically please.
  3. Tobes

    Tobes Woo-hoo, woo-hoo, woo-hoo-hoo!
    is a Battle Server Administratoris a Site Staff Alumnusis a Super Moderator Alumnusis a Community Contributor Alumnusis a Tiering Contributor Alumnusis a Contributor Alumnusis a Smogon Media Contributor Alumnusis a Past WCoP Winner

    Joined:
    Jul 16, 2010
    Messages:
    2,553
    I'll take A - D OU. (Tier, not metagame.)

Users Viewing Thread (Users: 0, Guests: 0)