Kishar.3762:

Hello !

It’s the first time I use Javascript and I did it with the Google script editor (to link the script to a google sheet). In fact, on the same sheet, I’d like to have everything I need from Trading Post (max offer / sell value …) and some others things like: auto calculated profit / auto loading item name and his full information when i’m just giving the item ID. Later, I want a script, which be able to send me a voice alert to say “Hey, big profit on this weapon, wake up now !”

I think I just did a small part of this work, just put the important steps (a lots found on the web, awesome community !) but I still having a problem.

In fact, from my “GetItemSellValue”, I’d like to have it with “XXXXXXXg XXs XXc” so I used the function “FormatAsGold”. There, is the problem: if there is more of 2 numbers for the golds, I’ll see only the 2 last number of the golds and not the others.

Easy example, a weapon sold for 1987 golds 34 silvers 55 coppers, in my “GetItemSellValue” column I will have: 19873455 and what I want to have in my "FormatAsGold column “1987g 34s 55c”… But I will only have “87g 34s 55c”, so missing the two first number “19”… And there’s a big difference between 1987g and 87g…
If anyone could help me a little bit about this, it could be very nice !

Just one thing, I know there is the GW2spidy API (really good one !) but I want to use only and only the official API (v2 so) and I know a lot of people put their jobs on the wiki but I still prefer do my own, even if, of course, I used a big part of the comunnity’s job to do mine, like I said, this is the first time I was using Javascript (and it’s hard because I never used any development languages…).

See here my pastebin code:
http://pastebin.com/XuQ214vm

darthmaim.6017:

Don’t take the modulo 100 for the gold.

Kishar.3762:

Thank you very much Darthmaim for your reply !

So Do I need to remove just “% 100” on the “var gold” or do I need to remove the full line and juste keep “var gold” ? :o (I’m sorry, my question is, I think, stupid, but I tried several times to remove some parts of this function and it doesn’t work…)

And now, I have another problem, about my function “GetItemBuyValue”, I saw a lot of different code for this one, so I tried it all but, on the Google sheets, it’s written "Error, can’t read “max_offer_unit_price” and what I don’t understand is, this the line that everybody use to get the item max offer.
So Actually, I’m using the line which is on my pastebin. But I tried those lines too:

function getItemBuyValue(itemID) {
var myUrl = “https://api.guildwars2.com/v2/commerce/listings/” + escape(itemID);
var jsonData = UrlFetchApp.fetch(myUrl);
var jsonString = jsonData.getContentText();
var jsonObject = JSON.parse(jsonString);
if (jsonObject.buys.length === 0) {
return 0;
}
var adjustedValue = (jsonObject.buys[jsonObject.buys.length-1].unit_price / 100);
return adjustedValue;
}

And if I use those lines, on the Google sheet, I don’t get “Error, can’t read max_offer_unit_price” (of course, this is not written on the script that’s why) but it’s written false information like “0,01” for the max offer price for Volcanus for example.

If someone could help me a little bit (again… >_<)

See here the new pastebin: http://pastebin.com/Z4UygwSc

EDIT: I found my error but to have the full price in gold / silver / copper, thanks again Darthmaim !
But I still have error the function to get the max offer… And now I have an error about the function to get item name with ID (but it was working yesterday so maybe an issue with gw2 server ?)

EDIT 2: I found my second error after XXX hours on (to get max offer) ! Even if… now i can’t get item name with the get item function with the ID… But this function still working with gw2spidy.

Light.7493:

Hey there. I created a webpage a few months back for calculating your bank worth:
http://pvp.guru/bank

I think the following web component has the stuff you need(look at the source):
http://pvp.guru/elements/paper-adder.html

Kishar.3762:

Hey Light !

Thank you very much for your reply ! You did a great job
I took a look on the source page, your javascript is “much clear” than mine, I prefer yours. The problem with mine is I’m asking to the API for each function I want, the best thing is to ask one time and get full informations, like yours.
I’ll so change my script to follow the base of what you did. Thanks again for your reply, you help me a lot ^^