Inspect self while debugging?

Is it not possible to inspect the contents of self of a script in any way?

I can’t remember, but you cannot pprint self right? Hmm, yes, iterating self is not possible.

Is this the same reason, why self content is not visible in debugger variables?



1 Like

I just attempted this in a script:

function init(self)
    local _self = {self}
    mt = {
        __newindex = function(t, k, v)
            t[1][k] = v
            rawset(t, k, v)
    setmetatable(_self, mt)
    _self.f = 01

And it gave me the following output:

{ --[[000001FD5E4963B0]]
  1 = Script: 0x01fd5e49dfb0,
  f = 1

I think this combined with tracking the table changes (I don’t know how to do it yet since I haven’t read up on it yet ), a self-inspection utility module is possible while keeping dynamic assignments fairly straightforward. Possible there’s a weird gotcha in there somewhere, though?