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 19th Dec 2018 at 7:05 PM
Default In-game function to get all sims in a save?
Heya. I'm trying to follow the scripting tutorial here and in particular, I'm stuck on this part:

Quote:
For the town population and all that other jazz, we need to get out of the core module collection and dive into "simulation". In the "sims" folder, there's a file called "sim_info_manager.py". That looks like a good place to start. There's a class in that file called "SimInfoManager". It seems to hold the details of every sim. If we could count all of the sims in its list, then that will give us the population of all sims. While looking through the rest of the code in TS4's repository, I'm noticing a pattern: sim_info_manager is an object in services. Its attachment to services is found in __init__.py inside the services folder. More importantly, it has a function that's called sometimes inside of the code files called get_all(), which returns a list element. That seems to have solved our mystery!


Only I don't see a function named get_all() in the sim_info_manager.py file? And inputting in the OP's exact code doesn't work for me in game. I'm assuming somewhere between the last update of the tutorial and the game's updating that this function is gone or changed; does anyone know of an equivalent function? Or maybe I'm just really, really not seeing it? I've looked through so many files now, and the closest I've come is finding a few functions I can use to get loaded zone population, but not a whole town/all the sims in a save...
Advertisement
Lab Assistant
#2 Old 19th Dec 2018 at 11:38 PM
There is a tuning participant type called AllSims what exactly are you trying to achieve with this you might not have to write a python script
Test Subject
Original Poster
#3 Old 20th Dec 2018 at 6:25 AM
Quote: Originally posted by WildWitch
There is a tuning participant type called AllSims what exactly are you trying to achieve with this you might not have to write a python script


Partly I'm just messing around to figure out some scripting! Secondary goal if-I-can-figure-it-out, I was trying to find a way to make a script that would add a custom trait to all sims of a certain age on save loading. Like, I'm working on a mod that will unlock some traits for kiddos (with common sense limits) and i figured adding a hidden trait with those limits (as a buff maybe??) would be the easist way to do that and have the least amount of conflicts with other mods. Or that's the idea anyway. Haha.

I think you responded to another mod question I had a while ago and I wanted to say a follow up thanks, as I did find looking at grim's files helpful! This kind of branched off that. @_@
Lab Assistant
#4 Old 20th Dec 2018 at 9:01 AM
A way you could do it is make a broadcaster with tests with a loot action that adds the trait, and attach it to an invisible trait that you give a sim. Good luck in your endevours and your welcome I'm glad grims files helped you
Test Subject
Original Poster
#5 Old 20th Dec 2018 at 4:27 PM
Well I don't know what I did the first time...but I got it to work now lol. I think I forgot some parenthesis somewhere. Thanks for the tuning advice tho WildWitch, I'll have to play around with that a bit too!
Deceased
#6 Old 31st Dec 2018 at 7:41 AM
Quote: Originally posted by Evvi
I don't see a function named get_all() in the sim_info_manager.py file?


I see you solved your problem, but thought I'd explain why you aren't seeing that get_all() method. If you look at the SimInfoManager class in sim_info_manager.py, you will see it is defined as a subclass of the DistributableObjectManager class. That class (from object_manager.py) is then a subclass of the IndexedManager class (in indexed_manager.py). That class then actually defines many of the manager get/add/remove/iterator methods and you will see the definiation of get_all() in there.

By doing this, those common methods don't need to be repeatedly defined for every type of object manager in the game. Useful, but does mean you sometimes have to follow the chain of superclasses to find an actual method's definition.
Back to top