<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
name="GMCP_Affliction_Tracker"
author="My Name"
id="b1a9d25f4c8e7a92d3b4f6e0"
language="Lua"
purpose="Track GMCP afflictions"
save_state="y"
version="1.2"
>
<description trim="y">
This plugin tracks the afflictions added and removed via GMCP and displays the active afflictions in a table.
</description>
</plugin>
<script>
<![CDATA[
-- Initialize afflictions table if it doesn't exist
if not afflictions then
afflictions = {}
end
-- handle affliction being added
function gmcp_affliction_add()
if gmcp and gmcp.Char and gmcp.Char.Afflictions and gmcp.Char.Afflictions.Add then
local affliction_name = gmcp.Char.Afflictions.Add.name
if affliction_name then
-- Add affliction to the list
table.insert(afflictions, affliction_name)
ColourNote("green", "", "Affliction added: " .. affliction_name)
-- Display updated afflictions
display_afflictions_table()
else
ColourNote("red", "", "No valid affliction add name received in GMCP.")
end
else
ColourNote("red", "", "No valid affliction add data received in GMCP.")
end
end
-- handle affliction being removed
function gmcp_affliction_remove()
if gmcp and gmcp.Char and gmcp.Char.Afflictions and gmcp.Char.Afflictions.Remove then
local affliction_name = gmcp.Char.Afflictions.Remove[1]
if affliction_name then
-- Remove affliction by name
for i, name in ipairs(afflictions) do
if name == affliction_name then
table.remove(afflictions, i)
ColourNote("green", "", "Affliction removed: " .. affliction_name)
display_afflictions_table()
break
end
end
else
ColourNote("red", "", "No valid affliction remove name received in GMCP.")
end
else
ColourNote("red", "", "No valid affliction remove data received in GMCP.")
end
end
-- display all active afflictions in a table format
function display_afflictions_table()
ColourNote("white", "blue", "=== Active Afflictions ===")
if #afflictions == 0 then
ColourNote("yellow", "", "No active afflictions.")
else
local affliction_list = table.concat(afflictions, ", ")
ColourNote("yellow", "", "Current Afflictions: " .. affliction_list)
end
end
-- gmcp event handling for affliction add-remove
function OnPluginTelnetSubnegotiation(msg_type, data)
if msg_type == 201 then -- GMCP Telnet subnegotiation type is 201
local message = string.match(data, "([%a.]+)%s+(.*)")
if message == "Char.Afflictions.Add" then
gmcp_affliction_add()
elseif message == "Char.Afflictions.Remove" then
gmcp_affliction_remove()
end
end
end
]]>
</script>
</muclient>I wrote this plugin to display my own afflictions in a table in an IRE game. However, I keep getting the result 'No valid affliction add data received in GMCP.' every time an affliction is added or removed. Thank you in advance for your help.
Edit: GMCP_handler_NJG plugin installed.