Toolkit for GreyScript which is a scripting language used in Grey Hack. This extension includes highlighting, code execution, bundling and minifying among other features.
If you're not a fan of VSCode you can also use the GreyScript language server.
- Latest changes: Changelog
- Projects using Greybel: viper-3.0
- Demo Projects: Minesweeper, JSON, TEdit
- CLI: greybel-js
- GreyScript API: GreyScript Documentation
- Grey Hack Image Transformer: gh-image-transformer
- Grey Hack Website Image Generator: gh-website-image-generator
- Discord: dedicated Greybel Discord
Automatically detects .gs
, .src
and .ms
files.
Commands available (CTRL+SHIFT+P
):
Greybel: Build
- infoGreybel: Share
- infoGreybel: Refresh
- infoGreybel: API
- infoGreybel: Snippets
- infoGreybel: Preview output
- info
You can also access most of the commands via the context menu:
Do not forget to set up Greybel to your needs.
- Autocomplete: Activate/Deactivate
- Create in-game
- Active: Activate/Deactivate
- Agent: headless, message-hook
- Mode: local, public
- Steam User: Steam username
- Auto Compile: Auto compile and delete source files
- Diagnostic: Activate/Deactivate
- Hoverdocs: Activate/Deactivate
- Interpreter
- Default Args: Default call arguments
- Environment Variables: JSON which can be used to define ENVs
- Hide Unsupported Text Mesh Pro Rich Text Tags: Hides none supported rich tags in pseudo-terminal
- Seed: Seed is used to generate the testing environment
- Silence Error Popups: Silences any error popups that might show up due to execution failure
- Transpiler
- Build Type: Default, Uglify, Beautify
- Literals optimizations: Activate/Deactivate
- Namespaces optimizations: Activate/Deactivate
- Environment Variables: JSON which can be used to define ENVs
- Excluded Namespaces: List which defines namespaces which should not be optimized
- Ingame directory: Destination folder which should be used in the game
- Installer
- Active: Activate/Deactivate
- Auto Compile: Adds boilerplate code to the installer which enables the script to delete itself after execution
- Max chars: Define the amount characters by which the installer should be split
- Obfuscation: Enables the transpiler to use special characters for minification of namespaces
- Syntax Highlighting
- Transform
- Build
- Upload
- Interpreter
- Debugger
- API Browser
- Comment Docs
- Snippets
- Share
- Goto Error
- Preview output
- Providers
Transpiles your code into a certain format. Remember to select your desired output in the settings. The build type "Default" is selected from the start.
There are three different modes "Default", "Uglify" and "Beautify". Depending on which you select the output will be different.
As the name already says "Default" will not have any special behavior such as optimization or formatting. If in doubt this format is probably the best allrounder.
"Uglify" will not only minify your code but also do literals and namespace optimization. Both of the features can be turned off as well since certain code may require namespace optimization to be turned off since namespaces may need to remain exactly named as they are since the code depends on it. Alternatively, you can also exclude namespaces from optimization.
"Beautify" is the complete opposite of "Uglify" and will instead try to format your code in a way to improve readability. As of right now, there is currently no customizability available which may restrict its use case.
Important: Unlike building transforms will ignore any #include, #import or import_code line. Use the build functionality instead.
Greybel enables you to inject environment variables when transforming. These environment variables can be configured in the extension settings.
Building will transform and bundle your scripts in a way that makes it easy to import into the Grey Hack. Just as mentioned in the transform section building provides three different output modes as well. These output modes are "Default", "Uglify" and "Beautify". If you want to know more about them please take a look at the output-modes section.
It is possible to automatically create transpiled files in the game. This can be activated by enabling the create-ingame option. Additionally, you can choose between two agents. Depending on the agent there are certain prerequisites to fulfill or behaviors to watch out for.
When you are using headless you are essentially connecting to the game without using the actual native game client. Depending on which mode you selected, either local
or public
the agent will import the files into either singleplayer or multiplayer.
By default local
is selected. Keep in mind that the game needs to have a single-player session running for local
to work. For public
there is no need to have the game client running.
A minor caveat is that a Steam account and password need to be provided. The refresh token will be cached so no continued providing of credentials is required. You can delete the refresh token at any time by using the "Clear secrets" command.
Note: This agent will potentially log you out of Grey Hack since Grey Hack only allows one active game session.
The message-hook agent will essentially send messages to the game server through the game client. For that to work you'll have to install BepInEx first and then the plugin second. You can find a description for both versions of BepInEx below.
- Download + Install BepInEx version 5.x.x (Installation guide)
- Download GreyHackMessageHook5.dll (Latest version: 0.5)
- Put GreyHackMessageHook5.dll into the plugins folder of BepInEx
- modify the Steam launch path to
"/path/to/Steam/steamapps/common/Grey Hack/run_bepinex.sh" %command%
(ONLY FOR NONE WINDOWS USERS)
- Download + Install BepInEx version 6.0.0-pre.1 UnityMono (Installation guide)
- Download GreyHackMessageHook.dll (Latest version: 0.5)
- Put GreyHackMessageHook.dll into the plugins folder of BepInEx
- modify the Steam launch path to
"/path/to/Steam/steamapps/common/Grey Hack/run_bepinex.sh" %command%
(ONLY FOR NONE WINDOWS USERS)
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.
Scripting in Grey Hack can be hell. Especially when you have files that import each other or any kind of bigger project where you have to copy-paste each file by hand into the game every time. Greybel tries to aid you so you spend less time copy-pasting and more time coding and playing.
Greybel enables you to split your code into different files which is useful to keep readability and also to make reusable code.
It is recommended to use include and import for small or medium-sized projects.
For big projects, import_code should be used instead since the transpiler will bundle your files in a way that makes full use of the import_code capabilities in the game to avoid exceeding the maximum character limit of 160.000.
Cyclic dependencies will be detected as well. In case there is one an error will be thrown indicating which file is causing it.
A step by step guide is available here as well.
Used to import exported namespaces from a file. Features of this import functionality:
- supports relative imports
- only loads code when required
- does not pollute global scope
- only gets imported once regardless of how many times it got imported
- only exports what you want
- code will be appended to the root file which may cause exceeding the character limit of GreyHack, use import_code instead if that is an issue
You can take a look at the example code to get a better idea of how to use this feature.
Used to import the content of a file. Features of this import functionality:
- supports relative includes
- very easy to use
- will pollute global scope
- will include the content of a file every time, which may cause redundant code
- may cause exceeding the character limit of GreyHack, use import_code instead if that is an issue
To get a better idea you can take a look at the following example code.
Used to import code from a file. Features of this import functionality:
- keeps files separate in-game, which is useful to avoid the character limit
- supports nested
import_code
- supports relative imports
Here is some example code.
By having the installer option active Greybel will create one or more installer files depending on the size of your project. These installer files will essentially contain all different code files and logic to create all files in the game. So basically you just need to copy and paste the code of the installer files into the game and then compile + execute them. By using the --auto-compile
flag additional logic will be appended that will automatically compile the project and remove all source files.
By setting up the in-game directory in the settings you can also define to which in-game space you want to import the files. By default /root/
will be used.
Additionally, it is important to mention that nested import_code
is supported as well. This is made possible by moving all imports into the entry file depending on their usage throughout the project. It is recommended to only use import_code
at the head of the file since the import locations of nested files cannot be guaranteed.
Any valid MiniScript or GreyScript syntax is supported. Additionally, some minor syntax sugar is added to those languages. If you use those keep in mind to transpile your code first. Using these is completely optional though.
myList = [
false,
null
]
myMap = {
"test": {
"level2": {
"bar": true
}
}
}
a /= b
a *= b
a -= b
a += b
a = b << c
a = b >> c
a = b >>> c
a = b | c
a = b & c
/*
My block comment
*/
print("test")
print(#filename)
The filename expression will be replaced with the string literal containing the name of the file before transpiling. Can be useful for debugging.
print(#line)
The line expression will be replaced with the number literal containing the line of the expression before transpiling. Can be useful for debugging.
print(#envar MY_TEST_VAR)
The envar expression will be replaced with the value of the provided environment variable. Make sure you defined an environment variable for the provided namespace if there is no value found it will instead use null
.
print(#inject "path/to/file";)
The inject expression will be replaced with the content of whatever file exists at the provided path. In case the file does not exist it will be replaced with null
. Content that gets injected will automatically be escaped.
In case you are not interested at all in the build functionality or require to upload a lot of files into the game you can also use the "Import files into game" command. It will pretty much have the same behavior as the create-ingame build feature just without building.
This feature will also use the transpiler "Ingame directory" setting as the in-game destination.
Greybel comes with its own GreyScript interpreter. Which enables you to test and debug your code outside of the game. This is partly also due to the test environment which gets generated on the fly trying to emulate the games API.
Dependencies will be dynamically loaded into the execution without any limitations. Cyclic dependencies are supported as well.
Greybel supports the injection of environment variables for the interpreter as well. These environment variables can be configured in the extension settings.
Greybel GreyHack Intrinsics will automatically generate a local environment. It will also generate other computers, networks, filesystems etc on the fly. Generating is by default based on a seed called test
. The seed can be modified with the seed option. While using the same seed-generated entities should stay consistent.
The local computer setup is hard coded. The admin credentials are root:test
. You will also have crypto.so
and metaxploit.so
on your local computer available.
Examples:
metax = include_lib("/lib/metaxploit.so") //returns metaxploit interface
print(metax) //prints metaxploit
myShell = get_shell("root", "test") //get local root shell
The 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:
AptClient
- only polyfill which "returns not yet supported"Blockchain
- only polyfill which "returns not yet supported"Wallet
- only polyfill which "returns not yet supported"SubWallet
- only polyfill which "returns not yet supported"Coin
- only polyfill which "returns not yet supported"
TextMesh Pro Rich Text is partially supported.
Note: For the pseudo-terminal Greybel will try to transform TextMesh Pro Rich-Text tags into ANSI-Codes. Due to the nature of TextMesh Pro Rich-Text tags some formatting will get lost. If you are looking for a proper preview of your output in Grey Hack please check out the preview output feature.
Enables you to set breakpoints, run code in a breakpoint context, jump to the next line of execution etc. Generally helpful if you want to debug your code.
Keep in mind to set the breakpoint on a none empty line. Otherwise, it will just skip that breakpoint.
A REPL is also available while executing the script or having an active breakpoint.
Will create a web view that will render actual TextMesh Pro Rich-Text tags in your VSCode. Main purpose of this feature is to emulate the actual output of the game. So in case you want to draw images or do fancy prompts this might be useful.
API Browser for GreyScript. Basically a version of the GreyScript API Documentation page within Visual Studio Code.
Provide signatures for your functions to show better hover tooltips. Additionally, the provided return value will be recognized by the implemented type system and thus result in context-sensitive auto-complete suggestions. In the future, it is planned to enable users to create their own custom types just by using comments.
// Hello world
// I am **bold**
// @description Alternative description
// @example test("title", 123)
// @param {string} title - The title of the book.
// @param {string|number} author - The author of the book.
// @return {crypto} - Some info about return
test = function(test, abc)
print(test)
end function
Shares your code via editor.greyscript.org. The related link will be written into the clipboard.
Will refresh the AST Cache which is used for diagnostics, hover tooltips and autocompletion.
Will return a list of available GreyHack snippets. Such as ls
, mkdir
and more.
Jumps to the next existing syntax error.
Figures out the current context and provides suggestions accordingly.
Returns information about functions/types.
Returns information about syntax errors in your code.
Returns list of all available symbols in the active file.
Shows definitions in the currently active file and its dependencies.
Shows the color picker if you got color or mark tags.
Sloth icons created by Freepik - Flaticon
- implement missing intrinsics
- improve mock environment
If you have any questions, feature requests or need help feel free to join the dedicated Greybel Discord.