From bf5af3d6c410c9559c925343e82b6b4e09e6f035 Mon Sep 17 00:00:00 2001 From: snicker Date: Tue, 25 Nov 2014 09:17:27 -0800 Subject: [PATCH] changed array indices for JSON data returned from the members API and added some more robust error handling, fixes issue #3 --- habitrpg.au3 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/habitrpg.au3 b/habitrpg.au3 index 745771d..2f13d5d 100644 --- a/habitrpg.au3 +++ b/habitrpg.au3 @@ -57,10 +57,14 @@ Global $growlHandle = _GrowlRegister($growlAppName,$growlNotifications,@ScriptDi Dim $gold_gained = 0, $xp_gained = 0, $original_gold = -1, $original_xp = -1; -Dim $userdata = HRPG_Get_Member($habitRpgUID,$habitRpgUID,$habitAPIToken)[2][1] +Dim $userdata = HRPG_Get_Member($habitRpgUID,$habitRpgUID,$habitAPIToken)[3][1] If $userdata <> "" Then - $original_gold = $userdata[4][1]; - $original_xp = $userdata[3][1]; + If UBound($userdata) > 4 Then + $original_gold = $userdata[4][1]; + $original_xp = $userdata[3][1]; + Else + _GrowlNotify($growlHandle,"notice","Error!","Couldn't get your current gold and XP. If this persists, file a bug report!") + EndIf EndIf Dim $response = HRPG_Score_Task($habitRPGTask,$habitRpgDirection,$habitRpgUID,$habitAPIToken)