Telling the player how many limited uses of skill are left

I am using Yanfly's Skill Restriction script, to limit the number of uses a skill has.  

I have, however, modified it slightly so that instead of the number of uses being limited within a particular battle, the uses are limited until the player rests at an inn, at which point they are reset.

It therefore becomes more important for the player to know how many uses of a skill are left before they need to rest to get it back.

I have no idea how this could be done.  The simplest and most effective way visually would be to have in the skill list e.g.

Skill name * 5

Skill name * 10

And then that number to be reduced each time the skill is used.  But for all I know, that is the most difficult to script for.

Can anyone think of a way of doing this?  

Thank you.
What I would do is use yanfly's skill cost manager script

Use the custom note tag like

<custom cost requirement>$game_variables[n] >= 1</custom cost requirement>
Code:
<custom cost perform>$game_variables[n] -= 1</custom cost perform>
Code:
<custom cost: $game_variables[n]> #note not certain if this part will work if not find a script that allows you to put \v[n]
in the skill name.
I'm a bit lost on this.

are you suggesting that I use this script instead of Skill Restrictions or as well as that one?

And I am utterly lost about how these note tags come in.  I hadn't intended having anything other than normal skill costs.  The only thing out of the ordinary would be that the number of uses are limited.  I'm afraid I can't follow what those tags are doing.

Sorry to be such a script idiot, it is my natural condition.
Sorry about the confusion. 😛

Yea for what you are doing I would probably recommend the script in the link I posted. Reason for this is I think it would be the easiest solution to what you are doing (I have something similar in the game I am working on).  All the note tags posted above would be placed in the skills note box.

The first note tag:

<custom cost requirement>$game_variables[n] >= 1</custom cost requirement>This is telling the skill that if the $game_variable n is >= 1 you can use the skill.

The next note tag:

<custom cost perform>$game_variables[n] -= 1</custom cost perform>This is telling the skill that after use lower $game_variable n by 1.

The last note tag (assuming it works I haven't tested it like this which is why I also mentioned that you may need a script to allow \v[n] in skill names):

<custom cost: $game_variables[n]>This would (hopefully) show you how many more times you can use the said skill. So "Skill name 5" for example in the skill selection window. Might be able to format it like this:

<custom cost: "x #{$game_variables[n]}">So it would then look like "Skill name x 5"
I am very sorry, but I am still a little confused.

1) I assume from this that every skill which is affected by this will need its own unique variable switch.

2) Those variables would have to be set up and activated at the beginning of the game.

3) The first 3 note tags are put into the skill note box.

4) You then tell me to format the skill selection box with the next, small note.  What do you mean by the skill selection box.  Do you mean the skill name in the data base?  Or something else?

5) How does it know when to reset these?  Are you saying that every inn event is going to have to reset all the variable switches?  (Sounds a bit of a nightmare, and wide open to error, so I'm hoping you mean something else.)

I do apologize for these questions, but I really can't work this out.
Perfectly all right.

1 and 2) not necessarily you can use a multi dimensional array (an array inside of an array). So you could have something like this $game_variables[n] = [5, 3 , 8] in a starting parallel event (numbers are example amount of times a skill may be used before you would need to rest at an inn). Then you would call this in the note tags like so:

<custom cost requirement>$game_variables[n][0] >= 1 #this would be the first index in the above array which in this #case would be the number 5</custom cost requirement>3) Yes.

4) Sorry meant that when you are in battle and viewing skills or viewing skills in the menu the skill listed in the skill selection window would be formatted using the 4th note tag I posted. If the said note tag didn't work then you would probably use \v[n] (like you would use in a message window) in the skill name box in the database so your players will know how many more uses they have left.

5) This will be the complicated one, easiest method I know of would be to actually use two $game_variables with the same data one to be read by your skills and the other as a limit for increasing them back to their appropriate amounts. I will be able to post a correct loop for doing this in about an hour (dinner is calling). I will try and give more information shortly.

Use the script call Rest_Skills.rest inside your inn events to return the skill use amount back to normal:

place this snippet in a new script slot above main and below materials.

#Script call Rest_Skills.restmodule Resting#replace V1 with the id you are using for the variable in the skill note tags#replace V2 with the id you are using for the variable that is holding the limitsV1 = 301V2 = 302endclass Rest_Skillsinclude Restingdef self.rest ($game_variables[V2].size - 1).times do |i| while $game_variables[V1] < $game_variables[V2] $game_variables[V1] += 1 end endendendSo In short use two $game_variables (currently using 301 and 302)

Set them in a starting parallel event like so:

Both should have the same values.

$game_variables[301] = [number1, number2, number3, etc, etc]

$game_variables[302] = [number1, number2, number3, etc, etc]

Then you can use them in note tags by doing the second variable should not be used (as it is just for returning the numbers back to default once you rest at an Inn):

