This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
anonimo182's profile picture

[QUESTION] How to turn words into numbers

Started by anonimo182, 27 October 2012 - 06:32 PM
anonimo182 #1
Posted 27 October 2012 - 08:32 PM
Is there a way to turn words into numbers, and if there is, how?

Thanks
Lyqyd #2
Posted 27 October 2012 - 08:33 PM
If you mean turning "one" into 1, you'd need a lookup table. If you mean turning "1" into 1, you need tonumber().
anonimo182 #3
Posted 27 October 2012 - 08:38 PM
but like "hello" into 4986
Watcher7 #4
Posted 27 October 2012 - 08:40 PM
Also, there is something called coercion. Coercion in Lua basicly implies a type change during things like (addition | subtraction | division | multiplication).
EX:
> =( 1 + '1' + "1" )
3


(EDIT:
Seems like the forums didn't alert me to a new post…)
Edited on 27 October 2012 - 06:42 PM
Doyle3694 #5
Posted 27 October 2012 - 08:42 PM
hello into 4986? why would that make sense?
anonimo182 #6
Posted 27 October 2012 - 08:45 PM
just an example :D/>/>
faubiguy #7
Posted 27 October 2012 - 08:46 PM
Do you want each word to become a random number?
sjele #8
Posted 28 October 2012 - 11:36 AM
http://lua-users.org/wiki/StringLibraryTutorial try that one, string.byte should help you.