Here is a little code snippet thing that could be useful if you want to use dollars and cents format for your game:
Wherever you see:
self.contents.draw_text(x, y, width, height, @gold.to_s)
You can replace @gold.to_s with:
format("$%.2f", (@gold/100).to_s)
e.g. 300G becomes $3.00, 495059 gold becomes $4950.59.
Note that the above code treats 1 standard G as being 1 cent in dividing it by 100. This way, you can sell items for $9.99 like in the real shops! :V:
If you want whole dollars (which is kinda pointless) just change the code to:
format("$%.2f", @gold.to_s)
If you want to omit the $ sign, change to:
format("%.2f", (@gold/100).to_s)
Credits:This Discussion on Ruby-Forum (http://www.ruby-forum.com/topic/89085)
Nice. I may use this in my game ;) power up
:) Thank you! I really appreciate it, and I'm glad you found it remotely useful!
Quote from: Reno-s--Joker on April 02, 2009, 05:39:09 am
:) Thank you! I really appreciate it, and I'm glad you found it remotely useful!
*pets* Good boy *pets* Who wants a cookie? YOU DO! Who's an awesome scripter? YOU ARE!! *pets and rubs belly*
:3 Aww, thank you Rose! :D
I couldn't say I'm an awesome scripter just yet though. o_O Although I wish I was. ;___;
I know this might be necroposting, but I tried this script and it didn't work. When I start the game, it says something about line 24. It contains:
self.contents.font.color = system_color
I'm a n00b at scripting, so I don't know what's up with the script.
//Oh, and I'm using XP, not VX.
Are you using the official RMXP or Dyna or PK or whatever it's called? xD
I'm using the official version.
Quote from: meyvn MaRa on August 20, 2009, 10:14:18 am
I know this might be necroposting, but I tried this script and it didn't work. When I start the game, it says something about line 24. It contains:
self.contents.font.color = system_color
I'm a n00b at scripting, so I don't know what's up with the script.
//Oh, and I'm using XP, not VX.
First, make sure you have the scripts in the right order.
And if that doesn't fix it, post the actual error and the scripts you're using (in the order they are in the Script editor).
Right order? What do you mean "right order"? The instuctions say that all I have to do is to change a part of a line of a script called "Window_Gold".
Well, I'll post the script as how I wrote it:
#==============================================================================
# ** Window_Gold
#------------------------------------------------------------------------------
# This window displays amount of gold.
#==============================================================================
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, format("%.2f", (@gold/100).to_s)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
end
end
#### # # ## ## ####
# # # # # # # # # #
#### # # # ## # ####
# # # # # # #
#### #### # # #
The right order (http://forum.chaos-project.com/index.php?topic=23.0)
Um, how was that supposed to help?
Oh yeah, I forgot. But, the right order has nothing to do with this, 'cuz I only replaced a one line of a default script called "Window_Gold".
No problem. Just making sure, lol!
Quote from: Blizzard on September 06, 2009, 04:41:05 am
No problem. Just making sure, lol!
:...:
Well, can anyone help me please? I'm a :n00b: at scripting, so I have no idea of what I'm suposed to do...
you did:
self.contents.draw_text(4, 0, 120-cx-2, 32, format("%.2f", (@gold/100).to_s)
change it to:
self.contents.draw_text(4, 0, 120-cx-2, 32, format("%.2f", (@gold/100).to_s))
remember that you have the same amount of ) as of (
Now it gives me an error message of that line:
QuoteScript "Window_Gold" line 23: NoMethodError occured.
undefined mathed `/" for nil:NilClass
been looking at this for over an hour and i have the feeling that this Snippet will only apply to 1-2 specific menu systems.
the first reason i have for this is that in WHOLE rmxp "@gold.to_s" can not be found.
the only rule there can be found that seems close is: "self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)" in window_gold
so I want to know who got this 1 to work and if they can post there script.
There are 2 instances of @gold.to_s in Window_BattleResult :P
And yeah, you can just use $game_party.gold.to_s instead