Trying to write a party onTurn hook
Posted: Fri May 15, 2015 11:14 am
Hi There,
I'm quite new on LoG2 scripting. For one of my puzzle I'd like to test wether my party has turned using the onTurn Party hook.
After reading this excellent topic viewtopic.php?f=14&t=5803&hilit=+hook, I try doing the same in my LoG2 dungeon editor.
I was following the 3 steps, apart the third step which I adapt to LoG2 like described here : viewtopic.php?f=22&t=7642
The code in my party_hooks.lua file is (actually I only need onTurn hook) :
In my dungeon editor I create an lua script named 'hooks' containing :
Until here all is OK, dungeon is starting correctly. When my party is turning on the following occurs:
I don't see my mistake, could someone light my way ? Any help would be appreciate.
N.B. Calling print(hooks) into onTurn function (insteed of print(party.go.id,"turning to",dir) ) returns a table...
I'm quite new on LoG2 scripting. For one of my puzzle I'd like to test wether my party has turned using the onTurn Party hook.
After reading this excellent topic viewtopic.php?f=14&t=5803&hilit=+hook, I try doing the same in my LoG2 dungeon editor.
I was following the 3 steps, apart the third step which I adapt to LoG2 like described here : viewtopic.php?f=22&t=7642
The code in my party_hooks.lua file is (actually I only need onTurn hook) :
Code: Select all
defineObject{
name = "party",
baseObject = "party",
components = {
{
class = "Party",
onTurn = function(party,dir,arg1)
--print(party.go.id,"turning to",dir)
return hooks.party_onTurn(party, dir)
end
}
},
}
Code: Select all
function party_onTurn(party, dir)
print (dir)
end
Code: Select all
mod_assets/scripts/party_hooks.lua:9: attempt to call field 'party_onTurn' (a nil value)
stack traceback:
mod_assets/scripts/party_hooks.lua:9: in function <mod_assets/scripts/party_hooks.lua:7>
...
N.B. Calling print(hooks) into onTurn function (insteed of print(party.go.id,"turning to",dir) ) returns a table...