Lokai

Moderator
Lokai submitted a new resource:

Lokai Versioning - Reduce compile times for new stand-alone scripts

Here is the reason for this change. You won't be able to tell from this below, but the compile time for the C# scripts can take anywhere from 20-30 seconds to several minutes on some systems. It depends on how many customs you have. The part below where it says "Finished with 0 errors, 0 warnings" is the part you wait patiently to appear.

Code:
ServUO - [http://www.servuo.com] Version 0.5, Build 5469.39357
Publish 54
Core: Running with arguments: -debug
Core: Optimizing for 2 64-bit processors...

Read more about this resource...
 
Just want to make sure, what goes where?

* * * * SCRATCH THAT, EDIT * * * *
I am using linux, should I copy the win.bat over my mono.bat?
Other than that, I guess the Main and ScriptCompiler.cs files get overwritten?
 
Just put Main and ScriptCompiler in your Server folder and compile using whatever compiler you have.
 
How would you set up the server to restart automatically every 24 hours, and give warnings 10, 5, 1 minutes left?
There is a timer class called "AutoRestart" which can do this for you and also allows you to set up a "server wars" period where the shard is still up, but not saving.
 
Help me to remember how to use it please. I have installed both in server and compiled it OK.

But to test a script, I should create a folder called Scripts.LV1, put my script there and run ServUO with parameter -LV1?
[doublepost=1522039475][/doublepost]Lokai, the updated script has an error:
Scripts: Compiling Lokai Version-1 C# scripts...Error:
System.ArgumentException: Path is empty
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00027] in <62351af909f64c3d9f8698380a6f7518>:0
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <62351af909f64c3d9f8698380a6f7518>:0
at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.IO.File.OpenRead (System.String path) [0x00000] in <62351af909f64c3d9f8698380a6f7518>:0
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00023] in <6bff51911ba74b8784948845d461f16f>:0
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00006] in <6bff51911ba74b8784948845d461f16f>:0
at Server.ScriptCompiler.CompileLV1Scripts (System.Boolean debug, System.Boolean cache, System.Reflection.Assembly& assembly) [0x001a9] in <48d4f54ece934a5c99c388689eb200b1>:0
at Server.ScriptCompiler.Compile (System.Boolean debug, System.Boolean cache) [0x000b2] in <48d4f54ece934a5c99c388689eb200b1>:0
at Server.Core.Main (System.String[] args) [0x00660] in <48d4f54ece934a5c99c388689eb200b1>:0
This exception is fatal, press return to exit

It occurs when you put ANY script inside Scripts.LV1 folder. If it is void, return message "no files found" and compile ok.

I am tired, gonna give a try another day.
 
Last edited:
That sounds right. It is working for me using the script I updated. I use a batch file I wrote to allow me to choose which folders to compile while starting the server.
 

Attachments

  • Lokai Servuo Menu.zip
    1.3 KB · Views: 19
Make sure you delete ALL compiled files in the Output folder now before running the server again.
 
Had a thought about this and was wondering if it would work to create a shortcut to say BaseCreature and put that shortcut in the custom folder. Would the shortcut allow your system to read the updated BaseCreature without moving the actual file?
 
Had a thought about this and was wondering if it would work to create a shortcut to say BaseCreature and put that shortcut in the custom folder. Would the shortcut allow your system to read the updated BaseCreature without moving the actual file?

I honestly have no idea what this means. Either my headache is really bad this morning, or... never mind, my head really IS bad this morning, but what the heck does this mean?
 
your versioning only compiles scripts in a particular folder right?

what if I change BaseCreature and want it to recompile that script but not the whole system.
Could I create a "shortcut" to BaseCreature and put the shortcut into the folder that is being recompiled every time so that it would then recompile BaseCreature without having to actually move the BaseCreature.cs out of Scripts/Mobiles

or am I misunderstanding how this works
 
The issue is that BaseCreature depends on other scripts, and more importantly other scripts depend on it. If you make a change, even to add a comment in the file, the Scripts folder would need to be recompiled. What this system does is allows you to separately compile independent scripts and systems. These scripts can use elements in scripts like BaseCreature and others in the Core because they will already be compiled by the time these are evaluated. However, the Core and Scripts folders cannot reference any of the scripts in the LV folders because they will not be available to them during compile time.
 
Ahh ok now I see the real question ;)

Additonally to what Lokai already said it works like this. You split the Scripts folder.
So that the new Scripts folder would read the compiled dll too and therefor have access to the codebase.

But in the end you generate multiple dlls. Therefor if you change something in Scripts, you will recompile Scripts. If you change something in Scripts2 then you will recompile that, and so on.

Hope this makes it easier to understand
 
That makes sense.

Was just hoping for a faster way to restart/recompile during testing of new scripts.

Is VS faster at that sort of thing?
 
As long as those new scripts are stand alone, and not modified versions of stock scripts then yes this is what it does. If I change BaseCreature or any other stock script, the recompile takes me about 25-30 seconds if there are no errors, but recompiling when the only script I have changed is in my LV1 folder takes me only 1 second. Complete world load varies depending on how populated the world is, but just by compile time alone you can see the saving after making a small change, testing, changing, testing, etc. etc. Those 30 seconds add up fast.
 
I am getting this error with the new scripts you uploaded:
CS0122: Line 659: `Server.Region.Load()' is inaccessible due to its protection level

* * * EDIT * * *
Main.cs is giving the error.
 
Last edited:
I dont understand how to get it work, i believe i will create a folder in script folder named Scripts.Lv1 and how can i run servuo with parameters?
I am sorry if the questions are absurd but i am new in c# :).
 
Last edited:
I dont understand how to get it work, i believe i will create a folder in script folder named Scripts.Lv1 and how can i run servuo with parameters?
I am sorry if the questions are absurd but i am new in c# :).

I have to second @Khalgir Sphrenies on this one. I have the scripts in and the server compiles everything in the base Scripts folder just fine. I am now confused on how to tell ServUo to run with the -lv1 parameters. I am sure it is something simple I am missing, any pointers would be appreciated :)
 
I have to second @Khalgir Sphrenies on this one. I have the scripts in and the server compiles everything in the base Scripts folder just fine. I am now confused on how to tell ServUo to run with the -lv1 parameters. I am sure it is something simple I am missing, any pointers would be appreciated :)

What I usually use is a batch file like the one attached. Change the extension from .txt to .bat and it will start the server and give you options for turning on various flags including any combination of LV1-5 plus debug and others. So, if you were only using the LV1 folder, for example, you would select option Z to go to the version menu, then select option 1 to select only to run with LV1. I often run with 2 folders, LV1 and LV2, so I use option Z to go to the version menu, then option A to select folders 1 and 2.
 

Attachments

  • Lokai Servuo Menu.txt
    6.7 KB · Views: 13
What I usually use is a batch file like the one attached. Change the extension from .txt to .bat and it will start the server and give you options for turning on various flags including any combination of LV1-5 plus debug and others. So, if you were only using the LV1 folder, for example, you would select option Z to go to the version menu, then select option 1 to select only to run with LV1. I often run with 2 folders, LV1 and LV2, so I use option Z to go to the version menu, then option A to select folders 1 and 2.
I may see what I can do to port that to a linux shell. My current shard is in Windows, but looking to move to a VPS, and testing with a smaller and cheaper Linux box. thanks!
 
Back