I have the following function in Lua:
function iffunc(k,str,str1) if k ~= 0 then return str .. k .. (str1 or "") end end
This function allows me to check if the value of k is full or not. I actually use it to determine if I want to display something that has a null value. My problem is this: I am trying to concatenate the iffunc () string, but since some of the values ββare 0, it returns an error when trying to match the nil value. For instance:
levellbon = iffunc(levellrep["BonusStr"],"@ wStr@r {@x111","@r}") .. iffunc(levellrep["BonusInt"],"@ wInt@r {@x111","@r}") .. iffunc(levellrep["BonusWis"],"@ wWis@r {@x111","@r}")
If any of the table values ββis 0, it will return an error. I could easily put "return 0" in iffunc itself; however, I also do not want a string of thousands. So, how can I work, where no matter what values ββare zero, I will not get this error? Ultimately, I'm going to make an iffunc in the levellbon variable to see if it is full or not, but I have this part. I just need to overcome this little obstacle right now. Thanks!
source share