From 6dfb1e4a86af8fc6eb8934a3136774585b86569e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 16 Aug 2020 16:19:12 -0700 Subject: [PATCH] slight refactoring --- MWSE/mods/celediel/NPCsGoHome/main.lua | 43 +++++++++++++------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/MWSE/mods/celediel/NPCsGoHome/main.lua b/MWSE/mods/celediel/NPCsGoHome/main.lua index 7a51f48..753c8db 100644 --- a/MWSE/mods/celediel/NPCsGoHome/main.lua +++ b/MWSE/mods/celediel/NPCsGoHome/main.lua @@ -359,6 +359,22 @@ local function isCityCell(internalCellId, externalCellId) return false end +local function isIgnoredCell(cell) + log(common.logLevels.large, "%s is %s, %s is %s", cell.id, config.ignored[cell.id] and "ignored" or "not ignored", + cell.sourceMod, config.ignored[cell.sourceMod] and "ignored" or "not ignored") + + -- don't do things in the wilderness + -- local wilderness = false + -- if not cell.name then wilderness = true end + + return config.ignored[cell.id] or config.ignored[cell.sourceMod] -- or wilderness +end + +local function isCantonCell(cellName) + for _, str in pairs(waistworks) do if cellName:match(str) then return true end end + return false +end + local function fargothCheck() local fargothJournal = tes3.getJournalIndex({id = "MS_Lookout"}) if not fargothJournal then return false end @@ -496,7 +512,7 @@ local function isPublicHouse(cell) return false end --- todo: check cell contents to decide if it should be locked +-- doors that lead to ignored, exterior, canton, unoccupied, or public cells, and doors that aren't in cities local function isIgnoredDoor(door, homeCellId) -- don't lock non-cell change doors if not door.destination then @@ -519,35 +535,18 @@ local function isIgnoredDoor(door, homeCellId) end end - log(common.logLevels.large, "%s is %s, %s is %s (%sin a city, is %spublic, %soccupied)", -- - door.destination.cell.id, config.ignored[door.destination.cell.id] and "ignored" or "not ignored", -- destination is ignored - door.destination.cell.sourceMod, config.ignored[door.destination.cell.sourceMod] and "ignored" or "not ignored", -- destination mod is ignored + log(common.logLevels.large, "%s is %s, (%sin a city, is %spublic, %soccupied)", -- + door.destination.cell.id, isIgnoredCell(door.destination.cell) and "ignored" or "not ignored", -- destination is ignored inCity and "" or "not ", leadsToPublicCell and "" or "not ", hasOccupants and "" or "un") -- in a city, is public, is ocupado - return config.ignored[door.destination.cell.id] or - config.ignored[door.destination.cell.sourceMod] or + return isIgnoredCell(door.destination.cell) or not isInteriorCell(door.destination.cell) or + isCantonCell(door.destination.cell.id) or not inCity or leadsToPublicCell or not hasOccupants end -local function isIgnoredCell(cell) - log(common.logLevels.large, "%s is %s, %s is %s", cell.id, config.ignored[cell.id] and "ignored" or "not ignored", - cell.sourceMod, config.ignored[cell.sourceMod] and "ignored" or "not ignored") - - -- don't do things in the wilderness - -- local wilderness = false - -- if not cell.name then wilderness = true end - - return config.ignored[cell.id] or config.ignored[cell.sourceMod] -- or wilderness -end - -local function isCantonCell(cellName) - for _, str in pairs(waistworks) do if cellName:match(str) then return true end end - return false -end - -- AT NIGHT local function checkTime() log(common.logLevels.large, "Current time is %s, things are closed between %s and %s",