Storing Skill ID into variable and being able to use it later en masse

So here's what I'd like to do;

I want to store the ID of a skill into a variable so that I can use that in a script call for conditional branches or to learn said skill.

I need something along these lines:

◆Script:$gameVariables.setValue(94, $dataSkills[358]);
◆Script:$gameActors.actor(1).learnSkill($gameVariables.value(94));

OR

◆Script:$gameVariables.setValue(94, $dataSkills[358]);
◆If:Script:$gameActors.actor(1).canUse($gameVariables.value(94))
◆
:End

This way, I could just assign my skill to a variable at the beginning of an event and didn't have to edit every instance of where said skill is referenced because every instance is already replaced by the variable.

EDIT: Okay I tested around a little more and it turns out I am just stupid.
For anyone that is interested, here is my solution:


◆Script:$gameVariables.setValue(X, Y);
◆Script:$gameActors.actor(Z).learnSkill($gameVariables.value(X));

X = The variable that stores the Skill ID
Y = The Skill ID
Z = ID of the actor that is supposed to learn the skill

For the conditional branch:

◆If:Script:$gameActors.actor(Z).isLearnedSkill($gameVariables.value(X))

Anyways, my issue is basically solved now, I feel really stupid finding the solution myself right after I post a thread for it.
Perhaps this would do:

$gameActors.actor(1)._lastBattleSkill._itemId

but this will also return some value if item was used on ally/enemy.
Please note this if you strictly put returned ID into variable and your code strictly reads only skills you may have some weird results (for example it says, "I used ${skillId} wich reads only skills the message box may say something different what was used (if item was used)) so to avoid this issue place this code before damage formula:

$gameVariables.setValue(94, a._lastBattleSkill._itemId); ( https://prnt.sc/wih1ah )

("a" in skill formula refers to user of skill)

then actual damage formula for all your skills.

That way variable will assign value of skill ID only when skill was used and not item.
@Soulrender Haha thank you for your time and effort, but I solved the issue myself.
Though I do feel bad a little since you seemed to go into great detail to help me. So I shall note your tips in case i need them later.

Also, for some more context, this wasn't for anything battle-related.
I needed this for my Monster-Trainer, basically, an NPC that can teach you skills from monsters.

There are going to be A LOT of these NPC's and each of them reference their respective Skill a lot.
So I wanted to spare me some time changing the skills for each and every trainer by just assigning their skill to a variable and using said variable for every instance of this NPC.
No problem, just a little tip:
damage formula is simply JS evaluation code, so putting any code before damage formula will cause that code to execute, so you can make many creative spells 🙂 Although this text box may be pain in a** so also you can type there functions from JS plugins to execute, it's easy and fun! 🙂

Original thread: https://forums.rpgmakerweb.com/threads/storing-skill-id-into-variable-and-being-able-to-use-it-later-en-masse.131934/