4 Commits
Author SHA1 Message Date
okvdai 47e4cd949c Begin #37 2023-10-23 20:19:30 +02:00
okvdai ca2ef84d55 Merge branch 'dev' of https://github.com/ToneAPI/pulse into dev 2023-10-23 18:32:39 +02:00
okvdai 4ce976cc88 Delete .gitignore 2023-05-04 20:48:07 +02:00
okvdai 687819e604 Create .gitignore 2023-05-04 20:46:03 +02:00
3 changed files with 49 additions and 30 deletions
+1 -3
View File
@@ -1,5 +1,3 @@
# SINCE 06.12.2023, PULSE IS **DEPRECATED** DUE TO THE CLOSING OF THE TONE API SERVICE. THANK YOU FOR USING THE MOD.
# pulse
**pulse** is a clientside mod for [TF|2 + Northstar](https://github.com/R2Northstar/Northstar) letting you view killstats collected by [the Tone API](https://toneapi.github.io/ToneAPI_webclient/) using the otherwise non-functional `Stats` tab.
@@ -77,7 +75,7 @@ Found a bug? Make an issue on GitHub [here.](https://github.com/ToneAPI/pulse/is
## DISCLAIMERS
The Tone API is NOT used by every server, view a list of supported servers [here.](https://toneapi.ovh/v2/client/servers)
The Tone API is NOT used by every server, view a list of supported servers [here.](https://tone.sleepycat.date/v2/client/servers)
**pulse** is very much a W.I.P as of right now, features may be missing/nonfunctional.
As of v2.1.0, **pulse** requires [loeb](https://github.com/okvdai/loeb)
@@ -1,9 +1,25 @@
globalize_all_functions
global enum ePulseDataType
{
WEAPON,
MAP,
GAMEMODE,
}
global struct pulseDataStruct
{
ePulseDataType dataType,
string dataName,
bool global,
int kills,
int deaths,
int max_distance,
int total_distance,
int deaths_while_equipped
}
global string pulsePrefix
table withMapName = {}
void function pulsePrefixSet() //Sets our prefix
{
pulsePrefix = format("\x1b[38;2;%i;%i;%im[PULSE]\x1b[0m", 255, 178, 102)
@@ -17,18 +33,39 @@ 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<string, array<string> > requestTable
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (givenURL, parameterTable, requestTable, tablepath)
ePulseDataType requestedDataType
if ("weapon" in parameterTable)
{
if (NSIsSuccessHttpCode(response.statusCode))
requestedDataType = ePulseDataType.WEAPON
}
else if ("map" in parameterTable)
{
requestedDataType = ePulseDataType.MAP
}
else if ("gamemode" in parameterTable)
{
requestedDataType = ePulseDataType.GAMEMODE
}
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response) : (givenURL, parameterTable, requestTable, tablepath, requestedDataType)
{
if (NSIsSuccessHttpCode(respone.StatusCode))
{
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
foreach (var key in DecodedJSON) {
table dData = DecodedJSON[key]
pulseDataStruct data = {
dataType = requestedDataType,
dataName = string(key),
global = tablepath.find("Global") != null ? true : false;
int kills = "kills" in dData ? dData["kills"] : 0
int deaths = "deaths" in dData ? dData["deaths"] : 0
int max_distance = "max_distance" in dData ? dData["max_distance"] : 0
int total_distance = "total_distance" in dData ? dData["total_distance"] : 0
int deaths_while_equipped = "deaths_while_equipped" in dData ? dData["deaths_while_equipped"] : 0
}
pulseData.append(data)
}
} else {
pulsePrintt(format("%s, %s is unreachable.", response.statusCode, givenURL))
@@ -47,22 +84,6 @@ bool function pulseRequestData(string givenURL, table parameterTable, string tab
return NSHttpGet(givenURL, requestTable, onSuccess, onFailure)
}
int function pulseParse(...) //Returns data from our pulseData table.
{
table parser = pulseData
int result = 0
for (int i; i < vargc; i++) {
if (i < expect int(vargc) - 1) {
if (expect string (vargv[i]) in parser) {
parser = expect table(parser[expect string(vargv[i])])
} else break
} else {
result = expect int(parser[expect string(vargv[i])])
}
}
return result
}
void function pulseLockStats()
{
loebSetLockedButton(Localize("#MENU_TITLE_STATS"), true)
@@ -1,7 +1,7 @@
global function pulseInit
global function pulseGetData
global table pulseData = {}
global array<pulseDataStruct> pulseData = []
struct {
array<string> allMaps