Disable skill through script?

I'm writing a script, but I can't figure out how to gray out a skill. I'm trying to gray out any skill that has a TP cost higher than another variable I've previously determined. I've trying friggin' around with "enable?(skill)" under Window_SkillList, but that hasn't yielded anything. Suggestions?
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


Show us your script. If we can't see how you've written it, how can we tell you how to change it?


I do think enable?(skill) is the place you need to make your change, so if it's not working, chances are you've done something wrong in there.
I was more wondering about if there were general good solutions to that kind of function, but okay, point taken. The rest of my script is messy and uses game variables and stuff, because I'm groping my way through scripting blindly. But the idea is that I gave the player a lot of extra action times, and I want the game to deplete TP as they select skills, and then not use TP when the skills are activated, so their choices in the moment will be more apparent. Otherwise they can select skills until they run out of action times, and then they only activate as far as the TP stretches. So I made $game_variable[7] equal to the Actor's TP at the beginning of the turn, and it subtracts the TP cost of the skill from that variable when the player selects it. I had something like this to gray out the skills that have a cost higher than the dummy TP variable;

 
class Window_SkillList < Window_Selectable
 
  def enable?(item)
    @actor && @actor.usable?(item) && $game_variables[7] > @actor.skill_tp_cost(skill)
  end
end

But nothing changed from the former problematic situation. I haven't touched the Window_SkillList script for anything else. 
It's no different because @actor.usable? already does a test to see if the actor has enough TP to use the skill. So if $game_variables[7] is equal to or greater than the skill TP cost in the database, you will not see a difference. At a quick look, I think you would only see a difference if $game_variables[7] is lower than the TP cost AND lower than the actor's TP.


Have you taken into account the fact that the player could "undo" a move? They can select a skill, you can remove the TP, and when they move onto the next actor, they could ESC to go back and select another skill for the previous actor. If they do that, do you give them back the TP you've just taken from them? Not really expecting or requesting an answer - just pointing out that's the way it works, so you need to make sure you've considered it (even if you decide to do nothing about it)
The place I change $game_variables[7] is when the player selects the skill from the menu, as opposed to when the game subtracts TP from the actor, which seems to be after all the moves are assigned. So for the first move, $game_variables[7] is the same as the actor's TP, but for the second action of that same actor, the TP is still the same whilst the variable changes. In theory, anyway. 

And yes, when a player cancels a move, I could just add the value back to the variable under the prior_command bit of whichever script that's from (I don't know off the top of my head). Save the value subtracted in a local variable or something. 

Original thread: https://forums.rpgmakerweb.com/threads/disable-skill-through-script.38619/