diff --git a/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-common-func.gnut b/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-common-func.gnut index c9428ef..a740c3c 100644 --- a/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-common-func.gnut +++ b/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-common-func.gnut @@ -18,18 +18,23 @@ void function pulsePrintt(string content) //Prints whatever we want printed with bool function pulseRequestData(string givenURL, table parameterTable, string tablepath) //Gets data from API (see ToneURL within mod.json) and puts it into one table for processing. { table > requestTable - void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (parameterTable, requestTable, tablepath) + void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (givenURL, parameterTable, requestTable, tablepath) { - table DecodedJSON = DecodeJSON(response.body) - if ("map" in parameterTable) - { - string mapName = expect string(parameterTable["map"]) - withMapName[mapName] <- DecodedJSON - pulseData[tablepath] <- withMapName + if(response.statusCode == 200 || response.statusCode == 201){ + table DecodedJSON = DecodeJSON(response.body) + if ("map" in parameterTable) + { + string mapName = expect string(parameterTable["map"]) + withMapName[mapName] <- DecodedJSON + pulseData[tablepath] <- withMapName + } else { + pulseData[tablepath] <- DecodedJSON + } + pulseSuccessBool = false } else { - pulseData[tablepath] <- DecodedJSON + pulseSuccessBool = true + pulsePrintt(format("%s %s is unreachable.", response.statusCode, givenURL)) } - pulseSuccessBool = false } void functionref (HttpRequestFailure) onFailure = void function(HttpRequestFailure failure) {