Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 10th Jan 2021 at 7:40 PM
Default How to get interaction to trigger my python script
Right now, I have a python function that works and pretty much does what I want. However it is triggered my a command in the cheat window. I want it to trigger when a sim does an action. For example, it will trigger when I click on a chair and click sit.
Advertisement
Field Researcher
#2 Old 10th Jan 2021 at 8:26 PM
You need to add do_command to the interaction.

Creator Musings is a Sims 4 modder, poser/animator, and CC creator hangout server (though everyone is allowed) with a tutorial/resource directory, help channels, and mod/cc/sims 4 news channels!
My Discord | Twitter | Tumblr | Patreon
Test Subject
Original Poster
#3 Old 10th Jan 2021 at 8:33 PM
Quote: Originally posted by MizoreYukii
You need to add do_command to the interaction.

Can that be done strictly with python or am I adding do_command in the xml file for the interaction?
Field Researcher
#4 Old 10th Jan 2021 at 9:56 PM
Quote: Originally posted by marcgood1996
Can that be done strictly with python or am I adding do_command in the xml file for the interaction?

XML File. You might be able to inject the do_command but I don't know.

Creator Musings is a Sims 4 modder, poser/animator, and CC creator hangout server (though everyone is allowed) with a tutorial/resource directory, help channels, and mod/cc/sims 4 news channels!
My Discord | Twitter | Tumblr | Patreon
Test Subject
Original Poster
#5 Old 10th Jan 2021 at 10:18 PM
Quote: Originally posted by MizoreYukii
XML File. You might be able to inject the do_command but I don't know.

Thanks alot this was a great help
Lab Assistant
#6 Old 18th Jan 2021 at 6:00 AM
If you'd like to go full script mode you can extend the different SuperInteraction classes and override the method that runs the interaction.
Code:
from interactions.base.immediate_interaction import ImmediateSuperInteraction

class MyCustomImmediateSuperInteraction(ImmediateSuperInteraction):
    def _run_interaction_gen(self, timeline):
        super()._run_interaction_gen(timeline)
        # do something here

now you can reference this new class in your xml files assuming your mod has the following folder structure: my_custom_mod > interactions > my_interactions.py
Code:
<I c="MyCustomImmediateSuperInteraction" i="interaction" m="my_custom_mod.interactions.my_interactions" n="my_name:my_custom_mod" s="123456789">

calling super()._run_interaction_gen within your method calls the original method so any of the existing loot or outcomes within the xml still occur. you can move it above or below your custom code depending on the order you want the interaction to occur.
Back to top