About This File
This mod improves upon the Lua console in Don't Starve Together. It was started as a collaboration between this author and @squeek.
- Extended and configurable command history. Each history line is editable (that is, scrolling past a previous line will save any modifications to it), and the command history is preserved saved between game sessions.
- Console log is scrollable
- Console keeps focus when you'd expect it to
- Console doesn't close after each line entered
- Added basic CTRL+A select all support (hitting backspace after CTRL+A will delete all the text)
- Added support for multi-line inputs (useful for e.g. function definitions and for loops)
- Many general useability improvements, bugs that have been fixed, and small but useful tweaks
- Better, more informative and less cluttered error handling
- With the "Hide on close" option, the console log gets hidden whenever the console closes
- Console log and console input text is slightly smaller
- Console log has word wrap enabled
- Modified the c_select command so that it will set the debug entity to whatever is under the mouse if it is called with no parameter (default c_select requires a parameter)
- With the "Variable autoprint" option, the console will automatically print back the value of any variable you enter (for example, if you do "test = 1" and then just "test" it will print back "1")
- If you use "return" it will print back the value that is returned (for example, "return ThePlayer" would print something like "100009 - wilson"); basically return can be used as somewhat of an alias of print. This supports multiple return values, such as "return 1, 2, 3".
- The console prints back any command you give it prefixed with "> " if on local execution and "% " if on remote execution.
- The console has a transparent black background
- With the "Command autoexec" option, the console will auto-execute console commands (example: "c_teleport" would translate to "return c_teleport()")
- If the first character of an input line is '=', then it will be translated to 'return ' (example: "=test" becomes "return test").
As illustrated in the screenshots, console commands run in their own environment, but with full access to the global environment, which also remains accessible in the tables _G and GLOBAL (which are aliases of each other).
This means global variables can be freely used, but new variables aren't exported to the global environment unless this is done explicitly via _G or GLOBAL. When accessing variables, those in the console environment take precedence over globals. Combining these two properties, the console environment becomes its own sandbox for code execution, with variables set not running the risk of clashing with global variables and inadvertently affecting the game state, but still retaining full access to these global variables.
In addition, every extension this mod does to standard commands and functions is done in this private environment, also preventing clashes with the game and other mods. This structure encourages greater use of the console as a place in which to write actual code to diagnose or manipulate the game state.
Dedicated server support
This mod has essentially two elements: extending the console UI and extending the processing and execution of Lua code. The former makes sense only in a client, and requires only the client to cooperate, and this is why this is a client mod. However, it may still be enabled in servers, including dedicated servers (though force enabling from modsettings.lua may be required). If that is done, the extensions to the execution of Lua code (including syntax extensions and all that was discussed in the "Technical features" section) will be applied to the server, both for code transmitted to it via a remote console by an admin user and for code read by a dedicated server from its terminal input.
What's New in Version 2.0.0 See changelog
Made the modicon show in the forum page