From d6a8c0228741778f067c812026a7d850556c23b9 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 30 Mar 2018 20:55:07 +0100 Subject: [PATCH] Few Big Changes In Core File --- ExpCore/commands.lua | 5 ++++- control.lua | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ExpCore/commands.lua b/ExpCore/commands.lua index e6ca29f0..137ebc83 100644 --- a/ExpCore/commands.lua +++ b/ExpCore/commands.lua @@ -143,5 +143,8 @@ commands.add_command = function(name, description, inputs, event) inputs=inputs } command_calls[name] = event - commands._add_command(name,command_inputs(command_data[name])..'- '..description,run_custom_command) + commands._add_command(name,command_inputs(command_data[name])..'- '..description,function(...) + local success, err = pcall(run_custom_command,...) + if not success then error(err) end + end) end \ No newline at end of file diff --git a/control.lua b/control.lua index 9bc76fd6..5e4ebbba 100644 --- a/control.lua +++ b/control.lua @@ -14,6 +14,9 @@ error = function(err) if _G.discord_emit and game then local color = _G.Color and Color.to_hex(defines.text_color.bg) or '0x0' discord_emit{title='SCRIPT ERROR',color=color,description='There was an error in the script @Developers ',Error=err} + elseif _G.error_handle and type(error_handle) == 'function' then + local success, _err = error_handle(err) + if not success then _error({handle=_err,err=err}) end elseif _G.Game and game then if Game.print_all(err) == 0 then _error(err) @@ -23,11 +26,12 @@ error = function(err) end end -- replaces the base require function -require_return_err = false +require_return_err = false -- set to false when removing files; set to true for debuging _require = require -local function require(path) - local success, err = pcall(_require,path) - if not success and require_return_err then error(err) end +require = function(path) + local _return = {pcall(_require,path)} + if not table.remove(_return, 1) and require_return_err then error(unpack(_return)) end + return unpack(_return) end require("mod-gui")