|
Post by Basemental on Nov 21, 2017 10:49:41 GMT -5
Hey guys, I am scouring through the XML files to find an example of this, but without any luck.
Do any of you know if it is possible to use XML in an interaction to force the actor to be the selected/active Sim?
I have a script that directly affects the active Sim, but if another family member is selected while the script command goes off it does not affect the actor that the interaction is tied to.
|
|
|
Post by FallenNights on Nov 21, 2017 11:37:21 GMT -5
what I'm getting from your post is that you created an interaction, and now anyone can perform it and you want only one certain sim to do it???
Make the interaction disabled for random, that's the only way you're gonna get that from happening.
But if you tied the interaction to a single sim (Is that even possible lmao) it's obviously gonna bug out like hell and not function bc the Sim data is held within your save/user data.
|
|
|
Post by Basemental on Nov 21, 2017 11:59:44 GMT -5
what I'm getting from your post is that you created an interaction, and now anyone can perform it and you want only one certain sim to do it??? Make the interaction disabled for random, that's the only way you're gonna get that from happening. But if you tied the interaction to a single sim (Is that even possible lmao) it's obviously gonna bug out like hell and not function bc the Sim data is held within your save/user data. Then you definitely misunderstood. Let me try to explain it better. Here is the sequence of events: 1. An NPC is spawned through a situation tuning. 2. Our playable Sim has a broadcaster that makes the NPC go over to him and perform a social interaction 3. The continuation to #2 is a new interaction that our playable Sim performs automatically. In this last interaction there is a do_command line that calls upon a script that affects the active Sim. If I have another member of the household selected and active at that time, the script will affect the other member of the household. That is why I am wondering if it is possible to add a line in the XML in this last interaction to briefly select the actor of the interaction to be the active Sim instead.
|
|
|
Post by brujah on Nov 21, 2017 19:49:17 GMT -5
Check out the voodoo doll
|
|
|
Post by Basemental on Nov 22, 2017 2:22:56 GMT -5
Thanks brujah!
|
|
|
Post by Basemental on Nov 22, 2017 7:02:50 GMT -5
Check out the voodoo doll I have had a look at it now. Not quite sure where that replicates the functionality that I am looking for, really. Might be me that is missing something...
|
|
|
Post by brujah on Nov 22, 2017 18:19:58 GMT -5
I mentioned this because it "binds" to a specific sim. Take a look at the success outcome of voodoodoll_bind (14528), this is where it stores the picked sim.
|
|
|
Post by Basemental on Nov 22, 2017 18:27:33 GMT -5
Hmm.. So if I store the actor and perhaps change the script to something like Sim = client.stored_sim instead of Sim = client.active_sim ? I know this is not really the place for python related questions, but I feel I am kind of fumbling a bit in the dark here
|
|
|
Post by andrew on Nov 22, 2017 18:38:19 GMT -5
There are also some examples of do_command that pass the actor/target from the interaction tuning to the python command. Take a look at PlanOutfit_Mirror.
<V t="do_command"> <U n="do_command"> <L n="arguments"> <V t="participant"> <U n="participant"> <E n="argument">Actor</E> </U> </V> </L> <T n="command">sims.modify_in_cas_with_householdId</T> </U> </V>
@sims4.commands.Command('sims.modify_in_cas_with_householdId', command_type=sims4.commands.CommandType.Live, command_restrictions=CommandRestrictionFlags.RESTRICT_SAVE_UNLOCKED) def modify_in_cas_with_household_id(opt_sim:OptionalTargetParam=None, _connection=None): sim = get_optional_target(opt_sim, _connection) ...
So instead of using the active sim in the python, you get the Actor from the interaction tuning that called the command via the opt_sim parameter.
|
|
|
Post by Basemental on Nov 22, 2017 18:41:26 GMT -5
Thanks a trillion andrew!
I tried out the participant argument previously, but I did not know enough about how to do the Python side of it. This helps immensely!
|
|
|
Post by Basemental on Nov 22, 2017 20:42:51 GMT -5
I must say I am still struggling a bit to get this to work. I have tried several versions of this now, but to no go. Do you see any major flaw in this code?
import services import sims4.commands import build_buy from protocolbuffers import Consts_pb2
@sims4.commands.Command('bm_clean_inventory', command_type=sims4.commands.CommandType.Live) def bmcleaninventory(opt_sim:OptionalTargetParam=None, _connection=None): output = sims4.commands.CheatOutput(_connection) client = services.client_manager().get(_connection) sim = get_optional_target(opt_sim, _connection) info = sim.sim_info sim.inventory_component.purge_inventory() output("Inventory clean for {} {} with the value of {}".format(info.first_name, info.last_name, value))
|
|
|
Post by andrew on Nov 23, 2017 10:21:39 GMT -5
You are missing this:
from server_commands.argument_helpers import OptionalTargetParam, get_optional_target
If you are going to be doing a lot in python, I'd suggest getting a python editor rather than a regular text editor and linking your game scripts to it. It will quickly show issues like this.
|
|
|
Post by Basemental on Nov 23, 2017 16:37:42 GMT -5
Thanks once again, andrew. It works flawlessly now. And thanks for the tip regarding getting a proper python editor as well, will definitely look into that.
|
|