That error is caused by your script, not the framework. As the message clearly says, the weapon variable is not defined.
And in your example you can just use fw_addHooks because you are using meleeAttack component with default name, no need to call fw.script:executeEntityHooks
Working example:
Code: Select all
defineObject{
name = "my_dagger",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/dagger.fbx",
},
{
class = "Item",
uiName = "Dagger",
gfxIndex = 10,
gfxIndexPowerAttack = 415,
impactSound = "impact_blade",
weight = 0.8,
projectileRotationX = 90,
projectileRotationY = 90,
description = "A vicious looking dagger, which is effective in close combat as well as from a distance. The dagger is the favorite weapon of many a rogue.",
traits = { "light_weapon", "dagger" },
},
fw_addHooks{
class = "MeleeAttack",
attackPower = 7,
accuracy = 5,
cooldown = 2.5,
swipe = "vertical",
attackSound = "swipe_light",
powerAttackTemplate = "throw",
},
},
tags = { "weapon" },
}
Code: Select all
fw.script:set('my_dagger@meleeattack.mymod.onHitMonster', function(hook,item,monster)
print( "Why did you hit me? ")
end)