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!
Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 6th Nov 2019 at 11:31 AM
Script automation help
Hello,
I made command script, where i write word in to the console and then magic happens , it all works fine, but now i wanted it to run withut writing it in console. I wanted script to run evry one hour in Sims4, also evry household exit, and before save game, how i can made this?
Advertisement
Lab Assistant
#2 Old 8th Nov 2019 at 9:54 PM
Hey! That's a lot of different things. I don't have the time to go into details, but I can tell you the basics.

Running something after a set amount of time and repeating it can be achieved with an Alarm. There are other ways, but this is the safest simulation-wise approach. Look for the usage of the "alarms.add_alarm" function in the game code, it should include everything you need. Set the TimeSpan to 90000 ticks (1500 * 60, one in-game minute is 1500ms) and set it to repeat. You need to remember that the handle instance that gets returned after creating an alarm using this function has to be stored somewhere or the garbage collector will automatically stop it and remove it.

Detecting zone teardown (exiting) and game saving require injecting. You can find a tutorial about it on this forum made by Scumbumbo. You need to inject into the "on_teardown" method in the "Zone" class for detecting the zone teardown, it's required to run your code before the original code. For saving you need to inject into the "save_zone" method in the Zone class, same thing. I would recommend learning about catching exceptions and making sure to return the result of the original methods, as well as passing all of the arguments and keyword arguments safely, as breaking these functions breaks the game as well.

Good Luck!
Back to top