Captain Cody Posted November 7, 2016 Share Posted November 7, 2016 (edited) is there any possible way (Other then tables or if statements) to convert strings to boolen? -- "true" -> true "false" -> false "nil" -> nil Edited November 7, 2016 by CodyL Link to comment
Simple0x47 Posted November 7, 2016 Share Posted November 7, 2016 You could make a function like this. local _S = { "false", "nil", "true" } function convertThem( key, _type ) if ( _type == 1 ) then _S[ key ] = false elseif ( _type == 2 ) then _S[ key ] = nil elseif ( _type == 3 ) then _S[ key ] = true end end convertThem( 1, 1 ) Link to comment
Walid Posted November 7, 2016 Share Posted November 7, 2016 Try this function booleanToString(boolean) return boolean and "true" or "false" end function stringToBoolean(string) return string == "true" and true or false 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