Skip to content

dust765/RazorEnhacedCSharpScripts

 
 

Repository files navigation

C# Scripts for RazorEnhanced

This is a collection of C# scripts for RazorEnhanced The best place to clone this repo is inside the folder Scripts of RE.

Disclaimer

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!

Use the scripts

Clone this repo into RazorEnhanced Scripts folder and add all C# files you need

Development

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:

  1. Clone this repo somewhere in your pc
  2. Clone RazorEnhanced source code in an other folder
  3. Compile it in debug with Visual Studio
  4. 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)
  5. Now open Scripts.sln file from bin\Win32\Debug\Scripts and never from the folder where you cloned the repo
  6. Mantain RazorEnhanced source code updated git pull to be sure to have the latest features

Note:

  1. You don't need to run the compiled version of Razor but you can use the installed and include scripts from there
  2. 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.
  3. Junktions works only on NTFS
  4. Use Command Prompt (cmd) and not Power Shell
  5. Remember to add quotes "" if your path contains a space
  6. Be careful to not have too much long paths because Windows limitations

Debug

Debug with Visual Studio is very simple:

  1. Run RazorEnhanced
  2. Open Scripts.sln
  3. Press CTRL + ALT + P
  4. Locate RazorEnhanced.exe if you are running OSI Client or ClassicUO.exe if you are using Classic UO
  5. Then Attach to the process
  6. Place your breakpoints
  7. Run the script on RazorEnhanced and enjoy your breakpoint

Special RazorEnhanced C# scripting features

C# scripting supports a list of directives that can enable extra features. All those directives MUST be added before the keyword namespace.

//#import directive

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.

//#assembly directive

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>

//#forcedebug directive

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

Notes

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

Contributes

This is the list of great guys that contributes to this repository

  • Dynamic aka FunkyPants

Links

About

A collection of C# scripts for RazorEnhanced

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%