Weapon reference in formula box

I've searched the forms for 2 hours and can't find the answer to what I'm looking for.
Basically I want to force a skill used if equipped with a certain weapon otherwise it's a standard attack.
I've tried a.weapons[N]; a.force_action(n, -2): a.atk but it errors out.
My Ruby coding isn't the best and maybe I'm just sleepy. What am I doing wrong?
Thanks in advance
Code:
a.equip_slots[slot]  #returns type of item

or

a.weapons[index] #returns item object

all items equipped by an actor are grouped under @equips.
actor.weapons returns @equips.select{|item| item.is_weapon?}
check actor.equip_slots, actor.equips and actor.change_equip, you can probably follow the code from there.
Code:
a.weapons[0].id == weapon_id
You can use this as well

Edit: It may return an error if your character does not equip any weapon though

Original thread: https://forums.rpgmakerweb.com/threads/weapon-reference-in-formula-box.90588/