From 4220de5f107cffeed5979ce3be5404c3b98b0711 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Sat, 3 Sep 2022 21:20:46 +0000 Subject: [PATCH] coditionally require dbg --- .luarc.json | 6 ++++-- dbg.lua | 1 - main.lua | 7 ++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.luarc.json b/.luarc.json index 1ae2aa2..90d8dc7 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,9 +1,11 @@ { "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.runtime.version": "LuaJIT", "Lua.diagnostics.disable": [ - "undefined-field" + "undefined-field", + "need-check-nil" ], "Lua.workspace.library": { "../cc-lsp-config": true } -} \ No newline at end of file +} diff --git a/dbg.lua b/dbg.lua index 87dc0f4..fa63b91 100644 --- a/dbg.lua +++ b/dbg.lua @@ -1,4 +1,3 @@ - local dbg_file function dbg(...) if dbg_file then diff --git a/main.lua b/main.lua index 9daa102..d4d81be 100644 --- a/main.lua +++ b/main.lua @@ -1,6 +1,11 @@ local ui = require("ui") -require("dbg")("logs.txt") +do + local success, dbg_module = pcall(require, "dbg") + if success then + dbg_module("logs.txt") + end +end local function is_inventory(peripheral_name) local types = {peripheral.getType(peripheral_name)}