ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Tue Oct 16, 2018 8:45 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Dec 12, 2017 9:07 pm 
Offline
Thalore

Joined: Mon Mar 25, 2013 9:39 am
Posts: 165
Simple talents have

Code:
racial_req2 = {
        stat = { str=function(level) return 20 + (level-1) * 2 end },
        level = function(level) return 6 + (level-1)  end,
}
...
newTalent{
        shortname = x
        name = y
        type = z
        require = racial_req2,


i want to have a talent that doesn't depend on a stat (nor on a talent, which is described in the guide in the post above).

I've tested that this works

Code:
require = { special={desc="After level 4, you can only study further when not wearing armour on your body and your feet", fct=function(self) return ((self.getTalentLevel(t) <= 4) or (self.GetTalentLevel(t) > 4 and not self:getInven("BODY") and not self:getInven("FEET"))) end} },


but, how can I combine this with a stat requirement? I can't find any example in the source.


Top
 Profile  
 
PostPosted: Tue Dec 12, 2017 10:57 pm 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5759
Put a comma after your special={...} bit and add your stat={...} there.

_________________
My feedback meter decays into coding. Give me feedback and I make mods.


Top
 Profile  
 
PostPosted: Wed Dec 13, 2017 5:27 pm 
Offline
Thalore

Joined: Mon Mar 25, 2013 9:39 am
Posts: 165
unfortunately,

Code:
racial_req1 = {
        stat = { str=function(level) return 12 + (level-1) * 5 end },
        level = function(level) return 0 + (level-1)  end,
}
...
require = { special={desc="After level 4, you can only study further when not wearing armour on your body and your feet", fct=function(self) return ((self.getTalentLevel(t) <= 4) or (self.GetTalentLevel(t) > 4 and not self:getInven("BODY") and not self:getInven("FEET"))) end}, racial_req1 },


does not show any strength needs on the screen. Did I understand you incorrectly?

On looking at ActorTalents.lua, I see

Code:
function _M:canLearnTalent(t, offset, ignore_special)
        -- Check prerequisites
        if rawget(t, "require") then
                local req = t.require
                if type(req) == "function" then req = req(self, t) end
                local tlev = self:getTalentLevelRaw(t) + (offset or 1)

                -- Obviously this requires the ActorStats interface
                if req.stat then
                        for s, v in pairs(req.stat) do
                                v = util.getval(v, tlev)
                                if self:getStat(s) < v then return nil, "not enough stat: "..s:upper() end
                        end
                end
                if req.level then
                        if self.level < util.getval(req.level, tlev) then
                                return nil, "not enough levels"
                        end
                end
                if req.special and not ignore_special then
                        if not req.special.fct(self, t, offset) then
                                return nil, req.special.desc
                        end
                end
                if req.talent then
                        for _, tid in ipairs(req.talent) do
                                if type(tid) == "table" then
                                        if type(tid[2]) == "boolean" and tid[2] == false then
                                                if self:knowTalent(tid[1]) then return nil, "missing dependency" end
                                        else
                                                if self:getTalentLevelRaw(tid[1]) < tid[2] then return nil, "missing dependency" end
                                        end
                                else
                                        if not self:knowTalent(tid) then return nil, "missing dependency" end
                                end
                        end
                end
        end


really nothing that iterates over multiple entries after require. Should I conclude this just can't be done?


Top
 Profile  
 
PostPosted: Wed Dec 13, 2017 11:28 pm 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5759
Since most talents already have both a stat and level requirement, I'd say there really is something that the iterates over multiple requirements.
I suspect your code isn't working because you have require = { special = {...}, { stat = ... , level = ... } }.
The code isn't expecting a table inside the requirements table.

_________________
My feedback meter decays into coding. Give me feedback and I make mods.


Top
 Profile  
 
PostPosted: Thu Dec 14, 2017 2:55 pm 
Offline
Thalore

Joined: Mon Mar 25, 2013 9:39 am
Posts: 165
Right!

Code:
require = { special={desc="After level 4, you can only study further when not wearing armour on your body and your feet", 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 },


works! :lol:

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group