Save Item ID as Variable

I’ll see what I can do, but up to this point my attempts at making a common event have caused the game to crash.
@ATT_Turan 's suggestion unfortunately cannot work, as the variable will be looked at but only once when the database is loaded. Whatever value the variable has at that point in time (presumably undefined) will be the source for the action copy.

However looking at that problem gave me another idea. <Custom Execution> notetags from the skills core should get evaluated before any action sequence takes place, right? So we should be able to use that to copy an action sequence, I think.
JavaScript:
<Custom Execution>
    $dataSkills[x].setupActions = $dataItems[$gameVariables.value(y)].setupActions.slice();
    $dataSkills[x].wholeActions = $dataItems[$gameVariables.value(y)].wholeActions.slice();
    $dataSkills[x].targetActions = $dataItems[$gameVariables.value(y)].targetActions.slice();
    $dataSkills[x].followActions = $dataItems[$gameVariables.value(y)].followActions.slice();
    $dataSkills[x].finishActions = $dataItems[$gameVariables.value(y)].finishActions.slice();
</Custom Execution>

Replace x with the id of your item copy skill and ywith the id of the variable you are using to track the last used item.
This doesn't seem to have worked, unfortunately.
Can you please provide a bit more detail? What happens instead? Are there any crashes or is the item simply not copied?
Can you please provide a bit more detail? What happens instead? Are there any crashes or is the item simply not copied?
The character performs the action, does the animation, and nothing happens. The game doesn’t crash. She uses the skill and it does nothing.

Original thread: https://forums.rpgmakerweb.com/threads/save-item-id-as-variable.151963/