Skip to content

Instantly share code, notes, and snippets.

@zcdziura
Last active Oct 19, 2016
Embed
What would you like to do?
A simple Lusternia reflex allowing users to see additional information about other players. Written for the Mudlet client.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MudletPackage>
<MudletPackage version="1.0">
<TriggerPackage/>
<TimerPackage/>
<AliasPackage>
<AliasGroup isActive="yes" isFolder="yes">
<name>Player Who</name>
<script></script>
<command></command>
<packageName></packageName>
<regex></regex>
<Alias isActive="yes" isFolder="no">
<name>Player Who</name>
<script>local player = matches[2]
playerWho.enabled = true
downloadFile(getMudletHomeDir() .. &quot;/player-who.json&quot;, string.format(&quot;http://api.lusternia.com/characters/%s.json&quot;, player))</script>
<command></command>
<packageName></packageName>
<regex>^pwho (\w+)$</regex>
</Alias>
</AliasGroup>
</AliasPackage>
<ActionPackage/>
<ScriptPackage>
<ScriptGroup isActive="yes" isFolder="yes">
<name>Player Who</name>
<packageName></packageName>
<script>playerWho = playerWho or {
enabled = false
}</script>
<eventHandlerList/>
<Script isActive="yes" isFolder="no">
<name>Found</name>
<packageName></packageName>
<script>function playerWho.found(_, filename)
if playerWho.enabled then
if not filename:match(&quot;player&quot;) then
hecho(&quot;\n|c00ffffNo player information found&quot;)
return
else
local f = io.open(filename, &quot;r&quot;)
local payload = f:read(&quot;*all&quot;)
if not payload:match(&quot;Character %s+ was not found&quot;) then
payload = yajl.to_value(payload)
hecho(&quot;\n|c00ffffName: |r&quot; .. payload.fullname)
hecho(&quot;\n|c00ffffRace: |r&quot; .. payload.race)
hecho(&quot;\n|c00ffffLevel: |r&quot; .. payload.level)
hecho(&quot;\n|c00ffffOrg: |r&quot; .. payload.city:gsub(&quot;^%l&quot;, string.upper))
hecho(&quot;\n|c00ffffGuild: |r&quot; .. payload.guild:gsub(&quot;^%l&quot;, string.upper))
else
echo(&quot;\n|c00ffffNo player information found&quot;)
end
f:close()
end
playerWho.enabled = false
os.remove(filename)
end
end
registerAnonymousEventHandler(&quot;sysDownloadDone&quot;, &quot;playerWho.found&quot;)</script>
<eventHandlerList/>
</Script>
<Script isActive="yes" isFolder="no">
<name>Not Found</name>
<packageName></packageName>
<script>function playerWho.notFound()
if playerWho.enabled then
hecho(&quot;\n|c00ffffNo player information found&quot;)
playerWho.enabled = false
end
end
registerAnonymousEventHandler(&quot;sysDownloadError&quot;, &quot;playerWho.notFound&quot;)</script>
<eventHandlerList/>
</Script>
</ScriptGroup>
</ScriptPackage>
<KeyPackage/>
</MudletPackage>

Unlicense (Public Domain)

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment