--[[ Prints all of the properties and their values for the given instance of a CEobject propertyprint(CEobject) --]] function propertyprint(ceClassObject) if type(ceClassObject) ~= 'userdata' then return end local function grabMT(ceObject) if type(ceObject) ~= 'userdata' then return end local om = getmetatable(ceObject) if type(om) == 'nil' then return end local mtKeys = {} for k, v in pairs(om) do if type(v) ~= 'function' then table.insert(mtKeys, k) end end return mtKeys end local function iterTbl(tbl, indent) local oTbl = tbl local ind = indent+1 local padd = string.rep('\t', ind) for k, v in pairs(oTbl) do print(padd..'<'..tostring(k)..'> = '..tostring(v)) end print(padd..'}') end local function propertiesStringTbl(multiLineString) if type(multiLineString) ~= 'string' then return end local str = multiLineString if str:sub(-1, -1) ~= '\n' then str = str..'\n' end local newLinePositions = {} local i = 0 while true do i = string.find(str, '\n', i+1) if i == nil then break end table.insert(newLinePositions, i) end local strLines = {} for k, v in ipairs(newLinePositions) do if k == 1 then table.insert(strLines, str:sub(1, v-2)) else local ind = k-1 table.insert(strLines, str:sub(newLinePositions[ind]+1, v-2)) end end return strLines end local ceobj = ceClassObject local propertyList = getPropertyList(ceobj) local propStrTbl = propertiesStringTbl(propertyList.Text) local checkMT = false local mtKeys = grabMT(ceobj) if type(mtKeys) ~= 'nil' then checkMT = true end local function _propertyprint(ceobj, indent) local obj = ceobj local ind = indent+1 local padd = string.rep('\t', ind) local pList = getPropertyList(obj) if type(pList) == 'nil' then return end local pStrList = propertiesStringTbl(pList.Text) for k, v in ipairs(pStrList) do local opv = obj[v] local strOV = tostring(opv) if strOV:sub(1, 8) == 'userdata' then strOV = '{' end print(padd..'<'..v..'> = '..strOV) if tostring(opv):sub(1, 8) == 'userdata' then _propertyprint(opv, ind) print(padd..'}') end end end for k, v in ipairs(propStrTbl) do local objName = ceobj.Name if type(objName) == 'nil' or objName == '' or objName == ' ' then objName = '' else objName = objName..'.' end local objPropVal = ceobj[v] local strV = tostring(objPropVal) if strV:sub(1, 8) == 'userdata' then strV = '{' end print('<'..objName..v..'> = '..strV) local objCheckMT = v if checkMT == true then for i = 1, #mtKeys do if tostring(mtKeys[i]) == objCheckMT then table.remove(mtKeys, i) end end end if tostring(objPropVal):sub(1, 8) == 'userdata' then _propertyprint(objPropVal, 0) print('}') end end print('\n\r {') for i = 1, #mtKeys do local pp = tostring(mtKeys[i]) local pn = 'nil' if type(ceobj[pp]) ~= 'nil' then pn = tostring(ceobj[pp]) end if pn:sub(1, 8) == 'userdata' or pn:sub(1, 5) == 'table' then pn = '{' end print('\t['..i..']: <'..tostring(mtKeys[i])..'> = '..pn) local var = tostring(ceobj[pp]) if var:sub(1, 5) == 'table' then iterTbl(ceobj[pp], 0) end end end registerLuaFunctionHighlight('propertyprint')