Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Converting FixNum to String, Need to know how ^_^
Rohiaw
post Aug 31 2011, 04:42 PM
Post #1


Level 2
Group Icon

Group: Member
Posts: 19
Type: Developer
RM Skill: Advanced




Well I keep getting this error and i need to know how to do this. I know it can be done, coz if it cant, than RGSS wud be just plain useless ...

basically i have an integer:

number = 1

and i need to use it in a string, like so:

string = "Graphics\\Characters\\" + number + ".png"
(for example)

But i get an error saying I cant convert a FixNum into a string.

Any help ? :3


__________________________
Writing this in my sig, cause I dunno what to say :P

My Current Projects:
Rohiaw - The Incarnate Shadow
Description
This is the story of a boy, and his search for who, or what, he is.

My Scripts:

Can u read this ??
Hleeo.Tahnk you for tkanig the tmie to raed tihs.I am bsaing tihs on the frist {oigranl} can you raed tihs?Yaeh olny smoe poelpe can sikm sneentces lkie tehse woituht hvanig to sotp.You rllaey olny hvae to konw the frist and end lttres of the wrod you are tyrnig to raed for yuor mnid to pcik tehm up esaily.Olny 55% of poelpe can raed tihs.I tihnk taht snice you konw waht you are raendig aoubt you can gesus the wrods.If you can raed tihs, palce it in yuor sgitanrue.
Go to the top of the page
 
+Quote Post
   
The Law G14
post Aug 31 2011, 05:23 PM
Post #2


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,346
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Ah, well what you have to do is use the to_s method which happens to be a method of the Integer class. The Help File defines the method as "Converts an integer to a base-10 string expression." So to keep it plain and simple, this "to_s" method converts your integer into a string, which seems to be what you're looking for.

So in effect, you would change this:

string = "Graphics\\Characters\\" + number + ".png"

To this:

string = "Graphics\\Characters\\" + number.to_s + ".png"

Then instead of looking for the actual Integer 1, it would look for the string "1". Hope this helps smile.gif


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
Rohiaw
post Aug 31 2011, 05:37 PM
Post #3


Level 2
Group Icon

Group: Member
Posts: 19
Type: Developer
RM Skill: Advanced




Thanks. Exactly what i needed tongue.gif
Although i may have used this before ... hah biggrin.gif may have forgotten it.
thanks tongue.gif


__________________________
Writing this in my sig, cause I dunno what to say :P

My Current Projects:
Rohiaw - The Incarnate Shadow
Description
This is the story of a boy, and his search for who, or what, he is.

My Scripts:

Can u read this ??
Hleeo.Tahnk you for tkanig the tmie to raed tihs.I am bsaing tihs on the frist {oigranl} can you raed tihs?Yaeh olny smoe poelpe can sikm sneentces lkie tehse woituht hvanig to sotp.You rllaey olny hvae to konw the frist and end lttres of the wrod you are tyrnig to raed for yuor mnid to pcik tehm up esaily.Olny 55% of poelpe can raed tihs.I tihnk taht snice you konw waht you are raendig aoubt you can gesus the wrods.If you can raed tihs, palce it in yuor sgitanrue.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 10:25 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker