A Console module to add textual commands to your Tabletop Simulator mods, generally for debugging.
console.ttslua provides the basics needed to add commands to your games, and
console++.ttslua is an example module which adds a full debug system for accessing and monitoring your program's structure.
Console module, allows you to add commands to your Tabletop Simulator mods. Commands are prefixed by a
you can change this to w/e you want). You can also add validation functions to check the messages
players are sending.
Built-in console commands:
help/?Lists available commands or provides information on specified command
infoDisplays help on all available commands. Alias for
aliasCreates an alias of another command with preset parameters
clsClear console text
=Evaluates the specified expression
cmdEnter command mode: no longer required to type
exitExit command mode
>Type this on its own to toggle command mode
Main functions it gives you access to:
console.add_validation_functionAdds a validation function all chat will be checked against
console.add_player_commandAdds a command any player can use
console.add_admin_commandAdds a command only admins can use
Example module demonstrating how to use the base module, though this is a useful debug tool in its own right and will become more feature-rich over time.
The runtime envirorment is treated like a filesystem, allowing you to view and access global variables. Included commands:
ls/dirList tables, variables, objects and functions at your current location or location specfied.
cdChange the table you are currently located in.
cd..Change the table you are currently located in to its parent.
addAdd a variable or table.
setSet the variable specified to the value specified.
tgl/toggleToggle the boolean variable specified.
rm/delRemove the variable specified.
callCall the function specified. You may then store the result with
~Display result of most recent function call or expression evaluation.
execExecute a series of commands.
watchWatch a variable or object; display it if it changes.
shoutBroadcast a message to all players
All commands in console++ except
shout are locked to admin players only.
Also includes simple swear-word blocking message validation.
If you are using Atom with the TTS plug-in then put
console++.ttslua in folder
<your user folder>/Documents/Tabletop Simulator/Console, and then in your code you can simply write
#include Console/console or
#include Console/console++ (be sure to enable the
#include feature in the package settings).
If you're using a different editor then you can simply paste the code for
console.ttslua into your own. If you want to use
console++.ttslua then paste it below that, and remove the
#include console it starts with.