Page 1 of 1
how to add a script to a class that executes on each lvl up
Posted: Sun Aug 26, 2012 11:02 pm
by nockermensch
Question is in the title.
I'm trying to create a new class and I'd like to run a function on each level up (on certain levels, the class would gain extra talents). How do I make this hook? Module is standart ToME4.
Also, on a more general question, is there some place where I can look for this kind of info? I'm trying to figure things by examining the existing lua scripts, with limited success so far.
Re: how to add a script to a class that executes on each lvl
Posted: Mon Aug 27, 2012 2:53 am
by catwhowalksbyhimself
I just put a list of hooks I on the wiki. There isn't an onlevelup on though, but DG did say to ask for more hooks if you needed them, so you might want to just ask him.
Re: how to add a script to a class that executes on each lvl
Posted: Mon Aug 27, 2012 2:59 am
by grayswandir
Take a look at the levelup defined in engine/interface/ActorLevel.lua.
It says something about checking self._levelup_info.
Or, you can just do your standard superloading, and superload levelup() in mod/Actor.lua. Make sure to call the original, and then just add a check for your class or something.
Re: how to add a script to a class that executes on each lvl
Posted: Mon Aug 27, 2012 6:01 am
by nockermensch
grayswandir wrote:Take a look at the levelup defined in engine/interface/ActorLevel.lua.
It says something about checking self._levelup_info.
Or, you can just do your standard superloading, and superload levelup() in mod/Actor.lua. Make sure to call the original, and then just add a check for your class or something.
I did this, copying the model shown in Zonk's Tweaked racials addon and it worked correctly. This game is amazingly moddable.
Thanks for the advice.