I needed this for something else and since it seems to be fairly useful (if rather trivial) I've posted it :)
What it does is populate the plugin's variable space with the time that it last received a new entity message. Discworld MUD uses these to track hitpoints &c.. and from this information I can add a field to my InfoBar with how old the data is.
You can replace the time.clock() call with a time.time() call if that suits your purposes better.
(time.time() returns the unix epoch tick while time.clock() returns the number of seconds since the first call to time.clock() as a float with millisecond precision)
Also, this should be fairly easy to implement in Lua for portability, but not something I've done yet.
What it does is populate the plugin's variable space with the time that it last received a new entity message. Discworld MUD uses these to track hitpoints &c.. and from this information I can add a field to my InfoBar with how old the data is.
You can replace the time.clock() call with a time.time() call if that suits your purposes better.
(time.time() returns the unix epoch tick while time.clock() returns the number of seconds since the first call to time.clock() as a float with millisecond precision)
Also, this should be fairly easy to implement in Lua for portability, but not something I've done yet.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="mxp_entity_last_received"
author="Isthiriel"
id="321c805e606140f2c3e6272e"
language="Python"
purpose="To track the last received time of various mxp entities."
save_state="y"
date_written="2007-12-29 07:17:54"
requires="4.00"
version="1.0"
>
</plugin>
<script>
<![CDATA[
import re, time
def OnPluginMXPsetEntity(val):
# val is of the form 'entity=newvalue'
m = re.match("^([^=]*)=(.*)$", val)
if not m: # something went wrong, we can't fix it, so ignore it
return 0
world.SetVariable(m.group(1), str(time.clock()))
return 0 # returning a string here gets me a "Type Mismatch <OK>" dialog.
]]>
</script>
</muclient>