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
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.
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.
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
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.
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.