Cornysz Posted November 8, 2018 Posted November 8, 2018 Is it possible to convert error message to string? Example my script have prompt and i input random number and then i got error, and i want after that the script will automatically alert the error.
Administrators Enyby Posted November 8, 2018 Administrators Posted November 8, 2018 Read data, check contents. If it is not fit you - show alert. You can try use tonumber or regular expression, whatever.
Cornysz Posted November 8, 2018 Author Posted November 8, 2018 Read data, check contents. If it is not fit you - show alert. You can try use tonumber or regular expression, whatever.What do u mean of Read data, check contents i dont have idea to make dat oof
Administrators Enyby Posted November 8, 2018 Administrators Posted November 8, 2018 You receive some input from the user. This will be your data. Before you use them, check that there is what you need, and not just random nonsense.
CmP Posted November 8, 2018 Posted November 8, 2018 4 hours ago, Cornysz said: What do u mean of Read data, check contents i dont have idea to make dat oof local min = 4 local max = 10 local data = gg.prompt({'Input a number between ' .. min .. ' and ' .. max}, {min}, {'number'}) -- read data -- Check contents if data == nil then gg.alert('Dialog was cancelled') os.exit() end local number = tonumber(data[1]) if number == nil then gg.alert('Input was not a valid number') os.exit() end if number < min or number > max then -- if does not fit gg.alert('Input number is not within allowable range') -- show alert os.exit() -- and interrupt script execution (or do whatever is required) end
Recommended Posts
Archived
This topic is now archived and is closed to further replies.