I did test the scripts but I can't guarantee they'll work perfectly, though.
Code:
# Two scripts for drawing scores, one to add zeroes to make a score display fixed,
# and another to add commas between every thousanth place
# These scripts can be combined, but recommended to be used on separate occasions
# Useful for arcade-style score displays that feature 0's in unfilled digits
script, appendZeroestoString, str, length, begin
# Note for length, 32 bit integers don't have more than 10 digits so it is pointless to do this with values
# with digits greater than that
variable (tempHold) # Needed to store the string's value
length := length -- string length (str) # Find out how many zeroes we don't want to overwrite
# Next store the value of the string and then clear it
tempHold := number from string (str) # Default for 2nd argument is kept to prevent masking bugs
clear string (str)
# Countdown from length to add the zeroes
while (length) do (
append number(str, 0)
length := length -- 1
)
# And then add the stored number to the end
append number (str, tempHold)
end
# Adding commas is useful for high score lists or general purpose displaying of large numbers
script, addCommastoNumberString, str, tempStr=99, begin
variable (count) # Used to cycle comma placement
count := 2 # Starting point, it cycles between 2-0
# Temporary string needed because I can't think of a way to do it without a duplicate string
copy string (tempStr, str)
clear string (str)
# Create the new string
while (string length(tempStr) ) do (
# Append the end of the string to the new string
# This will make the string backwards, but that is intentional
# As there's no way to insert to front of strings, the commas later are placed
# backwards, which we need to fix by reversing the whole string later
append ascii (str, ascii from string(tempStr, string length(tempStr) ) )
delete char (tempStr, string length(tempStr) ) # Delete that character
if (count <= 0) then (
$str + ","
count := 3
)
count := count -- 1
)
# Now we need to reverse the string. We use tempStr again for this
copy string (tempStr, str)
clear string (str)
while (string length(tempStr) ) do (
append ascii (str, ascii from string(tempStr, string length(tempStr) ) )
delete char (tempStr, string length(tempStr) ) # Delete that character
)
# Finally, trim any extranneous commas
if (ascii from string(str) == 44) then (delete char(str, 1) )
end
# and another to add commas between every thousanth place
# These scripts can be combined, but recommended to be used on separate occasions
# Useful for arcade-style score displays that feature 0's in unfilled digits
script, appendZeroestoString, str, length, begin
# Note for length, 32 bit integers don't have more than 10 digits so it is pointless to do this with values
# with digits greater than that
variable (tempHold) # Needed to store the string's value
length := length -- string length (str) # Find out how many zeroes we don't want to overwrite
# Next store the value of the string and then clear it
tempHold := number from string (str) # Default for 2nd argument is kept to prevent masking bugs
clear string (str)
# Countdown from length to add the zeroes
while (length) do (
append number(str, 0)
length := length -- 1
)
# And then add the stored number to the end
append number (str, tempHold)
end
# Adding commas is useful for high score lists or general purpose displaying of large numbers
script, addCommastoNumberString, str, tempStr=99, begin
variable (count) # Used to cycle comma placement
count := 2 # Starting point, it cycles between 2-0
# Temporary string needed because I can't think of a way to do it without a duplicate string
copy string (tempStr, str)
clear string (str)
# Create the new string
while (string length(tempStr) ) do (
# Append the end of the string to the new string
# This will make the string backwards, but that is intentional
# As there's no way to insert to front of strings, the commas later are placed
# backwards, which we need to fix by reversing the whole string later
append ascii (str, ascii from string(tempStr, string length(tempStr) ) )
delete char (tempStr, string length(tempStr) ) # Delete that character
if (count <= 0) then (
$str + ","
count := 3
)
count := count -- 1
)
# Now we need to reverse the string. We use tempStr again for this
copy string (tempStr, str)
clear string (str)
while (string length(tempStr) ) do (
append ascii (str, ascii from string(tempStr, string length(tempStr) ) )
delete char (tempStr, string length(tempStr) ) # Delete that character
)
# Finally, trim any extranneous commas
if (ascii from string(str) == 44) then (delete char(str, 1) )
end
<TheGiz> oh hai doggy, oh no that's the straw that broke tjhe came baclsb








