I give up on tes3.setEnabled for now, 2 many crash

This commit is contained in:
Lilian Jónsdóttir 2020-08-04 19:29:53 -07:00
parent 6f023acd1d
commit 2e6c19a78b

View file

@ -512,15 +512,15 @@ local function disableNPCs(cell)
else else
log(common.logLevels.medium, "Disabling homeless %s", npc.object.name) log(common.logLevels.medium, "Disabling homeless %s", npc.object.name)
-- npc:disable() -- ! this one sometimes causes crashes -- npc:disable() -- ! this one sometimes causes crashes
-- mwscript.disable({reference = npc}) -- ! this one is deprecated mwscript.disable({reference = npc}) -- ! this one is deprecated
tes3.setEnabled({reference = npc, enabled = false}) -- tes3.setEnabled({reference = npc, enabled = false}) -- ! but this one causes crashes too
end end
else else
if not npcHome then if not npcHome then
log(common.logLevels.medium, "Enabling homeless %s", npc.object.name) log(common.logLevels.medium, "Enabling homeless %s", npc.object.name)
-- npc:enable() -- npc:enable()
-- mwscript.enable({reference = npc}) mwscript.enable({reference = npc})
tes3.setEnabled({reference = npc, enabled = true}) -- tes3.setEnabled({reference = npc, enabled = true})
end end
end end
end end
@ -538,14 +538,14 @@ local function disableSiltStriders(cell)
if activator.object.id:match("siltstrider") then if activator.object.id:match("siltstrider") then
if checkTime() or (checkWeather(cell) and not config.keepBadWeatherNPCs) then if checkTime() or (checkWeather(cell) and not config.keepBadWeatherNPCs) then
log(common.logLevels.medium, "Disabling silt strider %s!", activator.object.name) log(common.logLevels.medium, "Disabling silt strider %s!", activator.object.name)
-- mwscript.disable({reference = activator}) mwscript.disable({reference = activator})
-- activator:disable() -- activator:disable()
tes3.setEnabled({reference = activator, enabled = false}) -- tes3.setEnabled({reference = activator, enabled = false})
else else
log(common.logLevels.medium, "Enabling silt strider %s!", activator.object.name) log(common.logLevels.medium, "Enabling silt strider %s!", activator.object.name)
-- mwscript.enable({reference = activator}) mwscript.enable({reference = activator})
-- activator:enable() -- activator:enable()
tes3.setEnabled({reference = activator, enabled = true}) -- tes3.setEnabled({reference = activator, enabled = true})
end end
end end
end end
@ -652,7 +652,7 @@ end
-- {{{ event functions -- {{{ event functions
local function onActivated(e) local function onActivated(e)
if e.activator ~= tes3.player and e.target.object.objectType ~= tes3.objectType.npc then return end if e.activator ~= tes3.player or e.target.object.objectType ~= tes3.objectType.npc then return end
if tes3.player.data.NPCsGoHome.intruding and not isIgnoredNPC(e.target) then if tes3.player.data.NPCsGoHome.intruding and not isIgnoredNPC(e.target) then
tes3.messageBox(string.format("%s: Get out before I call the guards!", e.target.object.name)) tes3.messageBox(string.format("%s: Get out before I call the guards!", e.target.object.name))