Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------
- -- Zerkish Hotkeys Improved Modders Resource
- -----------------------------------------------
- -------------------------
- -- Interface
- -------------------------
- -- Some parts of ZHI are exposed through an interface on the player.
- local ZHI = require('openmw.interfaces').ZHI
- if ZHI.version >= myRequiredVersion then
- ...
- end
- Useful Types:
- --------------------
- ZHI.ZHI_WINDOW = {
- Main,
- MagicSelection,
- InventorySelection,
- HotkeySelect,
- FirstTimePopup,
- QuickKeyMenuPopup,
- }
- Useful functions:
- isWindowOpen(ZHI_WINDOW)
- isAnyWindowOpen()
- -- Returns hotbar number
- getActiveHotbar()
- -- Get layers used by ZHI
- getPopupLayer()
- getTooltipLayer()
- ----------------------------
- -- Events
- ----------------------------
- -- These are events sent by ZHI when hotkeys are used.
- -- ZHI_HotkeySelectEvent
- --------------------------------------------------------------------
- -- This event will be sent any time the player presses a hotkey that has something useable on it.
- -- Keep in mind that this does not guarantee that the player can immediately use the item/spell,
- -- if the player is in an animation for instance.
- -- For item usage, the player needs to have the item in their inventory, or the event won't be sent.
- local function sendZHIHotkeyEvent(spell, item, itemEnchant)
- if (not spell) and (not item) and (not itemEnchant) then return end
- local data = {}
- if spell then
- data.spell = {
- id = spell.id
- }
- elseif item then
- data.item = {
- id = item.id,
- recordId = item.recordId,
- typeName = tostring(item.type),
- }
- elseif itemEnchant then
- -- This is set when the item will be used for its enchantment.
- -- the fields are the same as for data.item
- data.itemEnchant = {
- id = itemEnchant.id,
- recordId = itemEnchant.recordId,
- typeName = tostring(itemEnchant.type),
- }
- end
- self:sendEvent('ZHI_HotkeySelectEvent', data)
- end
- -- ZHI_HotkeyEquipEvent
- --------------------------------------------------------------------
- -- This is sent when ZHI equips an item.
- -- It is not sent if the item is already equipped.
- local function sendZHIHotkeyEquipEvent(item, equipmentSlot)
- if (not item) then return end
- local data = {
- item = {
- id = item.id,
- typeName = tostring(item.type),
- },
- equipmentSlot = equipmentSlot,
- }
- self:sendEvent('ZHI_HotkeyEquipEvent', data)
- end
Advertisement
Add Comment
Please, Sign In to add comment