tts-community / tts-community-bug-tracker

Community maintained list of Tabletop Simulator bugs.
2 stars 0 forks source link

obj.addAttachment(child) resets the child material if they are an assetbundle #33

Open leberechtreinhold opened 3 years ago

leberechtreinhold commented 3 years ago

Describe the bug If you have an object 'child' which is in an asset bundle, and you change the material, those changes are resetted if you do any_other_obj.addAttachment(child).

To Reproduce

Expected behavior

Screenshots If applicable, add screenshots to help explain your problem.

Tabletop Simulator Info (please complete the following information):

Known workarounds None

Additional context I have tried several workarounds to no avail. The idea was to change after the attachment, but I cannot seem to get a valid object. I tried "obj.getAttachments()", but this give a GUID that I cannot combine with "getObjectFromGUID()", since it returns nil as with all attachments. I investigated further and there was a "obj.getChild(name)", but apparently it uses the gameobj name, not the tts name, and for this use case, the name is... "Custom_Assetbundle(clone)", so not useful at all. Looking more options I found a "obj.getChildren()", with seemed promising, but with a bunch of "log()" I discored it is a LuaGameObjectReference instead of a LuaGameObjectScript. Funnily enough I can get the Custom_Assetbundle(clone) here (which I couldn't directly from the obj), but no way to access anything that will bbe usable by "setMaterialValue". It does have a "getComponents()" functions, which behave like "obj.getComponentInChildren", and this gives me a MeshRenderer, but If I try to use material.SetFloat() I'm blocked by MoonSharp.

Working but not really feasible workarounds are to essentially have all the possible values in a different assetbundles, and spawn each of them in each change. But in my case, considering combinations, it's not really usable. Same for using the TTSEffects.