[Side-Project] IG# / InfamousGeek Sharp

07/26/2010 15:18 InfamousGeek#1
As you know me of my Basic Conquer Emulator project, this is a side-project which I thought of when going through the npc server. I decided it would be a fun experience to write a scripting language which is a modification of C#, therefore IG#. So far it only supports Console.WriteLine, but every unknown method or variable will be invoked to an event which you can eventually handle on your own. Also undefined variables must be registered before compiling the external code.

A little preview:
Code:
        static void Main(string[] args)
        {
            IGReader Reader = new IGReader();
            Reader.Load(@"C:\Users\Admin\Documents\Test.txt");
            IGCompiler Compiler = Reader.ToIGCompiler();
            Compiler.Register("dialog", 3, IGVariableType.Integer);//Defining variables
            Compiler.Compile();//Compile the code

            Console.WriteLine("[IGSharp] Executed file!");
            Reader.Dispose();
            Compiler.Dispose();
            GC.Collect();

            while (true)
                Console.ReadLine();
        }
Little example code I wrote;
Code:
if (1 == 2)
{
  Console.WriteLine(Member 1 executed!);
}
if (1 == 1)
{
  Console.WriteLine(Member 2 executed!);
}
if (2 == 2)
{
  Console.WriteLine(Member 3 executed!);
}
if(%dialog == 3)
{
   Console.WriteLine(Member 4 executed!);
}
Have a good day.
07/26/2010 17:00 _DreadNought_#2
Neat, using a .dll ?
07/26/2010 17:06 InfamousGeek#3
Quote:
Originally Posted by Eliminationn View Post
Neat, using a .dll ?
Ofcourse. Most likely I'm stupid enough to share the source with you. Meh, if life was just that easy.
07/26/2010 17:12 Korvacs#4
Doesnt look like your going to be able to modify npc scripts on the fly with this? Unless you recompile everytime an npc is accessed which makes me wonder what the performance would be like while using this.
07/26/2010 17:15 InfamousGeek#5
Quote:
Originally Posted by Korvacs View Post
Doesnt look like your going to be able to modify npc scripts on the fly with this? Unless you recompile everytime an npc is accessed which makes me wonder what the performance would be like while using this.
The speed actually is pretty fast, also the process when compiling is very light-weight. I didn't have problems when testing this with npcs, also checked with GC for the memory usage.
07/26/2010 17:18 Korvacs#6
Quote:
Originally Posted by InfamousGeek View Post
The speed actually is pretty fast, also the process when compiling is very light-weight. I didn't have problems when testing this with npcs, also checked with GC for the memory usage.
Not doubting it works, or even works well, just wondering how well it compares to other script based methods.
07/26/2010 17:19 InfamousGeek#7
Quote:
Originally Posted by Korvacs View Post
Not doubting it works, or even works well, just wondering how well it compares to other script based methods.
I might compare it to LUA or do you perhaps know another quick scripting language? So that I can compare it with mine.
07/26/2010 17:44 Korvacs#8
Quote:
Originally Posted by InfamousGeek View Post
I might compare it to LUA or do you perhaps know another quick scripting language? So that I can compare it with mine.
LUA would probably give the best overall benchmark i think, personally i was thinking about something like xml based npcs, with sections containing functions which require a compiler, but i havent really decided yet, that way the scripts can be updated on the fly, and the performance hit from using a compiler would be minimal since the function is only compiled when its required.
07/26/2010 20:48 InfamousGeek#9
Quote:
Originally Posted by Korvacs View Post
LUA would probably give the best overall benchmark i think, personally i was thinking about something like xml based npcs, with sections containing functions which require a compiler, but i havent really decided yet, that way the scripts can be updated on the fly, and the performance hit from using a compiler would be minimal since the function is only compiled when its required.
Its kinda harsh using xml section for npc scripting, even though that is my personal opinion.
07/28/2010 18:26 Basser#10
I'm speechless.