I could understand this if I was passing an array or table, but I would think that a string or number value would get passed as a string or number. Needless to say, in the receiving function 'pt(a)', the error -attempting to perform arithmetic on a table value- is generated in the second line. Can anyone tell me why arguments get passed as a table when calling a function in another script? What I am doing wrong?
Code: Select all
function argTest() --main function
local n = 10
n = pt(n)
print(n) --> (prints 15)
end
function pt(a) --called function
return a + 5
end
But if 'function pt(a)' is placed in another script ( call it 'test_pass' ), it does not work:
function argTest() --main function
local n = 10
n = test_pass:pt(n)
print(n)
end
-- <OTHER SCRIPT> 'test_pass'
function pt(a) --called function in script 'test_pass'
return a + 5 --error generated here
end