diff options
Diffstat (limited to 'script-beta/core/hover/table.lua')
-rw-r--r-- | script-beta/core/hover/table.lua | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua new file mode 100644 index 00000000..9ed86692 --- /dev/null +++ b/script-beta/core/hover/table.lua @@ -0,0 +1,35 @@ +local vm = require 'vm' + +local function checkClass(source) +end + +return function (source) + local fields = {} + local class + vm.eachField(source, function (info) + if info.key == 's|type' or info.key == 's|__name' or info.key == 's|name' then + if info.value and info.value.type == 'string' then + class = info.value[1] + end + end + local type = vm.getType(info.source) + fields[#fields+1] = ('%s'):format(type) + end) + local fieldsBuf + if #fields == 0 then + fieldsBuf = '{}' + else + local lines = {} + lines[#lines+1] = '{' + for _, field in ipairs(fields) do + lines[#lines+1] = ' ' .. field + end + lines[#lines+1] = '}' + fieldsBuf = table.concat(lines, '\n') + end + if class then + return ('%s %s'):format(class, fieldsBuf) + else + return fieldsBuf + end +end |