ITEMINSPECTIONUI – PLUGIN API (v3.0)

ItemInspectionUI now works as an extensible Framework, allowing other mods to inject custom descriptions, behaviors, and inspection logic without modifying the core files.

This API is safe, stable, and compatible with any modded item.

WHAT THIS API ALLOWS

✔ Fully override an item's description
✔ Add extra text to the vanilla description
✔ Modify descriptions based on category
✔ Implement custom logic for specific items
✔ Add compatibility packs for other mods without touching the base mod

All via:

ItemInspection.RegisterPlugin(pluginTable)

HOW TO CREATE A PLUGIN

Create a file in your mod, for example:

media/lua/shared/MyPlugin.lua

Content:

require "InspectSystem/Core/Inspect_Plugins"

local plugin = {
    id = "MyMod.ExamplePlugin",
    priority = 50, -- higher = executed first

    -- Override: replace the entire description
    describe = function(item, statMap, parent, child, _)
        if item:getFullType() == "MyMod.SpecialItem" then
            return "This is a fully custom description written by a plugin."
        end
        return nil -- do not affect other items
    end,

    -- Post-process: modify or extend the vanilla description
    post = function(item, statMap, parent, child, desc)
        if parent == "Food" then
            return desc .. " (Enhanced by MyMod Plugin)"
        end
        return desc
    end,
}

ItemInspection.RegisterPlugin(plugin)

PLUGIN SIGNATURE

A plugin is a simple table with optional fields:

{
    id = "unique_string_identifier",
    priority = number (default = 0),
    describe = function(item, statMap, parent, child, baseDesc),
    post = function(item, statMap, parent, child, currentDesc),
}

Rules:

describe(): if it returns a non-empty string, the vanilla description is skipped.

post(): executed after vanilla (or override), can modify the final text.

Plugins run in descending priority order.

Errors inside plugins are caught via pcall, so they cannot break the framework.

ARGUMENTS PASSED TO PLUGINS

item – the inspected item
statMap – all processed stats
parent – main item category
child – subcategory
desc/baseDesc – current description text

QUICK EXAMPLES

Full override for a single item:

describe = function(item)
    if item:getFullType() == "MyMod.AmberKey" then
        return "A mysterious key dripping with amber energy."
    end
end

Add a line to all medical items:

post = function(item, _, parent, _, desc)
    if parent == "Medical" then
        return desc .. " Sterile and safe to use."
    end
    return desc
end

End of README_PluginAPI.txt