Tonumber

From ComputerCraft Wiki
Revision as of 10:09, 8 July 2012 by Banane9 (Talk | contribs) (created the page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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