Refactor: Added explicit typing and void return types

- Introduced explicit typing to variables and functions across multiple scripts for better code clarity.
- Specified 'void' as the return type for functions that do not return a value.
- Removed redundant code in some scripts.
This commit is contained in:
Dan 2024-05-15 10:42:16 +01:00
parent a62cd6018e
commit 2a9e78b52e
37 changed files with 216 additions and 248 deletions

View file

@ -1,9 +1,9 @@
class_name StringUtilities extends Node
func seconds_to_hms(seconds: float) -> String:
var ms = fmod(seconds, 1) * 100
var s = fmod(seconds, 60)
var m = fmod(seconds, 3600) / 60
var ms : float = fmod(seconds, 1) * 100
var s : float = fmod(seconds, 60)
var m : float = fmod(seconds, 3600) / 60
var formatted : String = "%02d:%02d:%02d" % [m, s, ms]
@ -15,14 +15,14 @@ func seconds_to_hms(seconds: float) -> String:
func format_number(number: int) -> String:
# Handle negative numbers by adding the "minus" sign in advance, as we discard it
# when looping over the number.
var formatted_number := "-" if sign(number) == -1 else ""
var index := 0
var number_string := str(abs(number))
var formatted_number : String = "-" if sign(number) == -1 else ""
var index : int = 0
var number_string : String = str(abs(number))
for digit in number_string:
for digit : String in number_string:
formatted_number += digit
var counter := number_string.length() - index
var counter : int = number_string.length() - index
# Don't add a comma at the end of the number, but add a comma every 3 digits
# (taking into account the number's length).