A generic IDE Connector for Tabletop Simulator - using Python
- Pull files from TTS
- Push files with save and reload to TTS
- Print messages from TTS
- Print errors with links to required files and code line.
- Launch code snippet files on global or objects
- 🌟 Hot reload of a single object : way faster, without save&reload
- 🌟 Hot reload of modified objects only (WIP)
You need to :
- Checkout the git repo
- Install Python (3.8+), nodejs and yarn
- optional Create a python virtualenv
- With your virtualenv is active
cd generic-ide-tabletopsimulator
pip install -r requirements.txt
yarn install
The server part is supposed to run whenever you want to work on a TTS project that talks to TabletopSimulator.
You run the server by using (in your virtual env)
python -u server.py --output-dir=path_to_your_project/fromtts
- Be very careful with the path you put here, the server will constantly erase and reload the content from this folder with what comes from TTS.
- (Note the -u to tell python to run unbuffered and get prints immediately)
- Tip : Use a fromtts subfolder in your code source project
- Optionaly the script takes a --lib-dirs argument if you want to override where to search for requires/includes
Create an External tool item :
- In File > Settings
- In section Tools > External tools
- Create a new entry
- Name : TTS Server
- Group : Tabletop Simulator (typing something in this field will create the new group)
- Description : Tabletop simulator IDE server
- Program :
- windows : <path_to_your_virtualenv>\Scripts\python.exe
- linux/macos : <path_to_your_virtualenv>/bin/python
- Arguments:
-u <path_to_your_checkout>/generic-ide-tabletopsimulator/server.py --output-dir "<path_to_your_project>\fromtts"
- Synchronize files after exec : False
- Open console for tool output : True
- Make console active on stdout : True
- Make console active on stdout : False
- Ouput filter :
$FILE_PATH$:$LINE$:.*
In addition to that, we advise to create a shortcut for that in your toolbar since you'll have to launch it each time you start working on your project
- In File > Settings
- Appearance & Behavior > Menu & Toolbars
- Navigation bar toolbar
- Press add, and search inside External tools, Tabletop Simulator section the TTS Server.
Also if you are using Windows, the default console encoding might be wrong.
Go in File > Settings and then Editor > General > Console and make sure the default encoding is set to UTF-8
Actions are scripts that will request various things to TTS embedded server, results of these actions will be collected by the IDE server started in the previous step.
The command looks like that :
python command.py --output-dir path_to_your_project/fromtts --command pull
You'll create again an external tool as made in the server step.
This time configuration should be :
- Name : TTS Pull
- Group : Tabletop Simulator (typing something in this field will create the new group)
- Description : Tabletop simulator Pull Files
- Program :
- windows : <path_to_your_virtualenv>\Scripts\python.exe
- linux/macos : <path_to_your_virtualenv>/bin/python
- Arguments:
<path_to_your_checkout>/generic-ide-tabletopsimulator/command.py --output-dir "<path_to_your_project>\fromtts" --command pull
- Synchronize files after exec : True
- Open console for tool output : False
- Make console active on stdout : False
- Make console active on stdout : False
- Ouput filter : leave empty
For this one, we advise you to bind a keymap.
- In File > Settings
- Keymap
- find the External tool / Tabletop Simulator folder
- open it until you get the added items, and right click + add keyboard shortcut.
- If you are used to Atom plugin, just use Ctrl+Shift+L
The command looks like that :
python command.py --output-dir path_to_your_project/fromtts --command push
Same as for pull, but replace pull
with push
in the command line
This allows you to run lua files directly on TTS without having any object nor modifying objects scripts.
You can create your own snippet/scratches files and run them in the context of TTS.
In order to make a script run in the context of one particular objects :
- Copy the object GUID from TTS
- Add the following line in your lua snippet file :
-- FOR_GUID : 892585
where 892585 is the guid of the object you want to run the script for
The command looks like that :
python lua_snippet_runner.py --output-dir path_to_your_project/fromtts --file <filepath>
Same as above to create a new entry. We take benefit of the Pycharm macro to pass the file path automatically for the one open.
- Name : TTS Run snippet
- Group : Tabletop Simulator (typing something in this field will create the new group)
- Description : Tabletop simulator Run current file
- Program :
- windows : <path_to_your_virtualenv>\Scripts\python.exe
- linux/macos : <path_to_your_virtualenv>/bin/python
- Arguments:
-u <path_to_your_checkout>/generic-ide-tabletopsimulator/lua_snippet_runner.py --output-dir "<path_to_your_project>\fromtts" --file $FilePath$
- Synchronize files after exec : False
- Open console for tool output : False
- Make console active on stdout : False
- Make console active on stdout : False
- Ouput filter : leave empty
The command looks like that :
python object_patcher.py --output-dir path_to_your_project/fromtts --object <the_object_guid>
Here we advise to configure a run profile that is easier to modify.
Just configure it to run the command of manual config above.
The command looks like that :
python command.py --output-dir path_to_your_project/fromtts --command soft_push
Same as push/pull advised
We strongly advise you to have a look to :
If you are working on TTS plugin, we strongly advise you to visit :
https://tts-community.github.io/
there is a lot of useful resources in this website and also other IDE integrations if this one doesn't fit your needs :)