tonumber

From ComputerCraft Wiki
Revision as of 21:23, 28 November 2012 by AfterLifeLochie (Talk | contribs) (Added to CAT:LuaForeFunctions.)

Jump to: navigation, search


Grid Redstone.png  Function tonumber
Converts a string into a number
Syntax tonumber(string to be converted into a number (needs to be a number))
Returns nil
Part of ComputerCraft
API none

Examples

Grid paper.png  Example
Converts the strings into numbers and adds the together. (It would be more intelligent to just save it as a number.)
Code
number1 = "10"
number2 = "5"
print (number1, " + ", number2, " = ", tonumber (number1) + tonumber (number2))
Output 10 + 5 = 15