CyberEngineTweaks icon indicating copy to clipboard operation
CyberEngineTweaks copied to clipboard

Find components by name

Open striderxfossility opened this issue 3 years ago • 3 comments

Idea: Is there a way to tell in scripting all the components the objects have?

for example, in save editor I can drop the player_female.entity and see all the components, the components can be called with the following script:

player:FindComponentByName(CName.new("TPPRepresentation")) -- Car/Body component
player:FindComponentByName(CName.new("root")) -- Animation Component

-- BUT ALSO (THIS IS FOR FEMALE PLAYER ONLY)
player:FindComponentByName(CName.new("body")) -- Mesh Component

But it would be nice if there is a function to see all the components on a certain class, not only player.

And by the why, root component have all sorts of UKNOWN TYPES.

striderxfossility avatar Feb 16 '21 14:02 striderxfossility

Also there is a BUG in these components related to props.

For example:

local tpp = player:FindComponentByName(CName.new("TPPRepresentation"))
print(tpp.detachedObjectInfo[1].itemTDBID) -- prints "Items.PlayerFppHead" CName
tpp.detachedObjectInfo[1].itemTDBID = TweakDBID.new("Items.PlayerWaTppHead")

print(tpp.detachedObjectInfo[1].itemTDBID) -- Still prints "Items.PlayerFppHead" CName

WORKAROUND FOR NOW:

local tpp     = player:FindComponentByName(CName.new("TPPRepresentation"))
local obj     = NewObject('gameFppRepDetachedObjectInfo')
obj.slotID    = TweakDBID.new("TppHead")
obj.itemTDBID = TweakDBID.new("Items.PlayerWaTppHead")

tpp.detachedObjectInfo = {obj}

print(tpp.detachedObjectInfo[1].itemTDBID) -- now prints "Items.PlayerWaTppHead" CName

striderxfossility avatar Feb 16 '21 15:02 striderxfossility

I'll split this into two issues if you dont mind cause having enhancement and bug in one is not ideal :P

WSSDude avatar Feb 17 '21 11:02 WSSDude

yes good idea, i hide the comment.

striderxfossility avatar Feb 17 '21 11:02 striderxfossility