Skip to content
TORNLIFE More

problems with API Personalstats

Started by LouBaker [1162207] on in API Development.

10 replies · 136 views · thread synced · 7 days ago · View on torn.com
About this thread

Posts archived: 11 / 11 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
11
Discussion span
→
People posting
5
Likes on archived posts
0
Posts by staff, officers and moderators
1
Authority score
73 / 100
Historical score
29 / 100
Story score
25 / 100
Engagement score
48 / 100
LouBaker [1162207]

Working on a Project with API https://gyazo.com/37906ffe16c8b11a9c2af13d2ab87553 this is testing ground for future stuff

but the why are the API personal stats not in the same order as on torn
they are not in alfabetic order, they are not in there groups or blocks they are all mest up all over the place
surely Torns data base is not this messy
each stat has to be searched for or organised, instead of being able to grab a block/section of data
this makes coding pains takingly long winded when it can be so simple

can we have some order here with API Personal Stats
McNeo [864688]

Any script you make should read the title of the data you're reading in, so the order doesn't matter. Order only matters if you're trying to guess and read sequentially, which would be bad coding.
Meme_Raven [1891116]

Correct, or the way they were index in to the API (not really familiar with JSON so don't scold me ^_^) either way, they do not need to ordered in a specific way because it's how YOU define them on your application.
LouBaker [1162207]

i dont know JSON too.
my work is mIRC script and Visual Basic, it just seems like a lot of work and string search to get there attack stats only.

if loaded into an array() in order i can grab a block of the array(1 - 8 ) to see there attacks stats as
  • Attacks won:4,491
  • Attacks lost:345
  • Attacks stalemated:24
  • Attacks assisted:12
  • Defends won:176
  • Defends lost:1,031
  • Defends stalemated:4
  • Win/Loss ratio:3.39
this can only be done if there where in order the same as shown on torn, currently they are all messed up and the arduous task of sorting them out is painfull

but i know i have to work with it, as i said before

Why have they been given to us like this, come on Torn help us out here

:)

McNeo [864688]

Use a matrix instead of an array, load the field names "attacks won","attacks lost",etc in the first row then the values "4491","345",etc in the second row. Then query the first row for the value you need, record the index, then query the second row using the index.
LouBaker [1162207]

yes it will be like that, the arrays will be the store as

Array Fields
1 "attackswon" , "4491"
2 "attackslost" , "345"
3 "attacksdraw" , "24"
4 "defendswon" , "176"
5 "defendslost" , "1031"
6 "defendsstalemated" , "4"

and can be displayed in a ListView


McNeo [864688]

You should use a single matrix and store the data like {{"attackswon","4491}{"attackslost","345"}...}

Then when your app needs to know "ok, how many attacks have the lost?" you look through the first value of the matrix until you find the string you are looking for, in this case "attacklost". Once you find it, you get the index of it. Then, you query the second row of the matrix for that specific index and it will return "345".

When querying the API and updating your matrix, don't forget to check if the field already exists and update the current value, or if it doesn't exist then to add it. Also, remember that some keys are duplicated in different categories and nests, so you need to check for that as well.