Make variable X equal to Actor or Enemy Y's current TP?

Ultimately, I'll want to make that actor or enemy be affected by a state if that variable is equal to 100, but this can be done without extra scripting.  Unfortunately, TP is not, by default, an option you can choose when making a variable equal to an actor's parameter.  I'd like to get a simple script to attach to a Control Variables event that calls for actor X's current TP and another that calls for enemy X's current TP.  If it affects anything, I have changed TP's name to SP in this case.
Ultimately, I'll want to make that actor or enemy be affected by a state if that variable is equal to 100, but this can be done without extra scripting.  Unfortunately, TP is not, by default, an option you can choose when making a variable equal to an actor's parameter.  I'd like to get a simple script to attach to a Control Variables event that calls for actor X's current TP and another that calls for enemy X's current TP.  If it affects anything, I have changed TP's name to SP in this case.

tape in console


$gameActors.actor(1)


to found tp state
For actors:


$game_actors[ID].tp


The ID is the database ID of the actors.


For enemies (only in battle):


$game_troop.members[index].tp


The index is the troop index of the enemy in the battle.


If you use an ABS, you must get the enemy assigned to the event and call the tp method on that.


You can use these in Control Variables event commands.
Sixth, I've tried your method, and I get the following error after inputting commands.

Script 'Game_Interpreter' line 543: NoMethodError occurred.


unidentified method 'tp' for nil:NilClass



This is my first time scripting in RPG Maker VX Ace, so I'm not sure what I may have done wrong, but here's a screenshot of the event.


State 26 Check.png
You did not use the brackets I used, these ones: [ ] .


The ID of the actors and index of the enemies must be inside those brackets.
Yeah, I tried it that way, too.  I did that first, actually.  Got the same error.
If that event is run on the map, you will get a NoMethodError.


There are no enemies on the map at all, so trying to get a member from $game_troop will yield a nil, and nil got no tp method/variable defined, and the error triggers.


You can't use $game_troop at all on the map, only in battles.
Could the fact I did the battle in a Troop test be the cause?
Ahh, I see, you counted the troop members from 1 instead of 0.


If we talk about indexes (mostly anywhere in scripting), they start from 0 instead of 1.


So change the troop member indexes to 0, 1 and 2, and it should work, assuming your troop got at least 3 members in it.
And that did it!  Thanks so much for sticking with me through this whole thing.

Original thread: https://forums.rpgmakerweb.com/threads/make-variable-x-equal-to-actor-or-enemy-ys-current-tp.67351/