Skip to content

Instantly share code, notes, and snippets.

@XDuskAshes
Last active November 10, 2024 18:10
Show Gist options
  • Select an option

  • Save XDuskAshes/d6ebfe628562089b66e5588cb940fb0e to your computer and use it in GitHub Desktop.

Select an option

Save XDuskAshes/d6ebfe628562089b66e5588cb940fb0e to your computer and use it in GitHub Desktop.
Dusk's ComputerCraft Snippets
-- Call a function in an xpcall() wrapper.
local function safeCall(f,args)
if not type(f) == "function" then
return false, "[libcommon]: cannot safeCall "..f..": not a function"
end
local function errorHandle(errormsg)
return false, "[libcommon]: exec error: "..errormsg
end
local status, result = xpcall(function() return f(table.unpack(args or {})) end, errorHandle)
return status, result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment