Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Silencher

Variables in item help lines?

Question

I basically want to have a skill called 'auto crossbow' and I'd like if it's 'highlighted' and when the little help screen comes up for it to display a variable. So I tried: Shoot up all your enemies with this. There are \V[102] shots remaining. But it literally shows \V[102] rather than the value of that variable. Am I doing something wrong, and if not is there a script that would allow that to be done in the item's help line?

Share this post


Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0

I basically want to have a skill called 'auto crossbow' and I'd like if it's 'highlighted' and when the little help screen comes up for it to display a variable. So I tried: Shoot up all your enemies with this. There are \V[102] shots remaining. But it literally shows \V[102] rather than the value of that variable. Am I doing something wrong, and if not is there a script that would allow that to be done in the item's help line?

It needs to be \v[variable number] not the value of the variable inside the variable. Also u dont need the caps. That should work :alright:.

Edit: Prob. wont work. Thnx kev lol

However why not just make a text command that shows that variable in battle whenever he or she goes?

Edited by Dragon324

Share this post


Link to post
Share on other sites
  • 0

class Bitmap

 alias variable_sub draw_text
 def draw_text(*args)
   index = args[0].is_a?(Rect) ? 1 : 4
   args[index].gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
   variable_sub(*args)
 end
end

 

Put that code anywhere in your game above "Main". It will allow you to use the "\v[VARIABLE_ID]" command anywhere in your game, including all windows, item/weapon/armor descriptions and names, actor names, etc.

Share this post


Link to post
Share on other sites
  • 0

It doesn't do that for me. I just re-tested it, and it works fines. From the sounds of the error, you have a script calling Bitmap#draw_text with the arguments out of order, or a script that modifies that method.

 

I can't seem to create that error in a new game or a loaded game, using both the "bitmap.draw_text(x, y, width, height, str)" and "bitmap.draw_text(rect, str)" way of drawing text.

 

The only possible way I could see this crashing is if Game_Variables was not initialized yet, but then you would get a different error.

 

If you like, upload me your Scripts.rxdata, and I will find whats causing the error.

Share this post


Link to post
Share on other sites
  • 0

@ForeverZe0 is that script made for VX? or does it matter? (not a scripter) Since the guy is using VX and perhaps the script is made for xp :unsure:

Edited by Kevin.ds

Share this post


Link to post
Share on other sites
  • 0

Ah, ok, I'm stupid. I was thinking XP. Give me one sec, I'll make you a VX version, and I apologize. :P

 

@Keven.ds: Thanks for pointing that.

 

 

EDIT:

Err, the methods are the same in both RGSS and RGSS2. I tested it in RMVX, and it still works just fine...

Edited by ForeverZer0

Share this post


Link to post
Share on other sites
  • 0

Do you have the fixed version of VX? If I recall correctly there was a version of VX that had a MAJOR bug with variables. Make sure you have the latest version.

Share this post


Link to post
Share on other sites
  • 0

Found the problem. Its "draw_currency_gold", which has the party gold, as an integer, passed to the draw_text. Unlike RMXP, RMVX automatically applies .to_s to non-string values, which my aliased method is executing before it gets a chance to convert. Here is an updated, fail-proof method:

 

class Bitmap

 alias variable_sub draw_text
 def draw_text(*args)
   index = args[0].is_a?(Rect) ? 1 : 4
   unless args[index].is_a?(String)
     args[index] = args[index].to_s
   end
   args[index].gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
   variable_sub(*args)
 end
end

Edited by ForeverZer0

Share this post


Link to post
Share on other sites
  • 0

Sweet the updated version works. I checked it on armor/items/skills and it worked in all of them. Do you want to be credited? and if so, can you either post or pm me how you would like to be, and contact info if you'd like that as well?

Share this post


Link to post
Share on other sites
  • 0

Its just a little snippet, you don't have to, I'll leave it up to you if you feel credit is necessary. If you decide to, my username will suffice.

 

Glad I could help.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...