So, in my Superload, I have added the following to the kinetic shield talent:
on_learn = function (self, t)
self:learnTalent(T_SPIKE_ALL_SHIELDS, true, 1)
end
But it errors out with the message '}' expected (to close '{' at line 4) near 'sustain_psi', where the start bracket is the one that begins the kinetic shield talent, and the missing end bracket is immediately after the stuff I added. What's gone wrong?
Need coding help: on_learn
Moderator: Moderator
-
- Uruivellas
- Posts: 744
- Joined: Thu Nov 18, 2010 6:42 pm
Re: Need coding help: on_learn
Talents are handled in a special way. The talent definition files are loaded and then reinterpreted into tables that the game uses.
The simplest way to add to an existing talent defnition is probably with a hook.
Something like
If you need to modify a large number of talents, see http://forums.te4.org/viewtopic.php?f=36&t=35006
The simplest way to add to an existing talent defnition is probably with a hook.
Something like
Code: Select all
class:bindHook("ToME:load", function(self, data)
engine.interface.ActorTalents.talents_def.T_KINETIC_SHIELD.on_learn = <your function definition>
end)
Re: Need coding help: on_learn
Now my hooks file errors out with "unexpected symbol near )" in the final line.
Code: Select all
local class = require"engine.class"
local ActorTalents = require "engine.interface.ActorTalents"
class:bindHook("ToME:load", function(self, data)
ActorTalents:loadDefinition("/data-mindslayer-simplicity/talents/psionic.lua")
ActorTalents.talents_def.T_KINETIC_SHIELD.on_learn = function (self, t)
self:learnTalent(T_SPIKE_ALL_SHIELDS, true, 1)
end)
Re: Need coding help: on_learn
It looks like you are only ending one of the functions, and not the other. Add another "end" between the two last lines.