From 0f0d89c9c39b9a7bad88036ea8a9a1289cae7afa Mon Sep 17 00:00:00 2001 From: okvdai <108829133+okvdai@users.noreply.github.com> Date: Sun, 3 Sep 2023 15:15:33 +0200 Subject: [PATCH] Merge pulse-loeb-component.nut into pulse-common-func.gnut --- mods/ToneAPI.pulse/mod.json | 7 ----- .../scripts/vscripts/pulse-common-func.gnut | 7 +++++ .../scripts/vscripts/pulse-loeb-component.nut | 7 ----- .../mod/scripts/vscripts/pulse.gnut | 29 +++++-------------- 4 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-loeb-component.nut diff --git a/mods/ToneAPI.pulse/mod.json b/mods/ToneAPI.pulse/mod.json index 8d52e9d..f5936a2 100644 --- a/mods/ToneAPI.pulse/mod.json +++ b/mods/ToneAPI.pulse/mod.json @@ -20,13 +20,6 @@ "UICallback": { "After": "pulseInit" } - }, - { - "Path": "pulse-loeb-component.nut", - "RunOn": "UI", - "UICallback": { - "After": "pulseRegisterWithLoeb" - } } ], "Localisation": [ 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 37461ac..0c3d3af 100644 --- a/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-common-func.gnut +++ b/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-common-func.gnut @@ -32,11 +32,13 @@ bool function pulseRequestData(string givenURL, table parameterTable, string tab } } else { pulsePrintt(format("%s, %s is unreachable.", response.statusCode, givenURL)) + pulseLockStats() } } void functionref (HttpRequestFailure) onFailure = void function(HttpRequestFailure failure) : (givenURL) { pulsePrintt(format("Something went wrong, %s is unreachable", givenURL)) + pulseLockStats() } foreach (key, value in parameterTable) { @@ -61,6 +63,11 @@ int function pulseParse(...) //Returns data from our pulseData table. return result } +void function pulseLockStats() +{ + loebSetLockedButton(Localize("#MENU_TITLE_STATS"), true) +} + string function HammerToMeterString(float value) { return value > 0 && int((1.905 * value ))/100 > 0 ? string(int((1.905 * value ) )/100) + "m" : "0"; diff --git a/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-loeb-component.nut b/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-loeb-component.nut deleted file mode 100644 index 052b98c..0000000 --- a/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse-loeb-component.nut +++ /dev/null @@ -1,7 +0,0 @@ -global function pulseRegisterWithLoeb - -void function pulseRegisterWithLoeb() -{ - bool success = pulseGetData() - loebSetLockedButton(Localize("#MENU_TITLE_STATS"), success) -} \ No newline at end of file diff --git a/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse.gnut b/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse.gnut index a9eb9c3..3d5c869 100644 --- a/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse.gnut +++ b/mods/ToneAPI.pulse/mod/scripts/vscripts/pulse.gnut @@ -12,36 +12,21 @@ void function pulseInit() pulsePrefixSet() file.allMaps = GetPrivateMatchMaps() pulsePrintt("Initialized.") + pulseGetData() } -bool function pulseGetData() +void function pulseGetData() { print("data getter called") string URL = GetConVarString("ToneURL") array URLpath = ["/weapons", "/weapons", "/gamemodes", "/gamemodes", "/maps"] array tablepath = ["weaponsLocal", "weaponsGlobal", "gamemodesAll", "gamemodesSeparated", "maps"] - if (!pulseRequestData(URL + URLpath[0], {["player"] = NSGetLocalPlayerUID()}, tablepath[0])) - { - return true - } - if (!pulseRequestData(URL + URLpath[1], {["player"] = "!" + NSGetLocalPlayerUID()}, tablepath[1])) - { - return true - } - if (!pulseRequestData(URL + URLpath[2], {["player"] = NSGetLocalPlayerUID()}, tablepath[2])) - { - return true - } + pulseRequestData(URL + URLpath[0], {["player"] = NSGetLocalPlayerUID()}, tablepath[0]) + pulseRequestData(URL + URLpath[1], {["player"] = "!" + NSGetLocalPlayerUID()}, tablepath[1]) + pulseRequestData(URL + URLpath[2], {["player"] = NSGetLocalPlayerUID()}, tablepath[2]) foreach (map in file.allMaps) { - if (!pulseRequestData(URL + URLpath[3], {["player"] = NSGetLocalPlayerUID(), ["map"] = map.slice(3)}, tablepath[3])) - { - return true - } + pulseRequestData(URL + URLpath[3], {["player"] = NSGetLocalPlayerUID(), ["map"] = map.slice(3)}, tablepath[3]) } - if (!pulseRequestData(URL + URLpath[4], {["player"] = NSGetLocalPlayerUID()}, tablepath[4])) - { - return true - } - return false + pulseRequestData(URL + URLpath[4], {["player"] = NSGetLocalPlayerUID()}, tablepath[4]) } \ No newline at end of file