doing arithmetic on tables

All development conversation and discussion takes place here

Moderator: Moderator

Post Reply
Message
Author
lifanov
Cornac
Posts: 32
Joined: Sat Jan 14, 2012 12:53 am

doing arithmetic on tables

#1 Post by lifanov »

v can be a table here. This silences the error (tonumber of nil is nil and tonumber of not a number is nil):

Code: Select all

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index a47492e..0d6d26a 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -1715,7 +1715,7 @@ function _M:tooltip(x, y, seen_by)
 
        local retal = 0
        for k, v in pairs(self.on_melee_hit) do
-               if v then retal = retal + v end
+               if tonumber(v) then retal = retal + v end
        end
 
        if retal > 0 then ts:add("Melee Retaliation: ", {"color", "RED"}, tostring(math.floor(retal)), {"color", "WHITE"}, true ) end

darkgod
Master of Eyal
Posts: 10750
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

Re: doing arithmetic on tables

#2 Post by darkgod »

thanks :)
[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 ;)

lifanov
Cornac
Posts: 32
Joined: Sat Jan 14, 2012 12:53 am

Re: doing arithmetic on tables

#3 Post by lifanov »

I can confirm that this is fixed for me.

Post Reply