Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

stringing % signs and values

Untra

Sponsor

I'm trying to edit scripts for myself, and so far everything is going quite smoothly. I know very little about scripting, and I believe I have gotten quite far with my rather impressive lack of knowledge.

Heres the situation, I'm editing my menu system so that at the bottom of the menu->status you would see the players evasion. Its all set up and working, but I would like the evasion value to read as a number and a percentage sign. I figured that making a string would work, but this doesnt seem to be the case.

When adding the evasion I had to add another number in window_base for it to be called properly, so it looks like this:
Code:
    when 7
      parameter_name = "Evasion"
      parameter_value = actor.eva

This comes out fine and dandy save for that I get the straight value and not with a pretty % sign afterwords. Ive tried stringing it but it keeps yelling at me for improper syntax or something else. thoughts?
 

khmp

Sponsor

I believe this is an easy fix. Originally you were probably doing something like this:
Code:
parameter_value = actor.eva + '%'
The problem with that is you are adding a numeric and a string. And ruby doesn't automatically convert numbers to strings so it throws a nice little error. The fix is quite simple and you only need to convert the number to a string.
Code:
parameter_value = actor.eva.to_s + '%'
However I'm not really sure what you are describing entirely. So my idea might be off. Let me know if it still doesn't work.

Good luck with it Untravaersil! :thumb:
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top