RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[SOLVED] Display a number :P

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 84
Above Characters
I guess it is the right place to ask my stupid questions.
I want to... well... display a number with a picture. Lets say i have 32 healing potions. I need them to be displayed ingame (potion icon and a number) and number must change in real time - if i, for example, hit the appropriate button to heal. I know the way it can be done with the events,  but it seems to hard for me (what if i have one bazillion potions?). So i think there must be much more easier way to do it with scripts. Unfortunately, i don't know much about scripting, so please someone help me!

If someone does not understand what I want to achieve, here is another example: its like in tankentai sbs they have those pretty damage/healing numbers popping up. System folder contains simple picture with the numbers from 0 to 9. I wanna know how they do that.

Well, i understand if my question looks stupid but i am noob in programming, i am noob in math and all that stuff, only now i started to learn ruby... Everyone says that its one of the easiest languages but still thats freaking hard to me. But I'm trying to do my best. And this is script support right? I didn't expect someone will do everything for me, I'm just looking for an advice.
« Last Edit: February 25, 2010, 07:48:00 PM by 104251 »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
So, you want to display a number using a set of 10 pictures from 0-9? As in, you don't want to just use a font?

It's pretty easy - one way to do it is split the number up and display through a loop, so something like this:

Code: [Select]
count = 0
while x != 0
  d = x % 10
  # Draw the picture for whatever number corresponds to d
  x /= 10
  count += 1
end

where x is the number you want to draw.

I didn't specify how you're drawing - because there are a number of ways to do it and it is dependent on the size of the files. I assume you would know how, but if you don't then just post again with more details on how you are designing the script and I will help further.

**
Rep: +0/-0Level 84
Above Characters
Oh my god. Yess! Thank you mr Modern Algebra! Splitting the numbers - this is what i couldn't figure out. I have tinkered a bit with your code in SciTE and it works like a charm. Now i will try to make something in rmvx.

In cbs they are using 2 solid pictures with numbers from 0 to 9. Like this one:
Spoiler for:
One for damage and another for healing. But now i think that using separate images for each number would be easier for me for now, i just don't know how to deal with solid ones))
Hmm i think i can make out the rest as i planning to display all this stuff through standard image commands - then i only need a way to alter ingame variables/switches with scripts...
« Last Edit: November 28, 2009, 09:15:13 PM by 104251 »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Altering in-game variables and switches through scripts is easy. They are located in the global arrays, $game_variables and $game_switches. So A code like: $game_variables[y] = integer would set the in-game variable with ID y to the integer, while a code like: $game_switches[z] = boolean (true/false) would set it to the new value, either ON (true) or OFF (false)

As for the solid numbers, you can draw only a portion of an external bitmap by changing the source rect when you are drawing.

So, the method in Bitmap is blt, so

bitmap.blt (x, y, bitmap_name, src_rect) is the basic code (and opacity if you wanted to change that too, but ignoting for now)

The method will draw only what is within the src_rect. So if you have a 100 x 20 pixel graphic, with each number from 0-9 being ten pixels in width, and your src_rect is Rect.new (40, 0, 10, 20), then it will only draw the 4.

**
Rep: +0/-0Level 84
Above Characters
Yes, thank you very much, i learned lots of new stuff. Of course, some things remain not quite clear to me, yet i still have much to learn. So i'll romp around with this for now, and if i cant make it then i just use the events, now i know how to do that))