Replies: 3 (Who?), Viewed: 1689 times.
Test Subject
Original Poster
#1 Old 10th Sep 2015 at 7:22 PM Last edited by todoabout : 27th Sep 2015 at 10:16 PM. Reason: updated
Default Python help? Mod doesn't seem to work - SOLVED
upd. The final result
***
I'm trying to solve this issue, using mgomez's tutorial, EA's defunct 'relationship.print_score' command (from simulation\server_commands\relationship_commands.pyo.py) and my own extremely limited understanding of Python.
Here's what I've got so far:

and it doesn't seem to work. I input e.g. 'relprint Bella Goth Mortimer Goth friendship_main' in the console, nothing comes out in the cheat box.
Any help & advice will be very appreciated. I barely know where to start troubleshooting...
Advertisement
Lab Assistant
#2 Old 12th Sep 2015 at 4:32 PM
From my knowledge, the 0s can't be inside the brackets in the lines:

Code:
    if track_type is None:
        sims4.commands.CheatOutput('Invalid relationship track: {0}'.format(track_name), _connection)
        return False
    score = info1.relationship_tracker.get_relationship_score(info2.id, track_type)
    sims4.commands.CheatOutput('Relationship Score: {0}'.format(score), _connection)
    return True


Also, change the def property name, it makes sure it doesn't conflict with the original.

Code:
def print_rltnship_score(first_name1='', last_name1='', first_name2='', last_name2='', track_type:TunableInstanceParam(sims4.resources.Types.STATISTIC)=None, _connection=None):


Lastly, change the output line style. That style usually doesn't work. Here is a finished revamp:



Maybe @scumbumbo can help as well?

Simalary Studios

Contact Me
Send me a PM, or Visit my Simblr for questions, comments, requests, or just a quick "hi" - I don't bite. If you need to contact me for anything, do so.
Requests
Valid Requests: CAS recolors, Build/Buy Mode recolors, houses or rooms, and simple script mods.
Deceased
#3 Old 15th Sep 2015 at 7:02 AM
A couple of problems here. You are getting the track_type correctly from the command line (using track_type:TunableInstanceParam...), but:
  • The TunableInstanceParam type isn't imported
  • Later in the code you're trying to get the track_type again using the track_name, since trackc_name has never been initialized that call always fails. But it's not needed since we already got the track_type directly off the command line.
  • You don't need the RelationshipCommandTuning class in this (unless you were planning on expanding it to use something from that, but in that case you could just import a reference to it).
I use the output method which simalary suggested above as well, I find it works most reliably; however, you can use the {0} parameter substitution no problem with that. That's built into the string format method. There are other uses for that notation, but it's most useful when you have to repeat an argument in the string so you can just specify the argument once but print it twice by reusing the positional parameter notation.

Also, the function name won't conflict with the EA default one as your new command will be in an entirely separate module. But it's probably best to change the name anyway as simalary suggested to be something unique. Uniqueness NEVER hurts!

Finally, you should probably verify that the get_sim_info_by_name calls succeeded by checking to insure that neither info1 nor info2 are None and print a nice friendly error if that occurs.
Test Subject
Original Poster
#4 Old 16th Sep 2015 at 11:41 AM Last edited by todoabout : 17th Sep 2015 at 5:33 AM. Reason: figured it out
Thank you so much! It works now! Seems like the main trouble was indeed in Output.



I still wonder, though: is there a way to address track_type from another variable, not directly from console input? The method of EA's disabled cheat [track_type = services.get_instance_manager(sims4.resources.Types.STATISTIC).get(track_name)] doesn't seem to be working; unless I'm missing something. Should I import anything else for that method to work? UPD: Yep, get_tunable_instance was missing.

Thank you very much, simalary44 and scumbumbo!
Back to top