Hook framework (a.k.a LoG Framework 2)
Re: Hook framework (a.k.a LoG Framework 2)
I will try it as soon as I get home and I let you know. Thank you very much
Re: Hook framework (a.k.a LoG Framework 2)
Oh, thanks a lot !JKos wrote:They are like event handlers. See LoG 1 documentation:Teto wrote:Sorry about my dumbness, what is a hook ? (it's not clear in the documentation, or I missed something)
http://www.grimrock.net/modding_log1/scripting-hooks/
Re: Hook framework (a.k.a LoG Framework 2)
Small bug fix: fw.script:remove('hook.identi.fier') didn't work.
Just update the fw.lua https://sites.google.com/site/jkoslog2/install/fw.lua
Just update the fw.lua https://sites.google.com/site/jkoslog2/install/fw.lua
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: Hook framework (a.k.a LoG Framework 2)
Guys, little help in here.
Iam trying to create hook for item onPickUpItem. But my code doesnt work
Iam trying to create hook for item onPickUpItem. But my code doesnt work
SpoilerShow
Code: Select all
fw.script:set('my_item@item.mymod.onPickUpItem',function()
hudPrint("picked up")
end)
Re: Hook framework (a.k.a LoG Framework 2)
That's because the game doesn't have a Item.onPickUpItem-hook, instead it has a party.onPickUpItem-hook. But since item.onPickupItem will be useful and it's easy to implement I added it to the framework.
Open fw_hooks.lua and replace party.onPickUpItem function definition with this:
Now it should work. I will update the fw_hooks.lua too soon, so if you don't want to modify it by hand you can wait that. But I decided to post this as an example that shows how you can add your own hooks to the framework. It's possible to call executeEntityHooks from script entities too, so if you want to handle your custom events through the framework, it's really easy.
Open fw_hooks.lua and replace party.onPickUpItem function definition with this:
Code: Select all
onPickUpItem = function(self, item)
if fw.script:executeEntityHooks('item','onPickUpItem',item) == false then
return false
end
return fw.script:execute('party','onPickUpItem',self, item)
end,
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: Hook framework (a.k.a LoG Framework 2)
WoW I will test it, if I get home and let you know if I have any problems. Many thx for help
Re: Hook framework (a.k.a LoG Framework 2)
Hello, JKos. I've got an item that gains a secondary action. A new MeleeAttack component is created named specialattack and then the item's secondaryAction is set to specialattack and the other properties of the attack are then defined in script (attackPower, Cooldown, etc). weapon.go.id correctly returns the id of the item in question, though nothing prints (The specialattack secondaryAction is available and performs without error, of course). What have I done wrong?
Code: Select all
fw.script:set(weapon.go.id .. '@specialattack.mymod.onHitMonster', function()
print("HIYA! ")
end)
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.
Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
Re: Hook framework (a.k.a LoG Framework 2)
By default the framework only works with components which are named by the class name. That's because we can't access the component name from the scripts, so I can't do anything about it.
But if you really need to to use the framework with custom named components you can do it like this.
Now it should work. And as you can see, the name of the component and hook method are hard coded.
But if you really need to to use the framework with custom named components you can do it like this.
Code: Select all
{
class = "MeleeAttack",
name = "specialattack",
attackPower = 16,
accuracy = 0,
damageType = "shock",
cooldown = 3.7,
swipe = "vertical",
attackSound = "swipe",
requirements = { "light_weapons", 1 },
onHitMonster = function(self, monster, tside, damage, champion)
return fw.script:executeEntityHooks('specialattack','onHitMonster',self, monster, tside, damage, champion)
end,
},
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
- Eleven Warrior
- Posts: 746
- Joined: Thu Apr 18, 2013 2:32 pm
- Location: Australia
Re: Hook framework (a.k.a LoG Framework 2)
Hi all sorry about this I have tried this as a test and it's not working could someone tell where imam going wrong.. Is it possible if we could get more demo's on how to do things, just simple stuff
The error I get is: attempt to index global 'weapon' ('a nil value')
I did just copy and paste the dagger out of the Assets lua Script.
Object: my_dagger.
Script Code in Editor:
EDIT: Say a player picks up a item you could have a huPrint, sound etc.. How do you do this? Thxs for any help.
The error I get is: attempt to index global 'weapon' ('a nil value')
I did just copy and paste the dagger out of the Assets lua Script.
Object: my_dagger.
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" },
},
{
class = "MeleeAttack",
attackPower = 7,
accuracy = 5,
cooldown = 2.5,
swipe = "vertical",
attackSound = "swipe_light",
powerAttackTemplate = "throw",
onHitMonster = function(self, monster, tside, damage, champion)
return fw.script:executeEntityHooks('specialattack','onHitMonster',self, monster, tside, damage, champion)
end,
},
},
tags = { "weapon" },
}
Code: Select all
fw.script:set(weapon.go.id .. 'specialattack.mymod.onHitMonster', function()
print("Why did you hit me? ")
end)