tdewitt274
January 2nd, 2011, 20:24
Can someone point me in the right direction? I'm looking to convert a value using a slash command from the chat window to increment a value.
Total = 0;
CurrVal = 0;
function IncrementIfGreater(params)
local msg = {};
if tonumber(params) == nil then
msg.text = "Not a number";
else
if CurrVal < tonumber(params) then
CurrVal = params;
end
Total = Total + CurrVal;
msg.text = Total;
end
deliverMessage(msg);
end
The tonumber() works fine to evaluate if the value is, in fact, a number. However, I receive "Script Error: [string "scripts/chatmanager.lua"]:321: attempt to compare function with string" when attempting to evaluate the number. I have also tried assigning the function to a variable, but the same error.
Thanks in advance!
Total = 0;
CurrVal = 0;
function IncrementIfGreater(params)
local msg = {};
if tonumber(params) == nil then
msg.text = "Not a number";
else
if CurrVal < tonumber(params) then
CurrVal = params;
end
Total = Total + CurrVal;
msg.text = Total;
end
deliverMessage(msg);
end
The tonumber() works fine to evaluate if the value is, in fact, a number. However, I receive "Script Error: [string "scripts/chatmanager.lua"]:321: attempt to compare function with string" when attempting to evaluate the number. I have also tried assigning the function to a variable, but the same error.
Thanks in advance!