Hi there, I have a custom code editor I’ve made, and along with that is a output that is meant to receive things like warnings, errors, prints, etc. The issue is, is that I’m unsure how messageout
works as there is little information on it’s documentation and also unsure where it logs messages from. I don’t have a attempt as I am confused on how the function works.
scroll down a bit
also I’m not so sure if you would want to use LogService in the first place
you’re essentially relying on the external game engine itself to catch errors, which can become flooded with other scripts, not just from the sandboxed script itself
You can use pcall
to catch errors and metatable sandboxing to catch print
, warn
, or any other kinds of functions ran within.
local fakeEnv = {
print = function(...)
scriptEditor.ConsolePrint(...) --function gets redirected
--do something else with the information
end,
--insert other proxy functions
}
setfenv(sandbox, fakeEnv)
local _, errorMsg: string = pcall(sandbox)
Also, check out this sandbox:
Sorry for (late) reply but I did however try using pcall but in just a simpler way, however it was only outputting errors within the script itself and not the sandboxed one. Does the sample you provided serves for only the sandboxed script?