March 15th - It's time for our Friday Highlights! You can check them out here!
Forum Announcement, Click Here to Read More From EA_Cade.

How/where would I find a particular console command in the game files?

«1
pboxpbox Posts: 630 Member
edited March 5 in Nominated Threads
I was attempting to try some very basic scripting, namely making shortcuts for some of those RSI-inducing in-game commands. I was thinking this should work along the lines of defining a new command named "mo" and having that execute the actual bb.moveobjects command, for example.

But now I'm already stuck because all the examples I looked at are using commands that I can find in the game scripts (like set_clock_speed in clock.pyo.py), however that moveobjects one I can not find. =/ Same problem with the unlocking stuff ones.

Am I making this too complicated? Is there some other way of defining aliases? The way I understood it, one would have to do that when defining the command in Python, but maybe I'm misunderstanding ..

Also, does the "plunking loose files in /unpackedmod" thing still work?
Stuff for TS2 · TS3 · TS4
Post edited by EA_Cade on

Comments

  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    Not all commands are defined in Python. You could define your own command and then call
    sims4.commands.client_cheat(...)
    
  • pboxpbox Posts: 630 Member
    Oh *lightbulb* .. you mean that is how to tell the game "please do whatever you'd do if someone entered (...) in the cheat console"?

    Thanks, I'll try that =)
    Stuff for TS2 · TS3 · TS4
  • pboxpbox Posts: 630 Member
    I have a feeling you aren't supporting loose .py files any more .. could that be? Because I cannot even get a "Hello World" thing to work in .py form that I literally copied and pasted from mods I am currently using in my game =/ (the creator/s had put the .py in the zips along with the pyo)

    Here it says "Loose .py files are supported out of the "Mods" folder" - I took this (in the context of hot loading scripts) to mean they would always be loaded when the game starts, just not *re*loaded. I tried both from the Mods folder and /Mods/unpackedmod, the unpackedmod folder is listed in my resource.cfg as well .. but still, all I get is "Unable to execute command".

    I'd actually prefer not having to compile this .. would make it a lot easier to add on to it every now and then.

    It could just as well be that I'm still making some stupid mistake in my code (I have no previous experience with Python) .. not sure.
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    I just tried the example Maslow mod as a loose .py file, and it works for me. Make sure the "Script Mods" option is checked. If it's unchecked, you'll have to restart the game.

    Even as a loose file, the mod should show up the in the list... does it for you?
  • pboxpbox Posts: 630 Member
    Yes I have scripts enabled.

    You mean the list in Game Options > Other > View Custom Content? I don't see anything there that could be the .py in question .. but to me it looks like it lists under "Script Mods" every .zip that it finds, not script mods per se (I have two zips listed there that do not contain any scripts, I just forgot to remove them). Also I have two empty lines in the nonscript department. Hm. What would it normally list there, the file name of the .py?
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    pbox wrote: »
    Yes I have scripts enabled.

    You mean the list in Game Options > Other > View Custom Content? I don't see anything there that could be the .py in question .. but to me it looks like it lists under "Script Mods" every .zip that it finds, not script mods per se (I have two zips listed there that do not contain any scripts, I just forgot to remove them). Also I have two empty lines in the nonscript department. Hm. What would it normally list there, the file name of the .py?

    Correct. If you were to plop maslow.py in there, it should say maslow.
  • pboxpbox Posts: 630 Member
    It doesn't =(

    Exhibit A:

    63136_141220233843modsprompt.jpg


    Exhibit B:

    63135_141220233832modsdir.jpg


    ???


    Script mods are enabled, all those zipped ones are working fine.
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    At this point, I'm not sure. Have you tried removing all other mods and just having maslow.py in there?
  • pboxpbox Posts: 630 Member
    edited December 2014
    Still no dice, the Mods panel is entirely empty then.

    Weird.

    I will, for science, try going online, see whether that makes a difference .. I dunno whether this could be similar with CC not being recognised in the Library unless going online-but-not-really etc pp .. ETA, Nope.


    ETA, do I perhaps need to tell the game something about .py files in resource.cfg?
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    Actually, instead of having the file be under Mods, make sure the path is The Sims 4\Mods\maslow\Scripts\maslow.py

    See if that works.
  • pboxpbox Posts: 630 Member
    edited December 2014
    OK, I'll try that .. along the same lines, should /Mods/shortcuts/Scripts/shortcuts.py also work for my thing, then? I guess I'll see what happens ..


    Oh, that looks good =) both are listed in the Mods dialog now.

    ETA, so, maslow is now actually working; mine is only working in the sense of being recognised by the game.
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    Glad it worked!
  • pboxpbox Posts: 630 Member
    63137_141221002844yay.jpg
    Stuff for TS2 · TS3 · TS4
  • pboxpbox Posts: 630 Member
    63138_141221015036huzzah.jpg

    And now I also got the actual work part of the workingness to work =D

    (Took me a while to realise just how nitpicky Python is about spaces and tabs and so on)


    The code, for other interested parties:
    import sims4.commands
    
    @sims4.commands.Command('m', command_type=sims4.commands.CommandType.Live)
    def moveobj(_connection=None):
    	command = 'bb.moveobjects'
    	sims4.commands.client_cheat(command, _connection)
    

    Rinse and repeat for all other cheats you may want to de-verbosify ..
    Stuff for TS2 · TS3 · TS4
  • pboxpbox Posts: 630 Member
    edited December 2014
    With this part I'm having a little issue:
    @sims4.commands.Command('h', command_type=sims4.commands.CommandType.Live)
    def headline(enable:bool=None, _connection=None):
    
    	if enable is not None:
    		if enable:
    			command = 'headlineeffects on'
    			sims4.commands.client_cheat(command, _connection)
    		else:
    			command = 'headlineeffects off'	
    			sims4.commands.client_cheat(command, _connection)
    	else:
    		output("You need to turn this on or off with 't', 'true', 'on', '1', 'yes', 'y', 'enable' or 'f', 'false', 'off', '0', 'no', 'n', 'disable'")
    

    The actual commands are working as expected (like with "h 1" or "h off" or whatever), but when I only type "h" I don't get the expected output .. and I don't understand why not. (The reason I want that is to prevent myself from forgetting that this is not a toggle)

    ?

    lastexception.txt is not complaining about me (as it did yesterday, about my untidy whitespaces).

    (I also have a feeling that the inner if is probably unnecessary as I can probably pass the bool directly somehow, I only don't want to change too many things at once)
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    The system requires you to enter a valid value for 'enable', i.e. a value that can be converted to a boolean. I believe 'None' is not being converted, and therefore the command is not being issued at all.
  • pboxpbox Posts: 630 Member
    edited December 2014
    No the enable/disable thing worked fine -- I found what my problem was; I just didn't tell it what the output would be. I mean where to output it TO.

    This works now:
    @sims4.commands.Command('h', command_type=sims4.commands.CommandType.Live)
    def headline(enable:bool=None, _connection=None):
    	output = sims4.commands.CheatOutput(_connection)
    	if enable is not None:
    		if enable:
    			command = 'headlineeffects on'
    			sims4.commands.client_cheat(command, _connection)
    		else:
    			command = 'headlineeffects off'	
    			sims4.commands.client_cheat(command, _connection)
    	else:
    		output("You need to turn this on or off with 't', 'true', 'on', '1', 'yes', 'y', 'enable' or 'f', 'false', 'off', '0', 'no', 'n', 'disable'")
    

    \o/

    (You are already doing the boolean conversion for me =) )



    ETA: oh but is there a way to give it multiple aliases for the same command? Like, can I pass it a list instead of the string somehow?
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    Ah. Weird that you didn't get anything in lastException.txt
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    pbox wrote: »
    ETA: oh but is there a way to give it multiple aliases for the same command? Like, can I pass it a list instead of the string somehow?

    There is. Check the definition for 'Command'.

    I think it's something like
    @sims4.commands.Command('name1', 'name2', ...)
    
  • pboxpbox Posts: 630 Member
    Well, I didn't get anything that mentioned the name of my .py .. it does talk about "xml.parsers.expat.ExpatError: not well-formed (invalid token)" but I'm also testing for stuff like "h 5" (and I'm also trying to get other things to work) so it's not very surprising that it finds *something* to complain about =D.
    Stuff for TS2 · TS3 · TS4
  • pboxpbox Posts: 630 Member
    edited December 2014
    @sims4.commands.Command('name1', 'name2', ...)
    

    That was exactly what I tried =D but that did not work, the result was "invalid command" or "unable to" or something along those lines (in the console output) .. I didn't take a screenshot of the exact wording, but I can try again and post one.

    My code was
    @sims4.commands.Command('t', 'd', 'debug', command_type=sims4.commands.CommandType.Live)
    def testing(enable:bool=None, _connection=None):
    	output = sims4.commands.CheatOutput(_connection)
    	if enable is not None:
    		if enable:
    			command = 'testingcheats on'
    			sims4.commands.client_cheat(command, _connection)
    		else:
    			command = 'testingcheats off'	
    			sims4.commands.client_cheat(command, _connection)
    	else:
    		output("You need to turn this on or off with 't', 'true', 'on', '1', 'yes', 'y', 'enable' or 'f', 'false', 'off', '0', 'no', 'n', 'disable'")
    

    I was wondering whether the aliases perhaps need to be in an array or something?
    Stuff for TS2 · TS3 · TS4
  • pboxpbox Posts: 630 Member
    edited December 2014
    So these are the replies I get:

    63140_141221135535output.jpg

    What I entered was, in order:

    testingcheats on // to verify this is actually the correct command
    testingcheats off // to verify this is actually the correct command
    t // works as expected: outputs the else option, telling me about explicit en/disabling
    t 1 // tries to pass the correct command apparently, but .. fails?
    t on // tries to pass the correct command apparently, but .. fails?

    same with t true, t 0 etc .. d and debug yield no resonse at all.

    Weird becuase this is the exact same code as with headlineeffects, and it is working when I only say
    @sims4.commands.Command('t', command_type=sims4.commands.CommandType.Live)
    

    in the first line .. so the problem is the aliases, I take it.
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    I don't have the code nor the game itself with me right now, and I won't until January, so I can't try this out myself. There are a few shipped commands that use aliases... I would try finding some of those and see if/how they work.

    Also, try to prepend a | to the command when entering it in the cheat window and see if that works.
  • pboxpbox Posts: 630 Member
    Okay. Thank you anyway! (Particularly as this sounds like you're not even actually working right now .. your help is much appreciated! =)
    Stuff for TS2 · TS3 · TS4
  • SimGuruEugiSimGuruEugi Posts: 503 SimGuru
    My pleasure!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file
Return to top