CyberEngineTweaks
CyberEngineTweaks copied to clipboard
Components bug related to props
Reported by @striderxfossility inside #497
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
This has to do with the fact that we copy by value arrays in ToLua, it's a broader project where we need to wrap internal arrays instead of converting to Lua arrays
If you ever decide to "wrap internal arrays instead of converting to Lua arrays": TweakDB::GetFlat can return an array, It shouldn't be wrapped. A Flat shouldn't be modified outside of TweakDB::SetFlat https://github.com/yamashi/CyberEngineTweaks/blob/47f04d660b521467f5d1279986c48717079430cb/src/reverse/TweakDB.cpp#L176-L193
Got it, thanks for the info :)