$game_variables[301][0]

#indexes starts at 0 and ends one number short of the length of your array if you want to find the length use:

puts $game_variables[301].size - 1
I still can't work out where to put the 4th note tag.  I have put it in the skill note box, as it won't fit in the box where the name is input.

I've been trying to get this to work on a test map, and as you can see, the name of the skill is overwritten by part of the formula.

I also don't understand why it is showing as 35MP instead of just the usual 35.  Is that because of the script?  It seems to have affected every skill.

skill%20test_zpshllny1vy.png
Okay don't use the 4th note tag then I'll see if I can't find something that will work for that instead. For the MP part line 228 is

MP_COST_SUFFIX = "%sMP" #remove the %sMP keep the ""There is also one for TP which you can do the same too.
Great, I've removed the MP and TP.

When I remove the 4th tag, the skill name is still being overwritten, but it's less messy, so I think it's only being overwritten once, not twice,  It looks like it's the

$game_variables[18]

This is from the third tag because when I remove that, the skill name is no longer overwritten.  What there is now is

Skill name           035

35 is the MP cost, so I am assuming that the zero is the result of the first 2 tags showing up.  The variable has been set to 3 uses.
Yea forgot about mention that the 3rd tag was the same as the fourth tag. 😛 Sorry about that, to remove the 0 though leave it in but erase the $game_variables part should look like this:

<custom cost: >Here is a snippet that I quickly made to allow message codes in the skill name:

Spoiler
class Window_Base < Window  alias sar_convert_escape_characters :convert_escape_characters  #added new escape code \vv[n1][n2] allows for 2d arrays  def convert_escape_characters(text)    result = text.to_s.clone    result.gsub!(/\\/)            { "\e" }    result.gsub!(/\e\e/)          { "\\" }    result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }    result.gsub!(/\eVV\[(\d+)\]\[(\d+)\]/i) { $game_variables[$1.to_i][$2.to_i] }    result.gsub!(/\eN\[(\d+)\]/i) { actor_name($1.to_i) }    result.gsub!(/\eP\[(\d+)\]/i) { party_member_name($1.to_i) }    result.gsub!(/\eG/i)          { Vocab::currency_unit }    result  end   alias sar_draw_item_name :draw_item_name #allows for escape codes in the skill and item names  def draw_item_name(item, x, y, enabled = true, width = 172)    return unless item    draw_icon(item.icon_index, x, y, enabled)    change_color(normal_color, enabled)    text = convert_escape_characters(item.name)    draw_text(x + 24, y, width, line_height, text)  end end
Put this in a new slot then in the skill name box in the data base you can do: "Skill name x\vv[301][0]" for example. 🙂 (Which in game will look like): "Skill name xN" where N is the number.
We're nearly there.

As instructed the 3rd tag was amended.

The message code reads x\vv[18][3]

I set variable 18 to 3, then taught the skill to the character.  In the skill list it shows up as

Skill name  x0           35

The skill works, but it stays as x0

EDIT

Done it!

I changed x\vv[18][3] to a simple x\V[18] and the correct number showed up.  I used the skill once, and the number reduced to 2.

I'm falling over with tiredness now, as it is late in my time zone.  So if you have any further thoughts, I'll pick them up in the morning.

Thank you so much for this.  I am extremely grateful.
Have a starting event with these commands:

$game_variables[18] = [3, 1] #add more numbers as you need to one for each skill with a comma after them except for the final number

$game_variables[19] = [3, 1] #limit to return $game_variables[18] to default

\vv[18][0] or $game_variables[18][0] will be the number 3

\vv[18][1] or $game_variables[18][1] will be the number 1

In my testing it works correctly.

Edit:

Here's an RTP free non encrypted demo showing how everything is setup for 2 skills (strong attack id 80 and cleave id 81): link

And your welcome 😀
Thanks for the further explanation, and for the demo.

When I run the demo, however, the inn event doesn't quite work.  The first skill (strong attack id 80) resets, but the second skill (cleave id 81) does not, and i cannot see why.
#Script call Rest_Skills.rest#Fixed bug with some skills not returning to normal when script is called.module Resting#replace V1 with the id you are using for the variable in the skill note tags#replace V2 with the id you are using for the variable that is holding the limitsV1 = 1V2 = 2endclass Rest_Skillsinclude Restingdef self.rest ($game_variables[V2].size).times do |i| while $game_variables[V1] < $game_variables[V2] $game_variables[V1] += 1 end endendendReplace the Resting Skills script with this one.
All is now well, and running as expected.

Once again, thank you very much for this.  I do appreciate your time and expertise.
You are most welcome 😀

I just wish I knew about doing it this way a year ago lol would have helped me so much.
I know the feeling.  There have been a couple of things I've found months too late to be useful.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/telling-the-player-how-many-limited-uses-of-skill-are-left.44679/