295 posts
Location
In the TARDIS at an unknown place in time.
Posted 15 October 2012 - 04:43 AM
Okay, I'm trying to make an automatic converter(int to string and string to int), so here's one of the functions:
function intstring(name)
(name.."string") = tostring(name) -- Errors Here
end
I guess (name.."string") is the problem, but how can I revise this to fix the error?
475 posts
Posted 15 October 2012 - 05:31 AM
Don't put quotes around string?
295 posts
Location
In the TARDIS at an unknown place in time.
Posted 15 October 2012 - 05:36 AM
Don't put quotes around string?
No, I need that, like here's what I need it like:
You enter
test = 5
intstring(test)
And you get "teststring".
1688 posts
Location
'MURICA
Posted 15 October 2012 - 05:39 AM
The way you're doing it is kind of "what are you even doing I don't understand this shouldn't even be possible".
You should probably just check to see if it's an integer or string first before converting.
function intstring(var)
if type(var) == 'string' then
return math.floor(tonumber(var)) -- math.floor so there are no decimals
elseif type(var == 'number' then
return tostring(var)
end
end
…Unless this isn't what you're trying to do. :/
62 posts
Location
Australia
Posted 15 October 2012 - 06:35 AM
The way you're doing it is kind of "what are you even doing I don't understand this shouldn't even be possible".
This amused me :D/>/>
But I agree with you, OP has me confused…