Karuzo Posted August 10, 2014 Share Posted August 10, 2014 Hey Guys, I wanted to ask if there is a possibility to check if a text from an edit box is a number and not a string. But as guiGetText retursn the text as a string idk how to solve this. I think i could do it with a table which is filled with numbers and check if its a number. But is there no other way to do this? Link to comment
xXMADEXx Posted August 10, 2014 Share Posted August 10, 2014 (edited) You can just simply use tonumber. Example: if ( not tonumber ( guiGetText ( myEdit ) ) ) then return outputChatBox ( "Invalid number" ) end Edited August 10, 2014 by Guest Link to comment
Castillo Posted August 10, 2014 Share Posted August 10, 2014 local number = tonumber ( guiGetText ( myGUIElement ) ) if ( number ) then -- is a number end Link to comment
Et-win Posted August 10, 2014 Share Posted August 10, 2014 http://www.lua.org/manual/5.1/manual.html#pdf-tonumber 'tonumber' returns 'nil' if the given string is not a number. Link to comment
Karuzo Posted August 10, 2014 Author Share Posted August 10, 2014 Ah yeah, that i didn't come up with this idea Thanks. Link to comment
#DRAGON!FIRE Posted August 10, 2014 Share Posted August 10, 2014 also u can use "onClientGUIChanged" and Cheek if the text not number return end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now