'LinKin Posted April 15, 2014 Posted April 15, 2014 Hello, I want to check it a string is a color code or not. I tried with string.match but it's not precise.. It's like using string.find. So if I have; local theString = "#FF0000Test" string.find(theString, "#%x%x%x%x%x%x") will return true, but it's not since the string contains the 'extension' (Test) I tried if theString == "#%x%x%x%x%x%x" then ... But it didn't work either.. function isHexCode(theString) --Which condition to put here? end Thanks. Need a clanwar script? Click here! Do you want some free scripts for your DD server? Visit my website.
'LinKin Posted April 16, 2014 Author Posted April 16, 2014 Well ok I made this: It seems to work function isStringHexCode(theHex) local Hex = theHex:gsub("#", "") if #Hex == 6 and tonumber(Hex, 16) then return true end return false end I got another question, How can I check if the first character of the string is "#" or not? Need a clanwar script? Click here! Do you want some free scripts for your DD server? Visit my website.
Bonsai Posted April 16, 2014 Posted April 16, 2014 string.find returns the position if there is a match, just check if its 1,1.
-.Paradox.- Posted April 16, 2014 Posted April 16, 2014 string.gsub If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
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