ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Thu Jul 27, 2017 8:37 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Feb 20, 2016 6:56 pm 
Offline
Higher

Joined: Thu Jan 14, 2016 11:10 am
Posts: 63
More specifically, what I want to do is make a function that checks for infravision range and adds to that up to a certain maximum. However, if the character doesn't have infravision, trying to do maths on infravision causes errors. I've had this issue before with other values (most recently heightened senses), but just given up after a while. This is the current code for the talent, and the way it's gotten the furthest before frakkin' up:

Code:
newTalent{
   name = "IVTest",
   type = {"undead/ghoul", 1},
   mode = "passive",
   require = undeads_req1,
   points = 5,
   getInfra = function(self, t) return self:attr("infravision") or 0 end,
   getVision = function(self, t) return math.floor((3 + self:getTalentLevel(t)) * (1+0.01*self:getCun(s))) end,
   passives = function(self, t, p)
      self:talentTemporaryValue(p, "infravision", math.min((t.getInfra + 4), t.getVision(self, t)))
   end,
   info = function(self, t)
      return ([[Your infravision range is increased by 4 to a maximum of %d. The maximum range scales with Cunning. ]])
   :format(t.getVision(self, t))
   end,
}


Googling around a bit I found out about using the "or 0" to provide an out for when infravision doesn't exist, but it still gives me an error ("trying to perform arithmetics on field 'getInfra' (a function value)").

This seems like it should be easy to do, and seems essential for quite a number of purposes - anyone can fill me in on how to do it? Thanks! :)


Top
 Profile  
 
PostPosted: Sat Feb 20, 2016 7:29 pm 
Offline
Master of Eyal

Joined: Wed Jul 24, 2002 9:26 pm
Posts: 10124
Location: Angolwen
"or 0" is indeed correct.

getInfra thoguh you're not actually calling it; you do "t.getInfra + 4" instead of "t.getInfra(self, t) + 4"

_________________
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)


Top
 Profile  
 
PostPosted: Sat Feb 20, 2016 8:41 pm 
Offline
Higher

Joined: Thu Jan 14, 2016 11:10 am
Posts: 63
d'oh! Thank you.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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