Game Development Community

Screenshot.cs - unfinished code?

by Martin Schultz · in Torque Game Engine Advanced · 09/14/2006 (5:56 am) · 2 replies

I stumbled across the screenshot.cs stuff and the first two functions seem to finished. I'll mark the lines I mean bold - the string is always set to "0" + %number. I guess it should be some kind of fill mechanism to have leading zeros. But now it's always only 1 zero. Is that intended?

common/client/screenshot.cs
function formatImageNumber(%number)
{
   if(%number < 10)
      [b]%number = "0" @ %number;[/b]
   if(%number < 100)
      [b]%number = "0" @ %number;[/b]
   if(%number < 1000)
      [b]%number = "0" @ %number;[/b]
   if(%number < 10000)
      [b]%number = "0" @ %number;[/b]
   return %number;
}

function formatSessionNumber(%number)
{
   if(%number < 10)
      [b]%number = "0" @ %number;[/b]
   if(%number < 100)
      [b]%number = "0" @ %number;[/b]
   return %number;
}

#1
09/14/2006 (6:41 am)
No, I think that code is correct, the zeros are appended (there is no "else", only "ifs") :)
e.g. for 77, it would add "0" for the second if, another "0" for the third if and another one for the fourth "if", so you'd get "00077"... I think :P
#2
09/14/2006 (6:52 am)
Ah, my fault, you're right. I overlooked that. Thanks Stefan :-)