Skip to content
Warning

The flags contained in Sprite and LayerState are added together during rendering, thus if one is set in Sprite but not LayerState it will still take effect for that layer.

Not fully documented yet, sorry! (A test script is provided below if you'd like to help document this)

Bitset Calculator

Enum "AnimRenderFlags"⚓︎

Value Enumerator Comment
1<<1 GLITCH Rapidly distorts the spritesheet position. Likely used for glitch items generated by CORRUPTED DATA.
1<<4 COLOROFFSET_CHAMPION Used by champion NPCs. If not applied to a champion NPC, it will not render.
1<<5 STATIC Used by Dogma (boss, collectible, related effects).
1<<6 IGNORE_GAME_TIME If set, animated effects (static, golden) will continue animating even if the game is paused.
1<<7 GOLDEN Used by golden trinkets.
1<<10 ENABLE_LAYER_LIGHTING Layer names starting with * will become fullbright.
1<<11 ENABLE_NULL_LAYER_LIGHTING Null layer names starting with * will emit light.
Test script

This script will print to both the console and log whenever an entity has flags applied to it:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
local mod = RegisterMod("REPENTOTEST", 1)

local function debugprint(string)
    print(string)
    Isaac.DebugString(string)
end

function getfilename(sprite)
    local name = sprite:GetFilename()
    local index = string.find(name, "/[^/]*$")
    return string.sub(name, index+1, string.len(name))
end

function printmessage(entity, sprite)
    debugprint("For entity "..entity.Type.."."..entity.Variant.."."..entity.SubType..", frame "..tostring(entity.FrameCount)..", ".."\""..getfilename(sprite).."\":")
end

function splitflags(n) --https://stackoverflow.com/questions/30445776/lua-decompose-a-number-by-powers-of-2
    local res = {}
    local ret = ""
    i = 1
    while i <= n do
        if i&n ~= 0 then -- bitwise and check
            table.insert(res, i)
        end
        i = i << 1 -- bitwise shift to the left
    end

    local count = 0
    for _ in ipairs(res) do count = count + 1 end

    for j,v in ipairs(res) do
        local num = math.floor(math.log(v, 2 ))
        if num == 0 then
            ret = ret.."1"
        else
            ret = ret.."1<<"..num
        end
        if j ~= count then
            ret = ret..", "
        else
            ret = ret.." ("..n..")"
        end
    end
    return ret
end

function mod:CheckFlags(entity)
    local data = entity:GetData()
    local sprite = entity:GetSprite()
    local anm2Flags = sprite:GetRenderFlags()
    local layers = sprite:GetAllLayers()

    local didmessage = false
    if data.layerFlags == nil then
        data.layerFlags = {}
    end

    if anm2Flags > 0 and anm2Flags ~= data.anm2Flags then
        if not didmessage then
            printmessage(entity, sprite)
            didmessage = true
        end
        debugprint("[Sprite]: "..splitflags(anm2Flags))
        data.anm2Flags = anm2Flags
    end

    local layerFlags
    for i = 1, #layers do
        layerFlags = layers[i]:GetRenderFlags()
        if layerFlags > 0 and layerFlags ~= data.layerFlags[i] then
            if not didmessage then
                printmessage(entity, sprite)
                didmessage = true
            end
            debugprint("["..tostring(i).."] \""..layers[i]:GetName().."\": "..splitflags(layerFlags))
            data.layerFlags[i] = layerFlags
        end
    end
end

mod:AddCallback(ModCallbacks.MC_POST_PLAYER_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_TEAR_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_FAMILIAR_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_BOMB_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_PICKUP_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_SLOT_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_LASER_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_KNIFE_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_PROJECTILE_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_NPC_RENDER, mod.CheckFlags)
mod:AddCallback(ModCallbacks.MC_POST_EFFECT_RENDER, mod.CheckFlags)