Jump to content
Sign in to follow this  
Cornysz

How to convert error message to string?

Recommended Posts

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.

Share this post


Link to post
Share on other sites

Read data, check contents. If it is not fit you - show alert. You can try use tonumber or regular expression, whatever.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×