Forrest Posted January 17, 2014 Share Posted January 17, 2014 I'm working on my own handling editor at the moment as a small project, and I'm currently setting up the limits. I'm probably just being stupid here, but whenever the GUI edit is empty, I get debug errors of trying to compare a number with nil, on line 4, which makes sense. However how do I check whether the edit is empty and not to run the check? function checkValues() for k, v in pairs(handlingValues) do if name == tostring(v[1]) then if tonumber(guiGetText(source)) > v[2] and tonumber(guiGetText(source)) < v[3] then guiSetEnabled(finishEdit, true) else guiSetEnabled(finishEdit, false) end end end end Thanks. Link to comment
Sasu Posted January 17, 2014 Share Posted January 17, 2014 Use: string.len(guiGetText(source)) or #(guiGetText(source)) To get first the lenght and check if is empty if string.len(guiGetText(source)) > 0 then Link to comment
Anubhav Posted January 17, 2014 Share Posted January 17, 2014 function checkValues() for k, v in pairs(handlingValues) do if name == tostring(v[1]) then if tonumber(guiGetText(source)) > 0 or tonumber(guiGetText(source)) < 3 then guiSetEnabled(finishEdit, true) else guiSetEnabled(finishEdit, false) end end end end Dint tested it. Link to comment
Forrest Posted January 17, 2014 Author Share Posted January 17, 2014 Use: string.len(guiGetText(source)) or #(guiGetText(source)) To get first the lenght and check if is empty if string.len(guiGetText(source)) > 0 then Perfect, thanks. 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