View Issue Details

IDProjectCategoryView StatusLast Update
0000591Gameplay + OpenGL[All Projects] Bugpublic2017-04-17 08:17
ReporterMajor Cooke 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionno change required 
Summary0000591: String.Format not working properly
DescriptionIn StatusBars, I'm trying to make this piece of code work:

String DialName = "cnt";
String d2, d3;
int amt = Clamp(GetAmountOnly("Counter"), 0, 52);

if (amt < 10)
    d2 = String.Format("cnt0%d", amt);
else
    d2 = String.Format("cnt%d", amt);

DrawImage(d2, (465, 337), imageAlignment);
Console.Printf(d2);


But it always comes out as "cnt00" instead of "cnt##"" like it's supposed to.
Steps To ReproduceDownload the attachment, start a new game and right click the mouse. The "cnt" numbers on the right are supposed to go up but they do not.
TagsNo tags attached.

Relationships

Activities

Major Cooke

Major Cooke

2017-04-16 23:25

reporter  

D4D.pk3 (521,725 bytes)
_mental_

_mental_

2017-04-17 03:06

developer   ~0001420

String.Format() works correctly, the result of GetAmountOnly("Counter") is always zero.
And you can use the following format string to avoid comparison:
String d2 = String.Format("cnt%02d", amt);

Major Cooke

Major Cooke

2017-04-17 06:35

reporter   ~0001421

Ah right forgot to mention:

int GetAmountOnly(class<Inventory> item)
    {
        let it = CPlayer.mo.FindInventory(item);
        return (it ? it.Amount : 0);
    }
_mental_

_mental_

2017-04-17 06:55

developer   ~0001422

GetAmountOnly() is the same as in the attached file. Just do give counter in the console several times and everything will work as expected.
Major Cooke

Major Cooke

2017-04-17 08:17

reporter   ~0001423

Nice to see I can close my own tickets now.

Issue History

Date Modified Username Field Change
2017-04-16 23:25 Major Cooke New Issue
2017-04-16 23:25 Major Cooke File Added: D4D.pk3
2017-04-17 03:06 _mental_ Status new => resolved
2017-04-17 03:06 _mental_ Resolution open => no change required
2017-04-17 03:06 _mental_ Note Added: 0001420
2017-04-17 06:35 Major Cooke Note Added: 0001421
2017-04-17 06:55 _mental_ Note Added: 0001422
2017-04-17 08:17 Major Cooke Status resolved => closed
2017-04-17 08:17 Major Cooke Note Added: 0001423