How to handle unknown initialization functions in lua?

I want to download data written in the lua variant (eyeonScript). However, the data is flooded with references to initialization functions that are not lua equal:

Redden = BrightnessContrast {
    Inputs = {
        Red = Input {
            Value = 0,
        },
    },
}

Standard lua gives the error "try to call a null value" or "unexpected character". Is there a way to catch them and pass them to some common initializer?

I want to finish with a nested table data structure.

Thank!

+3
source share
2 answers

Set the meta __indexfor the global variable table. For example, so undefined functions behave like an identity:

setmetatable(_G,{__index=function (n)
                           return function (x) return x end
                         end})
+4
source

: __call nil, C . , undefined:

debug.setmetatable(nil,{__call=function (x,v) return v end})
+2

Source: https://habr.com/ru/post/1743224/


All Articles