Posts: 2,162
Thanks: 43133 in 137 Posts
21 Achievements
If you look at the XML for the interactions in the mailbox testing cheats tutorial, you'll see in the do_command tuning that we specify that an argument should be sent to the command.
Code:
<V t="do_command">
<U n="do_command">
<L n="arguments">
<V t="participant" />
</L>
<T n="command">mbox.tc_enable</T>
</U>
</V>
|
Any number of different types of arguments can be sent, and in this case we're specifying that we want to send one of the participants of the interaction. Since we don't specify which participant, it uses the default which is the Object participant type, which is the game object that a Sim is interacting with (note that the actual game object itself isn't sent to our command since you can't "type" an actual object into the cheat command line, but rather the ID number of it). In the regular mailbox tutorial, this would be the ID of the mailbox itself, but since you're changing things so the target is a Sim it will be the game object ID of the Sim you are targeting.
In the Python code for the enable and disable commands, we specify in our argument list that we want that argument assigned to the obj_id variable
Code:
def mbox_tc_enable_command(obj_id:int, _connection=None):
|
so our Python code is receiving that ID number, but we're not using it since we didn't really care for the purposes of that tutorial.
However, you CAN do something with that number, which is to get a reference to the object itself from the object manager. We can then test the is_sim property on the object to see if the object is a Sim or not (testing that would be optional if your code can be 100% certain that it's a Sim object, but we'll assume we don't know and test).
If it is a Sim object, then it has a sim_info assigned to it, and we can then query that to get the name of the targeted Sim. Something like this...
Code:
obj = services.object_manager().get(obj_id)
if obj.is_sim:
full_name = obj.sim_info.first_name + " " + obj.sim_info.last_name
else:
full_name = "This is not a Sim object"
|
And of course, once we have an object reference, we can access a huge number of the variables and methods attached to that object. I suggest looking into the
D3OI script I wrote if you are interested in seeing just what is accessible on these objects.