talent function: info fine on hover, not on autouse?

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
Jurriaan
Wyrmic
Posts: 227
Joined: Mon Mar 25, 2013 9:39 am

talent function: info fine on hover, not on autouse?

#1 Post by Jurriaan »

I have coded a talent, which has an info() function.
This works just fine when I hover the mouse over the icon in the main screen, and when I hover the mouse over the icon in the levelup screen.

When I try to select it for auto-use, I get

Code: Select all

Lua Error: /engine/interface/ActorTalents.lua:82: bad argument #3 to 'info' (number expected, got nil)
        At [C]:-1 
        At [C]:-1 info
        At /engine/interface/ActorTalents.lua:82 info
        At /mod/class/Actor.lua:5791 getTalentFullDescription
        At /mod/dialogs/UseTalents.lua:317 generateList
        At /mod/dialogs/UseTalents.lua:69 init
        At /engine/class.lua:147 new
        At /mod/class/uiset/Minimalist.lua:1797 on_click
        At /engine/HotkeysIconsDisplay.lua:378 onMouse
        At /mod/class/uiset/Minimalist.lua:1789 fct
        At /engine/Mouse.lua:58 
ActorTalents.lua:82 contains

Code: Select all

--- Defines one talent
-- Static!
function _M:newTalent(t)
.... snip for brevity
-- Remove line stat with tabs to be cleaner ..
local info = t.info
[i] t.info = function(self, t) return info(self, t):gsub("\n\t+", "\n") end[/i]
t.id = "T_"..t.short_name
82 is the line in italic.

So it has something to do with the displaying of the information, right?

The talent looks like this:

Code: Select all

newTalent{
        -- shortname gives icon name
        shortname = 'MOUNTAINTROLLSMASHDOWN',
        name = "Smash Down",
        type = {"race/mountaintroll", 1},
        -- at level 5, prevent increase when wearing body / feet armour
        require = { special={desc="After level 4, you can only study further when not wearing armour on your body and your feet. Learning this skill automatically gains you equal experience in Dual Weapon Mastery. Note that this skill cannot be unlearned, your experience will be with you always", fct=function(self) return ((self.getTalentLevel(t) <= 4) or (self.GetTalentLevel(t) > 4 and not self:getInven("BODY") and not self:getInven("FEET"))) end}, stat = { str = function(level) return 12 + (level-1) * 5 end }, level = function(level) return 0 + (level-1) end },

        points = 10,
        random_ego = "attack",
        cooldown = 6,
        stamina = function(self, t) return 7 + self:getTalentLevelRaw(t) end,
        tactical = { ATTACK = { weapon = 2 }, DISABLE = { daze = 2 } },
        requires_target = true,
        getDamage = function(self, t) return self:combatTalentWeaponDamage(t, 0.7, 2.5) end,
        getDuration = function(self, t) return math.floor(self:combatTalentScale(t, 3, 7)) end,
        target = function(self, t) return {type="hit", range=self:getTalentRange(t)} end,
        range = 1,
        no_unlearn_last = true,
        on_learn = function(self, t)
                self:learnTalent(self.T_DUAL_WEAPON_MASTERY, true, self:getTalentLevelRaw(t), {nu_unlearn=true})
                if self:getTalentLevel(t) >= 5 then self:attr("allow_mainhand_2h_in_1h", 1) end
        end,

        action = function(self, t)
                local tg = {type="hit", range=self:getTalentRange(t)}
                local x, y, target = self:getTarget(tg)
                if not x or not y or not target then return nil end
                if core.fov.distance(self.x, self.y, x, y) > 1 then return nil end
                local hitted = self:attackTarget(target, nil, t.getDamage(self, t), true)

                if hitted then
                        if target:canBe("dazed") then
                                target:setEffect(target.EFF_DAZED, t.getDuration(self, t), {apply_power=self:combatAttack()})
                        end
                        if not target:hasEffect(target.EFF_DAZED) then
                                game.logSeen(target, "%s resists the daze!", target.name:capitalize())
                                self.energy.value = self.energy.value + game.energy_to_act * self:combatSpeed()
                        end
                end

                return true
        end,
        info = function(self, t)
                return ([[Smash! Smash an overhead blow on the enemy for %d%% damage, attempting to daze it for %d turns. If the daze fails, you regain your turn. At talent level 5, you have trained your muscles enough to wield a 2 handed weapon in your main hand, but no armour on your body or feet will fit you anymore. At level 10, you can wield 2 handed weapons in each hand. Daze chance increases with your Accuracy.]]):format(100*t.getDamage(self,t), t.getDuration(self,t))
        end,
}
how can the info() function work on the main screen, but not when selecting auto-use?

Jurriaan
Wyrmic
Posts: 227
Joined: Mon Mar 25, 2013 9:39 am

Re: talent function: info fine on hover, not on autouse?

#2 Post by Jurriaan »

I went back to an older version, entered my changes block by block, and it's gone. There must have been some obscure typo somewhere...

Post Reply