mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
So, for obvious reasons this freezes mirc for the X amount of seconds it takes it to do the loops. Any way to optimize it or have I gone around it completely wrong?

Code:
var %url3 = https://eu.battle.net/api/wow/leaderboard/3v3
var %c = 0
while (%c < 1000 && %name != $2) {
  var %name = $json(%url3,rows,%c,name)
  if (%name == $2) {
    var %rank3v3 = $json(%url3,rows,%c,ranking)
  }    
  inc %c
}


I'm looking for a name in http://eu.battle.net/api/wow/leaderboard/3v3 that fits a specified name - and then the 'raking' of that name.

Any suggestions? Thanks!

Last edited by lindenkron; 23/11/13 04:45 PM.
Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
Not really anything in mirc I can think of, but would this be a better api call? http://blizzard.github.io/api-wow-docs/#character-profile-api/pvp (I don't know what I'm looking at)

Last edited by Loki12583; 23/11/13 07:52 PM.
Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
Originally Posted By: Loki12583
Not really anything in mirc I can think of, but would this be a better api call? http://blizzard.github.io/api-wow-docs/#character-profile-api/pvp (I don't know what I'm looking at)


That link simply states how to get the different regions of the API (korea, us, eu) etc. It's the same basically though.

I'm just unsure of how long a 1000 loop should take, because when I run it and it goes to rank 900-1000 it's a 5+ sec freeze on my mirc, where the window is "non responsive".

Thanks!

Joined: Jul 2006
Posts: 4,213
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,213
You need to provide the $json alias, that's what make it super slow


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361

Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
Obviously the $json points towards something or it won't work at all smile Didn't think it was necessary to include, my apologies.

I guess mIRC just doesn't like do loops of 1000~. I read somewhere that 1000 loops shouldn't take more than 1~ sec. That's the only reason I asked, it seems extremely slow to me. Ah well smile

Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
It's because you're looping $json 1000 times, which is an expensive call.

Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
Originally Posted By: Loki12583
It's because you're looping $json 1000 times, which is an expensive call.


Yeh, I guess there's no way to pull this off as a function usable by people in a twitch channel. It would constantly be frozen.

I honestly blame the way the API is set up - due to it being a ladder the ranking is tied to the ladder which is a full list of Row -> 1,2,3,4,5 (etc to 1000) instead of being tied to either a character (or as it was before, a team) so you could search for a character name directly and get a rank instead of having to loop through 1000s until you hit what you need.

I guess I'm just shit out of luck. Thanks for your time though smile

Joined: Jan 2004
Posts: 1,361
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,361
$json works by setting up its own javascript functions to be run in the com call, you could do the same to take the processing out of mirc, either in the com call, a dll, or other program. They'll probably be able to process it faster, then return the answer back to mirc. It'll require a lot of research on your part

Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
Originally Posted By: Loki12583
$json works by setting up its own javascript functions to be run in the com call, you could do the same to take the processing out of mirc, either in the com call, a dll, or other program. They'll probably be able to process it faster, then return the answer back to mirc. It'll require a lot of research on your part


I'm having trouble keeping up with something as basic as mIRC scripting. So I most likely am not going to throw myself into .dlls and other complicated things. I've accepted my defeat of a poorly designed API.

It is kind of an half assed solution as well because they changed the way their API originally was to compensate for their feature change in-game.

In case you're interested even remotely;
http://wowprogramming.com/docs/api/GetArenaTeam
that's how their API used to be. Everything quite easily accessible in one api request smile

Thx though!

Last edited by lindenkron; 24/11/13 05:48 AM.

Link Copied to Clipboard