Jump to content

How to convert error message to string?


Cornysz

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.

Link to comment
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
Link to comment
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

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.