greybel-vsThis toolkit provides essential tools for developing in GreyScript, the scripting language used in Grey Hack. The extension offers syntax highlighting, code execution, bundling, minification, and more to streamline GreyScript development in VSCode. Prefer a different editor? The GreyScript Language Server is also available and compatible with IDEs like Sublime Text, IntelliJ, nvim and more. Examples for setting up these editors are included in the repository. LinksProject Resources
Projects Using Greybel
Grey Hack Tools
Community
UsageThis extension automatically detects Commands available (
You can also access these commands through the context menu for quick right-click access: Tip: Make sure to configure settings to customize Greybel to your preferences. Settings
Features
TransformTranspiles your code into a specific format. Be sure to select your desired output in the settings. By default, the "Default" build type is selected. Output modesThere are three different modes: "Default", "Uglify", and "Beautify". The output will vary depending on the mode selected.
Imports (Transform)Important: Unlike the build function, transforms will ignore any #include, #import, or import_code lines. Use the build functionality instead. Environment (Transform)Greybel allows you to inject environment variables during transformation. These can be configured in the extension settings. BuildBuilding transforms and bundles your scripts in a way that makes them easy to import into Grey Hack. As mentioned in the transform section, building also provides three different output modes: "Default", "Uglify", and "Beautify". For more details, check out the output-modes section. Auto create files in-gameYou can automatically create transpiled files in the game by enabling the "create-ingame" option. Additionally, you can choose between two agents. Depending on the selected agent, there are certain prerequisites to meet and behaviors to consider. Generally it is recommended to use message-hook if possible. HeadlessWhen using headless mode, you connect to the game without the native game client. Depending on your selected mode, either By default, One important requirement is that a Steam account and password must be provided. The refresh token will be cached, so you won’t need to provide credentials continuously. You can clear the refresh token at any time using the "Clear secrets" command. Note: This agent may log you out of Grey Hack since the game only allows one active session at a time. Message HookThe message-hook agent allows you to send messages to the game server through the game client. To use this feature, you need to first install BepInEx and then the plugin. Below, you can find installation instructions for both versions of BepInEx. BepInEx 5.x.x
BepInEx 6.x.x
With all that done you can now start the game and start either a single-player or multiplayer session. You'll be now able to sync files with the game without getting disconnected. Also, keep in mind that if you use BepInEx 6.x.x you'll use bleeding edge meaning that it won't be as stable as BepInEx 5.x.x leading to potential crashes. If you suffer too many crashes with 6.x.x may try out version 5.x.x! Additionally, you won't need to provide any Steam credentials nor do you need to select a mode. Note: For this agent to work you have to have Grey Hack running. Imports on buildingScripting in Grey Hack can be challenging, especially when you have files that import each other or are working on a larger project where you have to copy-paste each file manually into the game every time. Greybel aims to reduce this hassle, allowing you to spend more time coding and playing rather than copy-pasting files repeatedly. Dependency Management (Transpiler)Greybel enables you to split your code into different files, which helps maintain readability and also makes your code reusable. It is recommended to use include and import for small or medium-sized projects. For larger projects, import_code should be used instead, as the transpiler will bundle your files in a way that maximizes the use of import_code in the game, helping to avoid exceeding the maximum character limit of 160,000. Cyclic dependencies will also be detected. If a cyclic dependency is found, an error will be thrown, indicating which file is causing it. A step-by-step guide is available here. ImportUsed to import exported namespaces from a file. Features:
You can check out the example code for a better understanding of how to use this feature. IncludeUsed to import the content of a file. Features:
You can review the example code for more details. import_codeUsed to import code from a file. Features:
Here’s some example code. When the installer option is enabled, Greybel will create one or more installer files depending on the size of your project. These installer files will contain all the code files and logic to create the files in the game. Essentially, you just need to copy and paste the installer code into the game, then compile and execute it. Using the By setting up the in-game directory in the settings, you can define where you want the files to be imported in the game. By default, Additionally, nested SyntaxAny valid MiniScript or GreyScript syntax is supported. Additionally, some minor syntax sugar is added to these languages. If you use these features, keep in mind to transpile your code first. Using these is completely optional. No trailing comma is required in maps or lists
Math - shorthand
Bitwise - shorthand
Block comment
Filename expression
The filename expression will be replaced with the string literal containing the name of the file before transpiling. This can be useful for debugging. Line expression
The line expression will be replaced with the number literal containing the line of the expression before transpiling. This can be useful for debugging. Envar expression
The envar expression will be replaced with the value of the provided environment variable. Make sure you define an environment variable for the provided namespace. If no value is found, it will instead use Inject expression
The inject expression will be replaced with the content of whatever file exists at the provided path. If the file does not exist, it will be replaced with UploadIf you're not interested in the build functionality or need to upload many files into the game, you can use the "Import files into game" command. This will behave similarly to the create-in-game build feature, but without the building step. This feature will also use the transpiler's "Ingame directory" setting as the in-game destination. IMPORTANT: Please read about the two available agent options headless and message-hook. It is recommended to use message-hook but it requires to setup BepInEx. InterpreterGreybel comes with its own GreyScript interpreter, allowing you to test and debug your code outside of the game. This is partly due to the test environment that gets generated on the fly, attempting to emulate the game's API. Dependency Management (Interpreter)Dependencies are dynamically loaded into the execution without any limitations. Cyclic dependencies are also supported. Environment Variables (Interpreter)Greybel supports the injection of environment variables into the interpreter. These environment variables can be configured in the extension settings. Local EnvironmentGreybel GreyHack Intrinsics will automatically generate a local environment. It will also generate other computers, networks, filesystems, etc., on the fly. By default, generation is based on a seed called The local computer setup is hardcoded. The admin credentials are Examples:
Greyscript API supportThe intrinsics to support the Greyscript API are provided by Greybel Intrinsics and Greybel GreyHack Intrinsics. Keep in mind that not all of these functions are completely mocked. Also, only API that is available in the stable build will be implemented. Not yet supported:
TextMesh Pro Rich Text SupportTextMesh Pro Rich Text is partially supported. Note: For the pseudo-terminal, Greybel will attempt to transform TextMesh Pro Rich-Text tags into ANSI codes. Due to the nature of TextMesh Pro Rich-Text tags, some formatting may be lost. If you're looking for a proper preview of your output in Grey Hack, please check out the Preview Output feature. DebuggerThe debugger allows you to set breakpoints, run code in a breakpoint context, and jump to the next line of execution. It's helpful for debugging your code.
A REPL is also available while executing the script or having an active breakpoint. Preview OutputThis feature creates a web view that renders actual TextMesh Pro Rich-Text tags within VSCode. Its main purpose is to emulate the actual output of the game, making it useful for drawing images or creating fancy prompts. API BrowserThe API Browser for GreyScript brings the GreyScript API Documentation directly into Visual Studio Code. Comment DocsProvide signatures for your functions to show better hover tooltips. Additionally, the provided return value will be recognized by the implemented type system, resulting in context-sensitive auto-complete suggestions.
There is also the possibility of custom types. Here an example:
ShareShares your code via editor.greyscript.org. The related link will be copied to your clipboard. SnippetsProvides a list of available GreyHack snippets, such as Goto ErrorJumps to the next existing syntax error. Supporting ProvidersThis extension includes several IntelliSense providers to enhance your coding experience with GreyScript:
CopyrightSloth icons created by Freepik - Flaticon Todo
ContactFor questions, feature requests, or support, feel free to join the dedicated Greybel Discord. |