📄 mailmonitor.lua
字号:
--------------------------------------------------------------------------------- InboxTask::OnEvent-------------------------------------------------------------------------------function InboxTask_OnEvent(this, event) return false;end--------------------------------------------------------------------------------- InboxTask::OnUpdate-------------------------------------------------------------------------------function InboxTask_OnUpdate(this) return false;end--------------------------------------------------------------------------------- InboxTask::Execute-------------------------------------------------------------------------------function InboxTask_Execute(this) return false;end--------------------------------------------------------------------------------- WaitForInboxUpdate constructor-------------------------------------------------------------------------------function createWaitForInboxUpdateTask() local task = {}; task.name = "WaitForInboxUpdate"; task.OnEvent = WaitForInboxUpdate_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = InboxTask_Execute; return task;end--------------------------------------------------------------------------------- WaitForInboxUpdate::OnEvent-------------------------------------------------------------------------------function WaitForInboxUpdate_OnEvent(this, event) local satisfied = false; if (event == "MAIL_INBOX_UPDATE") then satisfied = true; end return satisfied;end--------------------------------------------------------------------------------- WaitForTakeInboxItem constructor-------------------------------------------------------------------------------function createWaitForTakeInboxItem(index) local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply = GetInboxHeaderInfo(index); local task = {}; task.index = index; task.isSenderAH = isSenderAuctionHouse(sender); task.name = "WaitForTakeInboxItem"; task.OnEvent = WaitForTakeInboxItem_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = InboxTask_Execute; return task;end--------------------------------------------------------------------------------- WaitForTakeInboxItem::OnEvent-------------------------------------------------------------------------------function WaitForTakeInboxItem_OnEvent(this, event, arg1) local satisfied = false; if (event == "MAIL_INBOX_UPDATE") then -- TODO: Verify that the item was looted. satisfied = true; -- If the message was from the AH, it will be deleted automatically. if (this.isSenderAH) then addTask(createWaitForDeleteInboxItem(this.index), true); end elseif (event == "UI_ERROR_MESSAGE" and arg1) then -- Check for errors in taking the inbox item. if (arg1 == ERR_ITEM_MAX_COUNT or arg1 == ERR_INV_FULL) then satisfied = true; end end return satisfied;end--------------------------------------------------------------------------------- WaitForTakeInboxMoney constructor-------------------------------------------------------------------------------function createWaitForTakeInboxMoney(index) local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply = GetInboxHeaderInfo(index); local task = {}; task.index = index; task.isSenderAH = isSenderAuctionHouse(sender); task.name = "WaitForTakeInboxMoney"; task.OnEvent = WaitForTakeInboxMoney_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = InboxTask_Execute; return task;end--------------------------------------------------------------------------------- WaitForTakeInboxMoney::OnEvent-------------------------------------------------------------------------------function WaitForTakeInboxMoney_OnEvent(this, event) local satisfied = false; if (event == "MAIL_INBOX_UPDATE") then -- TODO: Verify that the money was looted. satisfied = true; -- If the message was from the AH, it will be deleted automatically. if (this.isSenderAH) then addTask(createWaitForDeleteInboxItem(this.index), true); end end return satisfied;end--------------------------------------------------------------------------------- WaitForDeleteInboxItem constructor-------------------------------------------------------------------------------function createWaitForDeleteInboxItem(index) local task = {}; task.index = index; task.targetMessageCount = GetInboxNumItems() - 1; task.name = "WaitForDeleteInboxItem"; task.OnEvent = WaitForDeleteInboxItem_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = InboxTask_Execute; return task;end--------------------------------------------------------------------------------- WaitForDeleteInboxItem::OnEvent-------------------------------------------------------------------------------function WaitForDeleteInboxItem_OnEvent(this, event) local satisfied = false; if (event == "MAIL_INBOX_UPDATE") then -- Check if the message was deleted satisfied = (this.targetMessageCount == GetInboxNumItems()); end return satisfied;end--------------------------------------------------------------------------------- WaitForInvoiceTask constructor-------------------------------------------------------------------------------function createWaitForInvoiceTask(index) local task = {}; task.index = index; task.name = "WaitForInvoiceTask"; task.start = time(); task.OnEvent = WaitForInvoiceTask_OnEvent; task.OnUpdate = WaitForInvoiceTask_OnUpdate; task.Execute = InboxTask_Execute; return task;end--------------------------------------------------------------------------------- WaitForInvoiceTask::OnEvent-------------------------------------------------------------------------------function WaitForInvoiceTask_OnEvent(this, event) local satisfied = false; if (event == "MAIL_INBOX_UPDATE") then local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(this.index); if (playerName) then satisfied = true; end end return satisfied;end--------------------------------------------------------------------------------- WaitForInvoiceTask:OnUpdate-------------------------------------------------------------------------------function WaitForInvoiceTask_OnUpdate(this) local satisfied = false; if (this.start + 30 > time()) then statisfied = true; end return satisfied;end--------------------------------------------------------------------------------- WaitForReadMessage constructor-------------------------------------------------------------------------------function createWaitForReadMessage(index) local task = {}; task.index = index; task.name = "WaitForReadMessage"; task.OnEvent = WaitForReadMessage_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = InboxTask_Execute; return task;end--------------------------------------------------------------------------------- WaitForReadMessage::OnEvent-------------------------------------------------------------------------------function WaitForReadMessage_OnEvent(this, event) local satisfied = false; if (event == "MAIL_INBOX_UPDATE") then local packageIcon, stationeryIcon, sender, subject, money, CODAmount, daysLeft, hasItem, wasRead, wasReturned, textCreated, canReply = GetInboxHeaderInfo(this.index); if (wasRead) then satisfied = true; end end return satisfied;end--------------------------------------------------------------------------------- ProcessMessageTask constructor-------------------------------------------------------------------------------function createProcessMessageTask(index, messageAgeInSeconds) local task = {}; task.index = index; task.messageAgeInSeconds = messageAgeInSeconds; task.name = "ProcessMessageTask"; task.OnEvent = InboxTask_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = ProcessMessageTask_Execute; return task;end--------------------------------------------------------------------------------- ProcessMessageTask::Execute-------------------------------------------------------------------------------function ProcessMessageTask_Execute(this) processMailMessage(this.index, this.messageAgeInSeconds); return true;end--------------------------------------------------------------------------------- TakeInboxMoneyTask constructor-------------------------------------------------------------------------------function createTakeInboxMoneyTask(index) local task = {}; task.index = index; task.name = "TakeInboxMoneyTask"; task.OnEvent = InboxTask_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = TakeInboxMoneyTask_Execute; return task;end--------------------------------------------------------------------------------- TakeInboxMoneyTask::Execute-------------------------------------------------------------------------------function TakeInboxMoneyTask_Execute(this) TakeInboxMoney(this.index); return true;end--------------------------------------------------------------------------------- TakeInboxItemTask constructor-------------------------------------------------------------------------------function createTakeInboxItemTask(index) local task = {}; task.index = index; task.name = "TakeInboxItemTask"; task.OnEvent = InboxTask_OnEvent; task.OnUpdate = InboxTask_OnUpdate; task.Execute = TakeInboxItemTask_Execute; return task;end--------------------------------------------------------------------------------- TakeInboxItemTask::Execute-------------------------------------------------------------------------------function TakeInboxItemTask_Execute(this) TakeInboxItem(this.index); return true;end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -