less redundant logging and some refactoring

This commit is contained in:
Lilian Jónsdóttir 2020-07-26 01:05:30 -07:00
parent c0de6afc35
commit 5d31d0ad97
5 changed files with 15 additions and 9 deletions

View file

@ -23,7 +23,8 @@ local function alertGuards(aggressor, cell)
log("Alerting %s, %s units away, to the combat!", npc.object.name, distance) log("Alerting %s, %s units away, to the combat!", npc.object.name, distance)
if config.combatDialogue then if config.combatDialogue then
local response = common.guardDialogue(npc, table.choice(common.dialogues[config.language].join_combat), local response = common.guardDialogue(npc.object.name,
table.choice(common.dialogues[config.language].join_combat),
aggressor) aggressor)
log(response) log(response)
end end

View file

@ -5,7 +5,8 @@ local this = {}
this.modName = "More Attentive Guards" -- or something this.modName = "More Attentive Guards" -- or something
this.author = "Celediel" this.author = "Celediel"
this.version = "1.0.3" this.version = "1.0.3"
this.modInfo = [[Guards with some actual spacial awareness! this.modInfo = [[Guards with some actual spatial awareness!
Guards who catch you sneaking will follow you for a bit of Guards who catch you sneaking will follow you for a bit of
time, and will also come to the player's rescue if attacked unprovoked.]] time, and will also come to the player's rescue if attacked unprovoked.]]
this.dialogues = require("celediel.MoreAttentiveGuards.dialogues") this.dialogues = require("celediel.MoreAttentiveGuards.dialogues")
@ -43,9 +44,8 @@ this.guardDialogue = function(npc, str, target)
targetOrPlayer = target.object.name targetOrPlayer = target.object.name
end end
local name = npc.object.name
local message = string.format(str, targetOrPlayer) local message = string.format(str, targetOrPlayer)
local output = string.format("%s: %s", name, message) local output = string.format("%s: %s", npc, message)
tes3.messageBox(output) tes3.messageBox(output)
return output return output

View file

@ -8,7 +8,7 @@ local function onInitialized()
-- in order for this to work, everything in returned table must be functions named onEventName -- in order for this to work, everything in returned table must be functions named onEventName
for name, func in pairs(sneak) do event.register(name:gsub(eventPattern, string.lower), func) end for name, func in pairs(sneak) do event.register(name:gsub(eventPattern, string.lower), func) end
for name, func in pairs(combat) do event.register(name:gsub(eventPattern, string.lower), func) end for name, func in pairs(combat) do event.register(name:gsub(eventPattern, string.lower), func) end
common.log("%s initialized", common.modName) common.log("Successfully initialized")
end end
event.register("initialized", onInitialized) event.register("initialized", onInitialized)

View file

@ -28,7 +28,11 @@ local mainCategory = page:createCategory(common.modName)
local generalCategory = mainCategory:createCategory("Common settings") local generalCategory = mainCategory:createCategory("Common settings")
generalCategory:createDropdown({label = "Language", options = createLanguageOptions(), variable = createTableVar("language")}) generalCategory:createDropdown({
label = "Language",
options = createLanguageOptions(),
variable = createTableVar("language")
})
generalCategory:createYesNoButton({ generalCategory:createYesNoButton({
label = "Debug mode", label = "Debug mode",

View file

@ -39,7 +39,7 @@ local function startDialogue()
log("Dialogue roll = %s > %s", config.sneakDialogueChance, roll) log("Dialogue roll = %s > %s", config.sneakDialogueChance, roll)
if config.sneakDialogueChance > roll then if config.sneakDialogueChance > roll then
local response = common.guardDialogue(follower, dialogue, tes3.mobilePlayer) local response = common.guardDialogue(follower.object.name, dialogue, tes3.mobilePlayer)
log(response) log(response)
end end
end end
@ -72,7 +72,7 @@ local function stopFollowing(onTimer)
-- send a dialogue to let player know guard doesn't care any more -- send a dialogue to let player know guard doesn't care any more
if onTimer then if onTimer then
local response = common.guardDialogue(follower, local response = common.guardDialogue(follower.object.name,
table.choice(common.dialogues[config.language].stop_following), table.choice(common.dialogues[config.language].stop_following),
tes3.mobilePlayer) tes3.mobilePlayer)
log(response) log(response)
@ -119,7 +119,8 @@ local function startFollowing()
end end
local function abortFollow() local function abortFollow()
local response = common.guardDialogue(follower, table.choice(common.dialogues[config.language].stop_sneaking), local response = common.guardDialogue(follower.object.name,
table.choice(common.dialogues[config.language].stop_sneaking),
tes3.mobilePlayer) tes3.mobilePlayer)
log(response) log(response)
stopFollowing(false) stopFollowing(false)