Jump to content




[QUESTION] How to turn words into numbers


  • You cannot reply to this topic
7 replies to this topic

#1 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 27 October 2012 - 07:32 PM

Is there a way to turn words into numbers, and if there is, how?

Thanks

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 27 October 2012 - 07: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().

#3 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 27 October 2012 - 07:38 PM

but like "hello" into 4986

#4 Watcher7

  • Members
  • 25 posts
  • LocationEquestria, TX

Posted 27 October 2012 - 07: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 by Watcher7, 27 October 2012 - 07:42 PM.


#5 Doyle3694

  • Members
  • 815 posts

Posted 27 October 2012 - 07:42 PM

hello into 4986? why would that make sense?

#6 anonimo182

  • Members
  • 252 posts
  • LocationIn the universe

Posted 27 October 2012 - 07:45 PM

just an example :D/>

#7 faubiguy

  • Members
  • 213 posts

Posted 27 October 2012 - 07:46 PM

Do you want each word to become a random number?

#8 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 28 October 2012 - 11:36 AM

http://lua-users.org...LibraryTutorial try that one, string.byte should help you.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users