Elite raw draw scripting alternative you say?
DynamicSprite *coinSprite; // we'll be needing this since our sprite is after all dynamic
// player picks up coin:
player.AddInventory(iCoin); // give the player the coin
if (coinSprite != null) { // if our dynamic sprite has been set, we need to release the old one first
if (iCoin.Graphic == coinSprite.Graphic) iCoin.Graphic = 0; // make sure we remove the reference to the sprite first
coinSprite.Delete(); // release the sprite from memory
}
coinSprite = DynamicSprite.CreateFromExistingSprite(REGULAR_COIN_SPRITE); // copy the "raw" sprite
DrawingSurface *surface = coinSprite.GetDrawingSurface(); // get the surface to draw onto
String count = String.Format("%d", player.InventoryQuantity[iCoin.ID]); // store the number of coins the player has in a string
int width = GetTextWidth(count, Game.NormalFont) + PADDING_RIGHT; // get the total width used for aligning the text
surface.DrawingColor = COIN_COUNT_TEXT_COLOR; // set the text color
surface.DrawString(coinSprite.Width - width, PADDING_TOP, Game.NormalFont, count); // draw the number on the sprite
surface.Release(); // release the surface, updating the sprite
iCoin.Graphic = coinSprite.Graphic; // set the item's graphic
UpdateInventory(); // this may be necessary since the sprite graphic has changed
Values that need to be replaced are as follows:
REGULAR_COIN_SPRITE: The sprite slot number of the coin sprite without any number applied.
PADDING_RIGHT: How far from the right edge of the sprite the text should be.
PADDING_TOP: How far from the top edge of the sprite the text should be.
COIN_COUNT_TEXT_COLOR: The color the text should be drawn in.
And there you have it.
Edit: Haha Chicky is too proud to actually post here that he is using 2.72...but I'm not! :D
We'll have to use the old-school RawDraw techniques instead!
DynamicSprite *coinSprite; // we'll be needing this since our sprite is after all dynamic
// player picks up coin:
player.AddInventory(iCoin); // give the player the coin
if (coinSprite != null) { // if our dynamic sprite has been set, we need to release the old one first
if (iCoin.Graphic == coinSprite.Graphic) iCoin.Graphic = 0; // make sure we remove the reference to the sprite first
coinSprite.Delete(); // release the sprite from memory
}
RawSaveScreen(); // save the current room background
RawClearScreen(63519); // clear the screen to magic pink
RawDrawImage(0, 0, REGULAR_COIN_SPRITE); // draw the regular image onto the background so we can draw on top of it
String count = String.Format("%d", player.InventoryQuantity[iCoin.ID]); // store the number of coins the player has in a string
int width = GetTextWidth(count, Game.NormalFont) + PADDING_RIGHT; // get the total width used for aligning the text
RawSetColor(COIN_COUNT_TEXT_COLOR); // set the text color
RawPrint(Game.SpriteWidth[REGULAR_COIN_SPRITE] - width, PADDING_TOP, count); // draw the number on the sprite
coinSprite = DynamicSprite.CreateFromBackground(GetBackgroundFrame(), 0, 0, Game.SpriteWidth[REGULAR_COIN_SPRITE], Game.SpriteHeight[REGULAR_COIN_SPRITE]);
RawRestoreScreen(); // restore the normal background graphic
iCoin.Graphic = coinSprite.Graphic; // set the item's graphic
UpdateInventory(); // this may be necessary since the sprite graphic has changed