767 posts
Posted 31 December 2012 - 10:58 AM
Hello.
does anyone know how to make a detector, that detects if my program is beginning to crash. (
Like in the firewolf crash system)
thanks in advance :)/>
1688 posts
Location
'MURICA
Posted 31 December 2012 - 11:04 AM
This sounds like a job for pcall.
local function stupidFunction()
callingANilValue()
end
local ok, err = pcall(stupidFunction)
if not ok then
print(err)
end
pcall stands for "protected call", and it allows you to call functions and catch errors if any. In this example, "ok" is whether or not the function call was successful, and if ok is false, "err" is the error message.
767 posts
Posted 31 December 2012 - 11:11 AM
Thanks for that. I didnt know that it could be printed, before the error is there. But the pcall worked fine… thank you !
:D/> :D/>