From c5099e7ea482ca9c8c918e2e89674b2009129cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 11 Oct 2020 20:28:35 -0700 Subject: [PATCH] inspect in common; replace json.encode --- MWSE/mods/celediel/NPCsGoHome/common.lua | 1 + MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua | 2 +- MWSE/mods/celediel/NPCsGoHome/functions/processors.lua | 6 +++--- MWSE/mods/celediel/NPCsGoHome/main.lua | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MWSE/mods/celediel/NPCsGoHome/common.lua b/MWSE/mods/celediel/NPCsGoHome/common.lua index 3cdd21c..f15ed5e 100644 --- a/MWSE/mods/celediel/NPCsGoHome/common.lua +++ b/MWSE/mods/celediel/NPCsGoHome/common.lua @@ -1,4 +1,5 @@ local this = {} +this.inspect = require("inspect") -- {{{ Variables and such this.modName = "NPCs Go Home (At Night)" diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua b/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua index a00660b..47e6c92 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/cellEvaluators.lua @@ -73,7 +73,7 @@ this.pickCellFaction = function(cell) -- from the majority values, return the faction with the largest percentage, or nil local picked = common.keyOfLargestValue(npcs.majorityFactions) log(common.logLevels.medium, "[CELLEVAL] Picked faction %s for cell %s", picked, cell.id) - log(common.logLevels.large, "[CELLEVAL] breakdown:\n%s", json.encode(npcs, {indent = true})) + log(common.logLevels.large, "[CELLEVAL] breakdown:\n%s", common.inspect(npcs, {indent = true})) return picked end diff --git a/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua b/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua index d10bd45..f69dcfe 100644 --- a/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua +++ b/MWSE/mods/celediel/NPCsGoHome/functions/processors.lua @@ -64,7 +64,7 @@ local function disableNPC(npc, cell) end local function putNPCsBack(npcData) - log(common.logLevels.large, "[PROC] Moving back NPCs:\n%s", json.encode(npcData)) + log(common.logLevels.large, "[PROC] Moving back NPCs:\n%s", common.inspect(npcData)) -- for i = #npcData, 1, -1 do for id, data in pairs(npcData) do if data.npc.object then @@ -92,7 +92,7 @@ local function putNPCsBack(npcData) end local function reEnableNPCs(npcs) - log(common.logLevels.large, "[PROC] Re-enabling NPCs:\n%s", json.encode(npcs)) + log(common.logLevels.large, "[PROC] Re-enabling NPCs:\n%s", common.inspect(npcs)) for id, ref in pairs(npcs) do log(common.logLevels.medium, "[PROC] Making attempt at re-enabling %s", id) if ref.object and ref.disabled then @@ -131,7 +131,7 @@ local function checkForMovedOrDisabledNPCs(cell) for npc in cell:iterateReferences(tes3.objectType.npc) do if npc.data and npc.data.NPCsGoHome then log(common.logLevels.large, "[PROC] %s has NPCsGoHome data, deciding if disabled or moved...%s", npc, - json.encode(npc.data.NPCsGoHome)) + common.inspect(npc.data.NPCsGoHome)) local badWeather = checks.isBadWeatherNPC(npc) if npc.data.NPCsGoHome.disabled then -- disabled NPC diff --git a/MWSE/mods/celediel/NPCsGoHome/main.lua b/MWSE/mods/celediel/NPCsGoHome/main.lua index 43ca17a..7b1daba 100644 --- a/MWSE/mods/celediel/NPCsGoHome/main.lua +++ b/MWSE/mods/celediel/NPCsGoHome/main.lua @@ -5,7 +5,6 @@ local common = require("celediel.NPCsGoHome.common") local checks = require("celediel.NPCsGoHome.functions.checks") local processors = require("celediel.NPCsGoHome.functions.processors") local interop = require("celediel.NPCsGoHome.interop") -local inspect = require("inspect") -- }}} -- {{{ variables and such @@ -207,7 +206,7 @@ eventFunctions.onKeyDown = function(e) -- ? doesn't crash my barely modded testing setup though -- log(common.logLevels.none, json.encode(common.runtimeData, { indent = true })) -- inspect handles userdata and tables within tables badly - log(common.logLevels.none, inspect(common.runtimeData)) + log(common.logLevels.none, common.inspect(common.runtimeData)) end -- if ctrl log position data formatted for positions.lua if e.isControlDown then