As of 1.2 this mod has a new file structure and no longer uses a plugin. Make sure to delete any traces of the previous version before updating. Also make sure you have the very latest MWSE 2.1 Dev Build.
I discovered an issue with MWSE Containers Extended (and probably the original mod by Greatness7 as well): Because the containers are technically lights that have the "Can Carry" flag enabled, this mod tries to equip them if they come before other light sources in the inventory, and the character even holds them in their hand when this happens. To get around this, I added a check to this mod to make sure the "Time" of the light source is not 0, which is the case for the containers.
This is the code: local function getFirstLight(ref) for stack in tes3.iterate(ref.object.inventory.iterator) do if stack.object.canCarry and stack.object.time ~= 0 then return stack.object end end end With the other fixes that can be found here in the comments and as I already based my own MWSE Potion Effects Hotkeys mod on this one, I might release an updated version of this myself at some point, as it doesn't look like there will be an update any time soon.
I'm updating MWSE almost daily :). MWSE.log throws a lot of UI expansion errors. Maybe that's the culprit... Well, I ran it without UI expansion, still doesn't work, no errors in MWSE.log. The torch gets equipped (in the inventory), but not in game.
The only thing I edited is the equip key (from C to F). Works flawless with one-handed weapons.
After some testing, I think your mod works correctly, but it could be made more convenient with a 'readied weapon' check. Don't know if this is even possible with MWSE, but would be nice to switch between 2H and torch with just one button instead of two.
1- Equip a 2H weapon 2- Got to combat stance, i.e. pull your weapon out 3- Press the Torch Key: PC Equips Torch, but remains in combat stance, with fists out (since no longer holding weapon). 4- Press the combat stance key: Fists are removed and the Torch is now held by the PC.
Quick Equip keys in Morrowind have the exact same behaviour, you can assign a Torch to 1 and a Bow to 2 and you'll have the same problem going from 2 to 1 (pretty lame). I looked for a mswcript command to toggle combat stance but did not find. Maybe there is something in LUA?
Ok, you can ReadyWeapon via LUA, so I've fixed the mod, now it works for 1H and 2H weapons/Bows. Until this is updated, here is the modified script, in bold are the changes: Note that this version uses T for the Torch key (makes sense no?):
--[[ Torch Hotkey --]]
local function unequipLight() tes3.mobilePlayer:unequip{ type = tes3.objectType.light } end
local function getFirstLight(ref) for stack in tes3.iterate(ref.object.inventory.iterator) do if stack.object.canCarry then return stack.object end end end
local lastShield local lastWeapon local lastRanged local WeaponReady
local function swapForLight(e)
-- Don't do anything in menu mode. if tes3.menuMode() then return end
-- Look to see if we have a light equipped. If we have one, unequip it. local lightStack = tes3.getEquippedItem{ actor = tes3.player, objectType = tes3.objectType.light }
if (lightStack) then
unequipLight()
-- If we had a shield equipped before, re-equip it. if (lastShield) then mwscript.equip{ reference = tes3.player, item = lastShield } end
-- If we had a 2H weapon equipped before, re-equip it. if (lastWeapon) then mwscript.equip{ reference = tes3.player, item = lastWeapon } end
-- If we had a ranged weapon equipped before, re-equip it. if (lastRanged) then mwscript.equip{ reference = tes3.player, item = lastRanged } end
-- If our weapon was out before then take it out again if ( WeaponReady ) then tes3.mobilePlayer.weaponReady = true end
return end
-- If we don't have a light equipped, try to equip one.
local light = getFirstLight(tes3.player) if light then
-- Store the currently equipped shield, if any. local shieldStack = tes3.getEquippedItem({ actor = tes3.player, objectType = tes3.objectType.armor, slot = tes3.armorSlot.shield }) if (shieldStack) then lastShield = shieldStack.object end
-- Store the currently equipped 2H weapon, if any. local weaponStack = tes3.getEquippedItem({ actor = tes3.player, objectType = tes3.objectType.weapon}) if (weaponStack and weaponStack.object.isTwoHanded) then lastWeapon = weaponStack.object end
-- Store the currently equipped ranged weapon, if any. local rangedStack = tes3.getEquippedItem({ actor = tes3.player, objectType = tes3.objectType.weapon}) if (rangedStack and rangedStack.object.isRanged) then lastRanged = rangedStack.object end
mwscript.equip{ reference = tes3.player, item = light} -- Equip the light we found.
-- If we were using a 2H weapon we need to un-ready from combat stance if ( lastWeapon or lastRanged ) then tes3.mobilePlayer.weaponReady = false end
return end
tes3.messageBox("You have no lights") end
local function initialized(e) event.register("keyDown", swapForLight, { filter = tes3.scanCode.t }) print("Initialized TorchHotkey v0.20") end
Dungeoneering with a torch in MW is the core experience, especially with True Lights and Darkness(!), this would be a huge quality-of-life improvement.
This is almost correct. I play 1H with shield and what happens with your code is that if I unready my weapon when my torch is out, and then I unequip the torch, my character readies my weapon again automatically.
So I changed to the following for taking the weapon out if it was out before: -- If our weapon was out before then take it out again if (WeaponReady) then mwscript.equip{ reference = tes3.player, item = WeaponReady } end
This may however interfere with the 2H code, but I haven't tested this.
Endorsed! Great mod, this is much more convenient when equipping and un-equipping torches. This mod could use an update though to do two things: 1) incorporate BBOOze64's fix for 2H weapons; and 2) an MCM menu to configure the key bind.
"Excuse the Jiub but no one can know of this meeting, the nature of my trouble is darker still, over a year ago Fargoth of Morrowind lost his ring, it was his family heirloom, he does grieve for it... But the ring is not truly lost only hidden, i do not know why someone would hide such a beautiful heirloom... Perhaps you can find the answer and find the Engraved Ring of Healing bringing peace to his Soul. I ask this as you emperor, and your friend. I have one lesser request; several years ago i sent a package to Caius Cosades, it never arrived. The package was of sentimental and... personal nature. If you find and destroy that package, i will be grateful. Now my Nerevarine, rest well this night, for tomorrow you sail for Vvanderfell"
-(Probably) The Emperor in the image of this mod.
Sorry i couldn't resist the temptetion to write it all, anyway thanks for the mod :)
Yes, you'd want to open the mod's main.lua in Notepad and find the following line: event.register("keyDown", swapForLight, { filter = 46 }) Change the number 46 to the scan code of your desired key, which you can find here.
This is a nice convenient mod. Updating this with an MCM menu with an option to change key binds would make it even more convenient. If not an MCM menu, then at least an INI file to change the key bind setting. I like to Hot Key spell casting to the "C" key, which conflicts with my muscle memory, as I find myself pulling out my torch rather then casting my spells now, and I really don't want to be forced to re-train my muscles to use another key bind.
I second this... the LUA file at the the very end has this: event.register("keyDown", swapForLight, { filter = 46 }) where I suspect the 'C' key correlates with 46. I however have no clue what numbers the key I'd like to use correspons with...:(
Much appreciated, but when a lantern runs out of oil and I press the hotkey again it should equip the next lantern, but instead it tries to equip the burnt one and I get notification again "lantern ran out". So every time I have to throw out burnt out torch/lantern for the hotkey to work. I'm using the popular Merlord's mod The Midnight Oil (allows recharging light source items instead removing them), perhaps it can be patched?
Idk if this is just me, but I've noticed that torches which are flagged as "off by default" in the CS are not considered a light source by this mod. Like the basic torch (literally just called "torch") will not work with the hotkey
I posted this on the other mod's page, but I'll post it here too since this mod is newer: there is a conflict between this mod and MWSE Containers. If one of that mod's containers is in your inventory, using the torch hotkey will cause the menu for the container to appear, rather than equip a torch. I assume it's because these containers are apparently marked as light sources, which is also why I think this conflict is more on that mod's side.
Besides that, fantastic mod! I've never used torches very often because of the hassle of having to equip them, especially between fights. With this mod, I'm nearly always using torches when dungeon-delving.
EDIT: Abot posted a fix for the above issue on MWSE Containers' mod page. Works perfectly! https://www.nexusmods.com/morrowind/mods/44387/?tab=posts
57 comments
As of 1.2 this mod has a new file structure and no longer uses a plugin. Make sure to delete any traces of the previous version before updating. Also make sure you have the very latest MWSE 2.1 Dev Build.
This is the code:
local function getFirstLight(ref)
for stack in tes3.iterate(ref.object.inventory.iterator) do
if stack.object.canCarry and stack.object.time ~= 0 then
return stack.object
end
end
end
With the other fixes that can be found here in the comments and as I already based my own MWSE Potion Effects Hotkeys mod on this one, I might release an updated version of this myself at some point, as it doesn't look like there will be an update any time soon.
Well, I ran it without UI expansion, still doesn't work, no errors in MWSE.log.
The torch gets equipped (in the inventory), but not in game.
The only thing I edited is the equip key (from C to F). Works flawless with one-handed weapons.
1- Equip a 2H weapon
2- Got to combat stance, i.e. pull your weapon out
3- Press the Torch Key: PC Equips Torch, but remains in combat stance, with fists out (since no longer holding weapon).
4- Press the combat stance key: Fists are removed and the Torch is now held by the PC.
Quick Equip keys in Morrowind have the exact same behaviour, you can assign a Torch to 1 and a Bow to 2 and you'll have the same problem going from 2 to 1 (pretty lame). I looked for a mswcript command to toggle combat stance but did not find. Maybe there is something in LUA?
Regards,
Until this is updated, here is the modified script, in bold are the changes:
Note that this version uses T for the Torch key (makes sense no?):
--[[
Torch Hotkey
--]]
local function unequipLight()
tes3.mobilePlayer:unequip{ type = tes3.objectType.light }
end
local function getFirstLight(ref)
for stack in tes3.iterate(ref.object.inventory.iterator) do
if stack.object.canCarry then
return stack.object
end
end
end
local lastShield
local lastWeapon
local lastRanged
local WeaponReady
local function swapForLight(e)
-- Don't do anything in menu mode.
if tes3.menuMode() then
return
end
-- Look to see if we have a light equipped. If we have one, unequip it.
local lightStack = tes3.getEquippedItem{ actor = tes3.player, objectType = tes3.objectType.light }
if (lightStack) then
unequipLight()
-- If we had a shield equipped before, re-equip it.
if (lastShield) then
mwscript.equip{ reference = tes3.player, item = lastShield }
end
-- If we had a 2H weapon equipped before, re-equip it.
if (lastWeapon) then
mwscript.equip{ reference = tes3.player, item = lastWeapon }
end
-- If we had a ranged weapon equipped before, re-equip it.
if (lastRanged) then
mwscript.equip{ reference = tes3.player, item = lastRanged }
end
-- If our weapon was out before then take it out again
if ( WeaponReady ) then
tes3.mobilePlayer.weaponReady = true
end
return
end
-- If we don't have a light equipped, try to equip one.
local light = getFirstLight(tes3.player)
if light then
lastShield = nil
lastWeapon = nil
lastRanged = nil
WeaponReady = tes3.mobilePlayer.weaponReady
-- Store the currently equipped shield, if any.
local shieldStack = tes3.getEquippedItem({ actor = tes3.player, objectType = tes3.objectType.armor, slot = tes3.armorSlot.shield })
if (shieldStack) then
lastShield = shieldStack.object
end
-- Store the currently equipped 2H weapon, if any.
local weaponStack = tes3.getEquippedItem({ actor = tes3.player, objectType = tes3.objectType.weapon})
if (weaponStack and weaponStack.object.isTwoHanded) then
lastWeapon = weaponStack.object
end
-- Store the currently equipped ranged weapon, if any.
local rangedStack = tes3.getEquippedItem({ actor = tes3.player, objectType = tes3.objectType.weapon})
if (rangedStack and rangedStack.object.isRanged) then
lastRanged = rangedStack.object
end
mwscript.equip{ reference = tes3.player, item = light} -- Equip the light we found.
-- If we were using a 2H weapon we need to un-ready from combat stance
if ( lastWeapon or lastRanged ) then
tes3.mobilePlayer.weaponReady = false
end
return
end
tes3.messageBox("You have no lights")
end
local function initialized(e)
event.register("keyDown", swapForLight, { filter = tes3.scanCode.t })
print("Initialized TorchHotkey v0.20")
end
event.register("initialized", initialized)
I love you, I mean seriously!
:D
Dungeoneering with a torch in MW is the core experience, especially with True Lights and Darkness(!), this would be a huge quality-of-life improvement.
So I changed to the following for taking the weapon out if it was out before:
-- If our weapon was out before then take it out again
if (WeaponReady) then
mwscript.equip{ reference = tes3.player, item = WeaponReady }
end
This may however interfere with the 2H code, but I haven't tested this.
1) incorporate BBOOze64's fix for 2H weapons; and
2) an MCM menu to configure the key bind.
Sorry i couldn't resist the temptetion to write it all, anyway thanks for the mod :)
event.register("keyDown", swapForLight, { filter = 46 })
Change the number 46 to the scan code of your desired key, which you can find here.event.register("keyDown", swapForLight, { filter = 46 }) where I suspect the 'C' key correlates with 46. I however have no clue what numbers the key I'd like to use correspons with...:(
Besides that, fantastic mod! I've never used torches very often because of the hassle of having to equip them, especially between fights. With this mod, I'm nearly always using torches when dungeon-delving.
EDIT: Abot posted a fix for the above issue on MWSE Containers' mod page. Works perfectly!
https://www.nexusmods.com/morrowind/mods/44387/?tab=posts