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 = {}
this.inspect = require("inspect")
-- {{{ Variables and such
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
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

View file

@ -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

View file

@ -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