This is a collection of C# scripts for RazorEnhanced The best place to clone this repo is inside the folder Scripts of RE.
Most of these scripts are tested only on Demise Server but feel free to fix it for your server and send me a PR Some scripts are under development or just for reference purpose. Do not expect that all is perfect!
Clone this repo into RazorEnhanced Scripts folder and add all C# files you need
The develpment of those script is made on Visual Studio 2019 Community Edition and this is why I provide also a VS solution. Develop C# scripts is more more complex compared to Python scripting and this is why I'm not going to provide here personal support on how setup the enviroment but feel free to ask in RE Discord Channel.
There are many way to develop a C# script but the most comfortable (for me) is the following:
- Clone this repo somewhere in your pc
- Clone RazorEnhanced source code in an other folder
- Compile it in debug with Visual Studio
- Locate the folder bin\Win32\Debug\Scripts, and make inside it a junction (symbolic links works only on NTFS not ExFAT) to this script repo (ref. #1). Execute this command in CMD (not PowerShell):
mklink /J CSharp <full path of this cloned repo)
- Now open Scripts.sln file from bin\Win32\Debug\Scripts and never from the folder where you cloned the repo
- Mantain RazorEnhanced source code updated
git pull
to be sure to have the latest features
Note:
- You don't need to run the compiled version of Razor but you can use the installed and include scripts from there
- If you want run your builded copy of RE, consider that the build procedure deletes the Scripts forlder. The better thing to do is create a batch file that generates the junction and run it before run UO.
- Junktions works only on NTFS
- Use Command Prompt (cmd) and not Power Shell
- Remember to add quotes "" if your path contains a space
- Be careful to not have too much long paths because Windows limitations
Debug with Visual Studio is very simple:
- Run RazorEnhanced
- Open Scripts.sln
- Press
CTRL + ALT + P
- Locate RazorEnhanced.exe if you are running OSI Client or
ClassicUO.exe
if you are using Classic UO - Then Attach to the process
- Place your breakpoints
- Run the script on RazorEnhanced and enjoy your breakpoint
C# scripting supports a list of directives that can enable extra features. All those directives MUST be added before the keyword namespace.
Some C# files uses classes written in other C# files and RazorEnhanced implements a "custom C# way" to link files using a special directive
//#import <relative path of the imported C# file>
//#import "absolute path of the imported C# file
So be careful to have all required file in the correct path before run the script.
Some C# script may need an external assembly and this directive allow you to specify which assembly you need.
You can use this directive instead of add the assembly into the assemblies.cfg
file.
Both absolute and relative path are valid
//#assembly <Newtonsoft.Json.dll>
//#assembly "C:\absolutePath\awesome.dll>
By default all script are builded in release. During the development, haveing the script in debug is very useful and this directive force the build to be in debug. You can do the same thing running the script from the Script Editor and click on the debug button. Remember that debug build is always slower than the default release. Use it only during the development.
//#forcedebug
An important file to make scripts work is Assemblies.cfg. It contains the list of all the DLLs that are required to run your scripts. If you want to use a custom DLL place it in RazorEnhanced main folder and add it's name into this file. You can also add the full path using quotes
This is the list of great guys that contributes to this repository
- Dynamic aka FunkyPants