inspect in common; replace json.encode

This commit is contained in:
Lilian Jónsdóttir 2020-10-11 20:28:35 -07:00
parent 1d6684b57d
commit c5099e7ea4
4 changed files with 6 additions and 6 deletions

View file

@ -1,4 +1,5 @@
local this = {} local this = {}
this.inspect = require("inspect")
-- {{{ Variables and such -- {{{ Variables and such
this.modName = "NPCs Go Home (At Night)" this.modName = "NPCs Go Home (At Night)"

View file

@ -73,7 +73,7 @@ this.pickCellFaction = function(cell)
-- from the majority values, return the faction with the largest percentage, or nil -- from the majority values, return the faction with the largest percentage, or nil
local picked = common.keyOfLargestValue(npcs.majorityFactions) local picked = common.keyOfLargestValue(npcs.majorityFactions)
log(common.logLevels.medium, "[CELLEVAL] Picked faction %s for cell %s", picked, cell.id) 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 return picked
end end

View file

@ -64,7 +64,7 @@ local function disableNPC(npc, cell)
end end
local function putNPCsBack(npcData) 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 i = #npcData, 1, -1 do
for id, data in pairs(npcData) do for id, data in pairs(npcData) do
if data.npc.object then if data.npc.object then
@ -92,7 +92,7 @@ local function putNPCsBack(npcData)
end end
local function reEnableNPCs(npcs) 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 for id, ref in pairs(npcs) do
log(common.logLevels.medium, "[PROC] Making attempt at re-enabling %s", id) log(common.logLevels.medium, "[PROC] Making attempt at re-enabling %s", id)
if ref.object and ref.disabled then if ref.object and ref.disabled then
@ -131,7 +131,7 @@ local function checkForMovedOrDisabledNPCs(cell)
for npc in cell:iterateReferences(tes3.objectType.npc) do for npc in cell:iterateReferences(tes3.objectType.npc) do
if npc.data and npc.data.NPCsGoHome then if npc.data and npc.data.NPCsGoHome then
log(common.logLevels.large, "[PROC] %s has NPCsGoHome data, deciding if disabled or moved...%s", npc, 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) local badWeather = checks.isBadWeatherNPC(npc)
if npc.data.NPCsGoHome.disabled then if npc.data.NPCsGoHome.disabled then
-- disabled NPC -- disabled NPC

View file

@ -5,7 +5,6 @@ local common = require("celediel.NPCsGoHome.common")
local checks = require("celediel.NPCsGoHome.functions.checks") local checks = require("celediel.NPCsGoHome.functions.checks")
local processors = require("celediel.NPCsGoHome.functions.processors") local processors = require("celediel.NPCsGoHome.functions.processors")
local interop = require("celediel.NPCsGoHome.interop") local interop = require("celediel.NPCsGoHome.interop")
local inspect = require("inspect")
-- }}} -- }}}
-- {{{ variables and such -- {{{ variables and such
@ -207,7 +206,7 @@ eventFunctions.onKeyDown = function(e)
-- ? doesn't crash my barely modded testing setup though -- ? doesn't crash my barely modded testing setup though
-- log(common.logLevels.none, json.encode(common.runtimeData, { indent = true })) -- log(common.logLevels.none, json.encode(common.runtimeData, { indent = true }))
-- inspect handles userdata and tables within tables badly -- inspect handles userdata and tables within tables badly
log(common.logLevels.none, inspect(common.runtimeData)) log(common.logLevels.none, common.inspect(common.runtimeData))
end end
-- if ctrl log position data formatted for positions.lua -- if ctrl log position data formatted for positions.lua
if e.isControlDown then if e.isControlDown then