Update nut files to work with refactor
This commit is contained in:
@@ -13,17 +13,23 @@ void function pulsePrintt(string content) //Prints whatever we want printed with
|
||||
printt(format("%s " + content, pulsePrefix))
|
||||
}
|
||||
|
||||
bool function pulseRequestData(string givenURL, table parameterTable) //Gets data from API (see ToneURL within mod.json) and puts it into one table for processing.
|
||||
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<string, array<string> > params
|
||||
foreach (parameter in paramTable)
|
||||
{
|
||||
params[parameter] <- [paramTable(parameter)]
|
||||
}
|
||||
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
||||
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (params, tablepath)
|
||||
{
|
||||
table DecodedJSON = DecodeJSON(response.body)
|
||||
pulseData += DecodedJSON
|
||||
if (params["map"])
|
||||
{
|
||||
table map[params["map"]] <- DecodedJSON
|
||||
pulseData[tablepath] <- map
|
||||
} else {
|
||||
pulseData[tablepath] <- DecodedJSON
|
||||
}
|
||||
}
|
||||
void functionref (HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
||||
{
|
||||
@@ -32,16 +38,25 @@ bool function pulseRequestData(string givenURL, table parameterTable) //Gets dat
|
||||
return NSHttpGet(givenURL, params, onSuccess, onFailure)
|
||||
}
|
||||
|
||||
int function pulseParse(string parameter, string key, string value)
|
||||
int function pulseParse(string parameter, string key, string value, string opt = "none")
|
||||
{
|
||||
if (key == "maps") {
|
||||
if (key == "maps")
|
||||
{
|
||||
parameter = parameter.slice(3)
|
||||
}
|
||||
if (key in pulseData) {
|
||||
if (key in pulseData)
|
||||
{
|
||||
table keyandvalTable = expect table(pulseData[key])
|
||||
if (parameter in keyandvalTable) {
|
||||
table valTable = expect table(keyandvalTable[parameter])
|
||||
return expect int(valTable[value])
|
||||
if (parameter in keyandvalTable)
|
||||
{
|
||||
table valTable = expect table(keyandvalTable[parameter])
|
||||
if (opt == "none")
|
||||
{
|
||||
return expect int(valTable[value])
|
||||
} else {
|
||||
actualValTable = expect table(valTable[value])
|
||||
return expect int(actualValTable[opt])
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user