-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve menu flow, add multi-choice locations for mage/fighters guild…
… quests and more
- Loading branch information
Showing
13 changed files
with
714 additions
and
176 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
Data Files/MWSE/mods/mer/chargenScenarios/ScenarioBuilder/controllers/registerClutter.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
|
||
local common = require("mer.chargenScenarios.common") | ||
local Controls = require("mer.chargenScenarios.util.Controls") | ||
|
||
|
||
local logger = require("mer.chargenScenarios.ScenarioBuilder.luaLogger").new{ | ||
outputFile = "ChargenScenarioClutter.txt", | ||
} | ||
|
||
local luaClutterTemplate = [[ | ||
{ --${name} | ||
ids = {"${ids}"}, | ||
position = {${posx}, ${posy}, ${posz}}, | ||
orientation = {${orz}}, | ||
cell = "${cell}", | ||
scale = ${scale}, | ||
}, | ||
]] | ||
|
||
local function addClutter(clutterToAdd) | ||
local clutterString = luaClutterTemplate: | ||
gsub("${name}", clutterToAdd.name): | ||
gsub("${id}", clutterToAdd.id): | ||
gsub("${posx}", clutterToAdd.position[1]): | ||
gsub("${posy}", clutterToAdd.position[2]): | ||
gsub("${posz}", clutterToAdd.position[3]): | ||
gsub("${orz}", table.concat(clutterToAdd.orientation, ", ")): | ||
gsub("${cell}", clutterToAdd.cell.id): | ||
gsub("${scale}", clutterToAdd.scale) | ||
logger:info("\n" .. clutterString) | ||
end | ||
|
||
---@param target tes3reference | ||
local function registerClutter(target) | ||
local clutter = { | ||
name = target.object.name, | ||
id = target.object.id, | ||
position = { | ||
math.floor(target.position.x), | ||
math.floor(target.position.y), | ||
math.floor(target.position.z), | ||
}, | ||
orientation = { | ||
math.floor(target.orientation.x), | ||
math.floor(target.orientation.y), | ||
math.floor(target.orientation.z), | ||
}, | ||
cell = target.cell, | ||
scale = string.format("%.2d", target.scale) | ||
} | ||
addClutter(clutter) | ||
end | ||
|
||
---@param e keyDownEventData | ||
local function onKeyDown(e) | ||
if common.config.mcm.registerClutterEnabled then | ||
if Controls.isKeyPressed(e, common.config.mcm.registerClutterHotKey) then | ||
local result = tes3.rayTest{ | ||
position = tes3.getPlayerEyePosition(), | ||
direction = tes3.getPlayerEyeVector(), | ||
ignore = { tes3.player }, | ||
maxDistance = tes3.getPlayerActivationDistance() | ||
} | ||
if not (result and result.reference) then | ||
tes3.messageBox("No reference found.") | ||
return | ||
end | ||
local target = result.reference | ||
|
||
tes3ui.showMessageMenu{ | ||
message = string.format("Register %s as clutter?", target.object.name), | ||
buttons = { | ||
{ | ||
text = "Yes", | ||
callback = function() | ||
registerClutter(target) | ||
end | ||
}, | ||
{ | ||
text = "Cancel" | ||
} | ||
} | ||
} | ||
end | ||
end | ||
end | ||
event.register("keyDown", onKeyDown) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Data Files/MWSE/mods/mer/chargenScenarios/ScenarioBuilder/luaLogger.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--[[ | ||
Logs lua code templates to a custom file | ||
]] | ||
|
||
local luaLogger = {} | ||
|
||
|
||
---@param params { outputFile: string } | ||
function luaLogger.new(params) | ||
local self = { | ||
outputFile = io.open(params.outputFile, "w"), | ||
} | ||
|
||
function self:info(output) | ||
if self.outputFile then | ||
self.outputFile:write(output .. "\n") | ||
self.outputFile:flush() | ||
else | ||
print(output) | ||
end | ||
end | ||
|
||
return self | ||
end | ||
|
||
return luaLogger |
1 change: 1 addition & 0 deletions
1
Data Files/MWSE/mods/mer/chargenScenarios/ScenarioBuilder/main.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--Controllers for the scenario builder | ||
require('mer.chargenScenarios.ScenarioBuilder.controllers.registerLocations') | ||
require('mer.chargenScenarios.ScenarioBuilder.controllers.registerClutter') | ||
--MCM | ||
local mcm = require('mer.chargenScenarios.ScenarioBuilder.mcm') | ||
event.register("modConfigReady", mcm.registerModConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.