Forum Discussion

tastytourist's avatar
9 years ago

Applying material_state in interactions

I made an object that I would like to be able to change its material state depending on how it is used in game. However I can't get the state change to work -- the actual material state itself works fine (when applied with the design tool I mean), and I'm not getting any exceptions either when I try to do the state change in game (by way of the interaction).

Right now, for testing / unborking, I'm trying to get it to work the way the Bonsai Pot does it, with an immediate super interaction that's available directly on the object. (Next step would be to tie that into the actual crafting procedure, but for that I want to verify first that the state change works on its own .. )


What I have atm:

* State list, like in the bonsai (I'm only using the last one -- "_grape" -- for testing):

S4_5B02819E_00000000_9C7DAF25_pbox_juiceblender.xml
Spoiler



3951525336
4124636623
801373366
517599605
4031633664
3659597537




* Individual states, also like in the bonsai:

S4_5B02819E_00000000_DA2106E1_pbox_juiceblender_grape.xml
Spoiler






* Interaction (C+P from the bonsai, more or less):

S4_E882D22F_00000000_99B82F067DC5279D_pbox_juiceblender_ChangeObjMaterialState_grape_Immediate.xml
Spoiler








3659597537






0x77CF3624




Actor




Object





False

OBJECT




26171







TEEN
YOUNGADULT
ADULT
ELDER
CHILD


Actor






* And finally, the object tuning - relevant bits:

S4_B61DE6B4_00000000_80607E2FF8C97A8F_pbox_object_JuiceBlender.xml













517599605




set1-materialVariant






3951525336




drink_03






4124636623




drink_04






801373366




drink_05






4031633664




drink_07






3659597537




drink_08







517599605






77076


77077



77076

True



35956


35957



35957







NONE


11076654988444116893




Can't post the full code here since it's telling me "Body is 13997 characters too long" =P


The name of the material state is correct as well, as far as I can see -- I gave the object a catalog instance with "drink_08" as material variant name, and with the design tool I can use that just fine.

Object upload is here -- this is split into three packages, "interactions" is the most interesting one right now (plus "object" which has the actual recolour). The previous version, without the material stuff, is also available here.
  • To my knowledge, material states do not correspond to the material state variants available in the catalog. You should compare it with an object that implements dirty/clean, as those use material states.

    To test whether or not your interaction and state setup is correct, apply a tint or opacity change on the state instead of a material state change.

    Hope that helps.
  • "SimGuruEugi;14491599" wrote:
    To my knowledge, material states do not correspond to the material state variants available in the catalog. You should compare it with an object that implements dirty/clean, as those use material states.


    Ah, gotcha -- I mixed up material states and material variants; what I actually meant to change was the variant!

    Re. clean/dirty states, this object has

          
    : Index: 0x00000017 (0x01 (Private)); MaterialState: 0x00000000 (0); MaterialVariant: 0xF4BD1CE9
    : Index: 0x00000018 (0x01 (Private)); MaterialState: 0xC3867C32 (Burnt); MaterialVariant: 0xF4BD1CE9
    : Index: 0x00000019 (0x01 (Private)); MaterialState: 0xEEAB4327 (Dirty); MaterialVariant: 0xF4BD1CE9


    0xEEAB4327 (Dirty) is also what is in the state list in the tuning:


    15131




    Dirty






    Looks like all I need to do is change the variants instead (each should still be able to have a dirty / burnt state) .. looking at bookThin_Cooking_Advanced it seems like that works exactly the same, so yay!


    E: yes, that solves half the issue =D



    3659597537



    drink_08





    This is working now with the direct interaction .. I've yet to see how I'll squeeze it into the crafting, but that's a different can of worms.

    Thank you!
  • So now I seem to be stuck at the next step -- "how I'll squeeze it into the crafting" >.<

    This is the relevant bit of one of my recipes (which works fine when I leave it like that):




    CreateCraftingComponentOnObject



    CreateCraftingComponentOnObject



    14367




    0
    2
    0x2642142E
    (etc etc)



    When I try to put in another phase at the start, it stops showing up -- even when that phase doesn't contain a super affordance at all (shouldn't that work no matter what?), or something (seemingly) harmless like cheat_MakeDirty:




    ChangeObjectMaterial



    ChangeObjectMaterial



    CreateCraftingComponentOnObject

    14981707989595339024




    CreateCraftingComponentOnObject



    14367




    0


    Is there anything wrong with the code above? Or would the problem be with the linked super affordance itself?

    For CreateCraftingComponentOnObject I would like to use the original teaMaker interaction, since when I change that to a custom one, sims stop routing to the object at the start. I believe this is because it is listed in S4_7DF2169C_00000000_0000000000003FCC_cooking_Counter.xml and that is something I wouldn't want to override.

    Re. the material change, I suspect the issue is that I'm using the wrong interaction type -- originally it was ImmediateSuperInteraction (that one works via the pie menu, but not in the recipe); now I think it would have to be a CraftingPhaseStagingSuperInteraction, but I can't get that to work either. I also looked at the various computer interactions and how those do the state changes .. all I can see is that it *should* work, but doesn't =(.

    The only exception I ever got was "_use_animation_constraint_cache AttributeError: type object 'pbox_juiceblender_ChangeObjMaterial_grape' has no attribute '_animation_constraint_dirty'" but unfortunately I didn't pay attention as to how I made that happen exactly, and now I can't repro it >.<

About The Sims 4 Mods & Custom Content

Find expert tips, troubleshooting help, tutorials for mods and custom content, and The Sims 4 patch files in our forum.4,703 PostsLatest Activity: 8 hours ago