Skip to content

Instantly share code, notes, and snippets.

@keevitaja
Created June 7, 2016 12:08
Show Gist options
  • Save keevitaja/ac5c395e51abf17ed02eb6c64062be20 to your computer and use it in GitHub Desktop.
Save keevitaja/ac5c395e51abf17ed02eb6c64062be20 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="jedhi_pup_tracker"
author="Jedhi"
id="c364d2e34c3fca301b9b5d03"
language="Lua"
purpose="For Lazy Mudders"
version="1.0"
>
</plugin>
<aliases>
<alias match="puptracker reset" enabled="y" script="reset"></alias>
<alias match="puptracker simulate" enabled="y" script="simulate"></alias>
</aliases>
<triggers>
<trigger
match="Congratulations, hero. You have increased your powers!"
enabled="y"
script="triggerPup"
>
</trigger>
</triggers>
<script>
<![CDATA[
local lastPup = os.time()
local pupTimes = {}
local channel = 'Echo @WCustom Report: '
local trackerReset = false
function secondsToReadable(raw)
if (raw >= 60) then
local minutes = math.floor(raw/60)
local seconds = raw - (minutes * 60)
return string.format("%s min %s sec", minutes, seconds)
else
return string.format("%s sec", raw)
end
end
function tableSum(table)
local sum = 0
for i,v in ipairs(table) do
sum = sum + v
end
return sum
end
function triggerPup()
if trackerReset == true then
doReset()
trackerReset = false
else
local currentTime = os.time()
local currentPup = currentTime - lastPup
lastPup = currentTime
table.insert(pupTimes, currentPup)
local avaragePupTime = math.ceil(tableSum(pupTimes) / #pupTimes)
local pupMessage = string.format("%s @clast: %s | avarage: %s@w", channel, secondsToReadable(currentPup), secondsToReadable(avaragePupTime))
SendNoEcho (pupMessage)
end
end
function doReset()
lastPup = os.time()
pupTimes = {}
Note('Pup tracker reset')
end
function reset()
trackerReset = true
Note('Resetting pup tracker on next pup')
end
function simulate()
Simulate ("Congratulations, hero. You have increased your powers!\n")
end
]]>
</script>
</muclient>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment