Skip to content

Commit 8565e0c

Browse files
authored
Add files via upload
1 parent 93834bd commit 8565e0c

File tree

4 files changed

+133
-0
lines changed

4 files changed

+133
-0
lines changed

.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# remove ide files
2+
/.idea
3+
4+
# Compiled Lua sources
5+
luac.out
6+
7+
# luarocks build files
8+
*.src.rock
9+
*.zip
10+
*.tar.gz
11+
12+
# Object files
13+
*.o
14+
*.os
15+
*.ko
16+
*.obj
17+
*.elf
18+
19+
# Precompiled Headers
20+
*.gch
21+
*.pch
22+
23+
# Libraries
24+
*.lib
25+
*.a
26+
*.la
27+
*.lo
28+
*.def
29+
*.exp
30+
31+
# Shared objects (inc. Windows DLLs)
32+
*.dll
33+
*.so
34+
*.so.*
35+
*.dylib
36+
37+
# Executables
38+
*.exe
39+
*.out
40+
*.app
41+
*.i*86
42+
*.x86_64
43+
*.hex

OutOfMana2.iml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="WEB_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$" />
6+
<orderEntry type="inheritedJdk" />
7+
<orderEntry type="sourceFolder" forTests="false" />
8+
</component>
9+
</module>

OutOfMana2.toc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Interface: 90207v
2+
## Version: v1.0
3+
## Title: |cFF7FFFD4OutOfMana2|r by: |cFFE6CC80Gonzo Inc
4+
## Notes: |cFFE6CC80Send an alert when reaching a certain mana percentage (/mana on chat to config).
5+
## Author: GonzoInc
6+
## SavedVariables: OutOfManaDB2
7+
8+
main.lua

main.lua

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
-- constants
2+
local playerName = UnitName("player")
3+
local defaultMpThreshold = 50
4+
local antiSpamThresholdValue = 20
5+
6+
-- Saved vars (config)
7+
local mpThreshold -- mp = mana percentage
8+
9+
-- vars
10+
local antiSpam = false
11+
local antiSpamThreshold
12+
13+
local version = GetAddOnMetadata("OutOfMana2","Version")
14+
-- Addon loaded message
15+
print("|c0003fc07OOM |r[v|c0003fc07" .. version .. "|r] loaded: /mana")
16+
17+
-- Handle Events
18+
local f = CreateFrame("Frame");
19+
f:RegisterEvent("ADDON_LOADED")
20+
f:RegisterEvent("PLAYER_LOGOUT")
21+
f:RegisterEvent("UNIT_POWER_UPDATE")
22+
23+
function f:OnEvent(event, arg1, arg2)
24+
if event == "ADDON_LOADED" and arg1 == "OutOfMana2" then
25+
if not OutOfManaDB2 then
26+
OutOfManaDB2 = {}
27+
OutOfManaDB2.mpThreshold = defaultMpThreshold
28+
end
29+
mpThreshold = OutOfManaDB2.mpThreshold
30+
antiSpamThreshold = mpThreshold + antiSpamThresholdValue
31+
end
32+
if event == "PLAYER_LOGOUT" then
33+
OutOfManaDB2.mpThreshold = mpThreshold
34+
end
35+
if event == "UNIT_POWER_UPDATE" then
36+
local mp = (UnitPower("player", 0) / UnitPowerMax("player")) * 100 -- current player mana percentage
37+
if (arg1 == "player") and (arg2 == "MANA") and (mp <= mpThreshold) and (not antiSpam) then
38+
DoEmote("OOM")
39+
SendChatMessage(playerName .. " - I have " .. round(mp) .. "% mana!", IsInGroup(LE_PARTY_CATEGORY_INSTANCE) and "INSTANCE_CHAT" or IsInRaid() and "RAID" or "PARTY")
40+
antiSpam = true
41+
end
42+
if (arg1 == "player") and (arg2 == "MANA") and (mp >= antiSpamThreshold) and antiSpam then
43+
antiSpam = false
44+
end
45+
end
46+
end
47+
48+
f:SetScript("OnEvent", f.OnEvent)
49+
50+
function round(number)
51+
if (number - (number % 0.1)) - (number - (number % 1)) < 0.5 then
52+
number = number - (number % 1)
53+
else
54+
number = (number - (number % 1)) + 1
55+
end
56+
return number
57+
end
58+
59+
-- Commands
60+
SLASH_SAVED1 = "/mana";
61+
function SlashCmdList.SAVED(msg)
62+
if msg ~= "" then
63+
mpThreshold = tonumber(msg)
64+
print("Changed limit to: " .. mpThreshold .. "%")
65+
if (mpThreshold + antiSpamThresholdValue > 100) then
66+
antiSpamThreshold = 100
67+
else
68+
antiSpamThreshold = mpThreshold + antiSpamThresholdValue
69+
end
70+
else
71+
print("Limit: " .. mpThreshold .. "%" .. " (\"/mana number\" to change)")
72+
end
73+
end

0 commit comments

Comments
 (0)