Last active
July 12, 2018 13:54
-
-
Save rubenwardy/f5676ebe451272941b2170d4cf264350 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- First check to see if it can be evaluated as an expression, | |
-- then fallback to executing it raw | |
local func, error = loadstring("return (" .. param .. ")") | |
if not func then | |
func, error = loadstring(param) | |
if not func then | |
return false, "E " .. error | |
end | |
end | |
local good, errOrResult = pcall(func) | |
if not good then | |
return false, "E " .. errOrResult | |
end | |
return true, "= " .. dump(errOrResult) | |
-- note: this function returns a tuple - (successBoolean,messageToSendToUser) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment