A downloadable mod

Remote REPL is a PlumbBuddy UI Bridge mod for The Sims 4 which allows you to execute ad-hoc Python code in the game's environment while it's running, which can be useful for experimentation and debugging purposes.

How to Use

Have PlumbBuddy 1.5 or later

This is available for Windows and macOS for free from the PlumbBuddy website.

Enable Runtime Mod Integration in PlumbBuddy

This should be turned on by default, but in case it isn't...

  1. open PlumbBuddy's menu
  2. select Settings
  3. on the General tab, switch on Enable runtime mod integration

Download and Install this mod

Probably should go with the latest release shown on this page for this, but if you're particularly adventurous, you can download a GitHub Actions workflow artifact for any commit you want. Each time a commit make it to the master branch in this repo, GitHub will build a complete, production-ready version of the .ts4script file for use by the game.

Use the Cheat Console

The Cheat Console command to get the REPL to appear in PlumbBuddy is:

remote_repl.launch 

PlumbBuddy will grab foreground app focus to ask your permission to launch the REPL's UI. Give consent and you're off to the races.

Python interpretation

The REPL is capable of both evaluation and execution, which behave slightly differently.

Implementation note: For those to whom those seem familiar, yes, the REPL is using eval and exec, respectively.

The REPL always interprets your Python code starting from the context of its own module. This means that you need to import other modules to interact with the structures and objects of your own mod (or of the game).

The REPL's effects are "as good as" if it were a compiled script mod performing the actions you tell it to perform. If you inject into EA code or alter tuning... whatever... that will stick around until the game is closed, even if you close the REPL's bridged UI.

Evaluation

This is just a single Python expression. As long as it's valid, the REPL will give you the result of evaluating your expression in the game. If you fat-fingered something, the REPL will give you the message for the error it caught while trying to evaluate the expression. Also, importantly: only one Python expression is allowed in this mode.

Execution

This can be... whatever you want. You could stuff an entire script mod into a single execution. That's probably a bad idea, but you could. The real purpose here is to give you the ability to provide complex logic, up to and including whole functions or even classes, if you need them.

Because execution doesn't inherently have a result, but you might want to have results, two magical variables are put in the local scope of each of your executions by the REPL:

  • __EXEC_RESULTS_LIST__: a list to which you can do whatever you like, but most likely append
  • __EXEC_RESULTS_DICT__: a dictionary, the key/value pairs of which are... entirely up to you

When your execution finishes, the contents of both of the above will be transmitted to the REPL's interface and displayed along with the status of the execution itself (i.e. any error information if one was thrown).

That's about it. Have fun being a script mod with a life all its own, because that's what you are when you're using the REPL.

Published 7 days ago
StatusReleased
CategoryGame mod
AuthorCodeBleu

Download

Download
CodeBleu-TS4_Remote_REPL.ts4script 11 MB

Leave a comment

Log in with itch.io to leave a comment.