Check Current Skill Being Used (Help)

Is there a way to access the current skill that's being used?


I'm wondering if there is an eval or JS code to check, but I'm not too familiar with those. I have been trying
 


if (this.Skill().damage.elementId === physical)


Which was an attempt to check the current skill's element (whether it was physical, fire, etc). I saw somewhere a similar piece of code for checking the item being used, so thought that could work and from there I could figure out how to check the actual skill ID, but no luck.

Edit: Replacing 'physical' with the actual ID numbers of the elements didn't work either.

Edit 2: 
if (this.action.skillId() == 404)
gives me "Cannot read property of 'skillId' of undefined.
I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.
This depends on where you are trying to check the skill.
This depends on where you are trying to check the skill.



I'm trying to check the skill during battle while the skill itself is being executed. 
Why: I'm using Yanfly's Action Sequence <action copy> tag to copy the action sequences from another skill/item. This is to make it easier on myself in editing skills and animations. It would be useful to me if the Action Sequence being called via <action copy> can differentiate which skill is calling it.

There's a game eval option, so I didn't think it was necessarily a Yanfly-specific question.
(And sorry @ Mod for posting in the wrong section)
I'm trying to check the skill during battle while the skill itself is being executed. 
Why: I'm using Yanfly's Action Sequence <action copy> tag to copy the action sequences from another skill/item. This is to make it easier on myself in editing skills and animations. It would be useful to me if the Action Sequence being called via <action copy> can differentiate which skill is calling it.

There's a game eval option, so I didn't think it was necessarily a Yanfly-specific question.
(And sorry @ Mod for posting in the wrong section)

You can use


this._action.item().id


in the action sequence eval to get the id of the skill/item being used.


example that prints to the console the id:

Code:
eval: console.log(this._action.item().id);
if (this.action.skillId() == 404)
gives me "Cannot read property of 'skillId' of undefined.

I think the problem is that 'this.' references something different from what you may have supposed.


Try referencing directly with 'BattleManager.' or probably 'BattleManager.actor().'


I'm not sure whether it will work, but you may give it a try.
I think the problem is that 'this.' references something different from what you may have supposed.


Try referencing directly with 'BattleManager.' or probably 'BattleManager.actor().'


I'm not sure whether it will work, but you may give it a try.


You can use



this._action.item().id


in the action sequence eval to get the id of the skill/item being used.


example that prints to the console the id:



eval: console.log(this._action.item().id);


Okay, so I was not successful. My set up:

Skill ID 411: <action copy: skill:414>


Skill ID 412: <action copy: skill:414>


Skill ID 414: Long action sequence, but the key part is:


eval: $gameVariables.setValue(86, X);
if ($gameVariables.value(86) == 411)
add state 178: user
else if ($gameVariables.value(86) == 412)
add state 176: user
end


I can replace X with 411 or 412 and it enters the if else branch correctly.


Replacing X with:
this._action.skill().id                                    ( undefined is not a function )
BattleManager._action.skill().id                   ( undefined is not a function )
BattleManager.actor()._action.skill().id        ( Error: Cannot read property '_action' of null )
BattleManager.action.skillId()                      ( Error: Cannot read property 'skillId' of undefined )
BattleManager.actor().action.skillId()           ( Error: Cannot read property 'action' of null )


Edit 3:

BattleManager.actor().this._action.skill().id   ( Cannot read property 'this' of null )
BattleManager.this._action.skill().id               ( Cannot read property '_action' of undefined )
I don't know if you put script in formula or what?!


but try this if you want it in formula


a._lastBattleSkill._itemId
BattleManager.actor().this._action.skill().id   ( Cannot read property 'this' of null )
BattleManager.this._action.skill().id               ( Cannot read property '_action' of undefined )

You got me wrong. Please see what 'this' is: http://www.quirksmode.org/js/this.html


In short, 'this.' is similar to link which stands for current scope of the function/object.


You should have tried 'BattleManager.' or 'BattleManager.actor().' instead of 'this.'


I am also not sure whether '_action' will work for you, as I cannot find any definition that 'skill()' is its property. Why did you opt for this '_action'?
@Yurii I also tried it without using 'this.' in the four examples above Edit 3.
I tried '_action' because that was from what DreamX suggested I try.

@mrcopra I'm working inside the note box as I'm working with Yanfly's Action Sequences.
Is it " a._lastBattleSkill._itemId " with both Skill and item? Or do I change " item " to " skill "?
And in the set up I described... do I put that in Skill ID 411/412 or Skill ID 414?

I also tried calling different common events with Skills 411 and 412 (via the Effects section) that set switch 86 to different values so that Skill 414 (when called via <action copy>) would enter the relevant branch, but the common event wasn't being called.

--------------------
EDIT: Well I found a work around using the lunatic coding of Yanfly's Skill Core.

(Example) Skill ID 411:
 


<Custom Execution>


$gameVariables.setValue(86, 2);


</Custom Execution>


<action copy: skill:414>

So I just have to change the custom execution accordingly for each skill that would call 414 and it should work.
I wouldn't mind still learning how to do what I was doing before though.

Original thread: https://forums.rpgmakerweb.com/threads/check-current-skill-being-used-help.66736/