No, you can just throw code like this. Javascript need something called "context". So not all codes will work everywhere. Charge Tp By Action and Charge Tp By Damage have different contexts. And because of that I don't think you can use .results the same way.
If you want to do the inverse, then you can still use the same formula, but identify if the target is an actor or enemy. I will work out something for you, but before that, just clarify me this, to see if I understood you right:
If I'm not wrong, your formula was to let the player/party gain some tp values according to some conditions right? And now, you want for, when the player is being attacked, it loses tp according to the same conditions?
Copy and paste your final formula here, so I can work on it.

