Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 13:33

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Scripting via IronPython

Discussion on Scripting via IronPython within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
InsomniacPro's Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 397
Received Thanks: 205
Scripting via IronPython

So now, I'm pretty sure, approx 99.2% affirmative that I have ironpython setup correctly. Now when I utilize this code.
Code:
                    var Test = scope.GetVariable<Func<GameClient, ushort, int>>("npc");
                    Test(Client, option);
                    runtime.Shutdown();
I'll get the error


Now, has anyone come across this error?
I'm pretty new to IronPython, so please bear with me.

Thanks for any help.
InsomniacPro is offline  
Old 04/23/2014, 21:09   #2
 
elite*gold: 0
Join Date: Feb 2006
Posts: 726
Received Thanks: 271
Can't say I have ever scripted with iron python.

But judging from the error, try:

Code:
    var Test = scope.GetVariable<Func<GameClient, short, int>>("npc");
Aceking is offline  
Old 04/23/2014, 22:40   #3
 
InsomniacPro's Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 397
Received Thanks: 205
Quote:
Originally Posted by Aceking View Post
Can't say I have ever scripted with iron python.

But judging from the error, try:

Code:
    var Test = scope.GetVariable<Func<GameClient, short, int>>("npc");
I've tried all data types. No luck.
InsomniacPro is offline  
Old 04/23/2014, 22:43   #4
 
abdoumatrix's Avatar
 
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 238
just stupid question

why u use ironpython for npcscripting?

i would go with a similar script engine like

's one.
abdoumatrix is offline  
Old 04/23/2014, 22:44   #5
 
InsomniacPro's Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 397
Received Thanks: 205
Quote:
Originally Posted by abdoumatrix View Post
just stupid question

why u use ironpython for npcscripting?

i would go with a similar script engine like

's one.
I can ask the same question to the OP of that source as to why he didn't use IronPython.
InsomniacPro is offline  
Thanks
1 User
Old 04/23/2014, 23:01   #6
 
elite*gold: 0
Join Date: Sep 2013
Posts: 197
Received Thanks: 141
It seems like a bug in your Python script
SteveRambo is offline  
Old 04/23/2014, 23:08   #7
 
elite*gold: 0
Join Date: May 2011
Posts: 648
Received Thanks: 413
Quote:
Originally Posted by abdoumatrix View Post
just stupid question

why u use ironpython for npcscripting?

i would go with a similar script engine like

's one.
Probably because apple pie isn't as tasty as strawberry ice.

Y u k i is offline  
Old 04/23/2014, 23:32   #8
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Quote:
Originally Posted by InsomniacPro View Post
I can ask the same question to the OP of that source as to why he didn't use IronPython.
Why use ProjectX's scripting engine?
1. You can script in C#/VB
2. The scripts are compiled to IL and loaded only once (although, by the looks of it, Super Aids has implemented, but does not use [might use a command or something for that too], something that reloads the scripts)
3. The scope of the script is handled by .net (that is if the script is loaded in the same AppDomain)
4. Once a script is compiled and the method info is kept in a dictionary using it would be like invoking any function using Delegate.Invoke.

Why not to use it as is:
1. Reloading one script would require copying the contents of all the existing scripts into one file, then compile it, to update all preloaded scripts.
2. When you write a script, the method name will have to follow C#'s/VB's guidelines regarding the method name, so you can't use something like script_1-100,200-400(...) to avoid making 299 files for the same function.

Why use IronPython?
1. If you love/want to learn Python, you will obviously want to use IronPython.
2. It's an easy scripting language which provides lots of features

Why not use IronPython?
1. The scope is handled by you by setting variables.
2. Writing scripts with IronPython can be tricky if you want to use .net libraries or w/e without auto completition (although it is possible with Wing [maybe with others too?], as I was just reading).

I don't use Python much so I couldn't find more reason as to why to use or why not to use it. Although if you're interested into performance, using compiled C#/VB scripts is faster.
-impulse- is offline  
Thanks
3 Users
Old 04/23/2014, 23:34   #9
 
InsomniacPro's Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 397
Received Thanks: 205
Quote:
Originally Posted by -impulse- View Post
Why use ProjectX's scripting engine?
1. You can script in C#/VB
2. The scripts are compiled to IL and loaded only once (although, by the looks of it, Super Aids has implemented, but does not use [might use a command or something for that too], something that reloads the scripts)
3. The scope of the script is handled by .net (that is if the script is loaded in the same AppDomain)
4. Once a script is compiled and the method info is kept in a dictionary using it would be like invoking any function using Delegate.Invoke.

Why not to use it as is:
1. Reloading one script would require copying the contents of all the existing scripts into one file, then compile it, to update all preloaded scripts.
2. When you write a script, the method name will have to follow C#'s/VB's guidelines regarding the method name, so you can't use something like script_1-100,200-400(...) to avoid making 299 files for the same function.

Why use IronPython?
1. If you love/want to learn Python, you will obviously want to use IronPython.
2. It's an easy scripting language which provides lots of features

Why not use IronPython?
1. The scope is handled by you by setting variables.
2. Writing scripts with IronPython can be tricky if you want to use .net libraries or w/e without auto completition (although it is possible with Wing [maybe with others too?], as I was just reading).

I don't use Python much so I couldn't find more reason as to why to use or why not to use it. Although if you're interested into performance, using compiled C#/VB scripts is faster.
Well, after reading this, and doing my own personal research ofc, I guess I will go along the lines of what Jacob made and do all that. Keeping C# syntax is a big deal to me, so thanks Alex.
InsomniacPro is offline  
Old 04/24/2014, 08:08   #10
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
Quote:
Originally Posted by -impulse- View Post
Why use ProjectX's scripting engine?
1. You can script in C#/VB
2. The scripts are compiled to IL and loaded only once (although, by the looks of it, Super Aids has implemented, but does not use [might use a command or something for that too], something that reloads the scripts)
3. The scope of the script is handled by .net (that is if the script is loaded in the same AppDomain)
4. Once a script is compiled and the method info is kept in a dictionary using it would be like invoking any function using Delegate.Invoke.

Why not to use it as is:
1. Reloading one script would require copying the contents of all the existing scripts into one file, then compile it, to update all preloaded scripts.
2. When you write a script, the method name will have to follow C#'s/VB's guidelines regarding the method name, so you can't use something like script_1-100,200-400(...) to avoid making 299 files for the same function.

Why use IronPython?
1. If you love/want to learn Python, you will obviously want to use IronPython.
2. It's an easy scripting language which provides lots of features

Why not use IronPython?
1. The scope is handled by you by setting variables.
2. Writing scripts with IronPython can be tricky if you want to use .net libraries or w/e without auto completition (although it is possible with Wing [maybe with others too?], as I was just reading).

I don't use Python much so I couldn't find more reason as to why to use or why not to use it. Although if you're interested into performance, using compiled C#/VB scripts is faster.
What I did for the reload was using FileSystemWatcher.

I did some heavy optimization and changes to it when I worked on coding for Insomnius. Since I used it to implement dynamic events so lots of features could be edited/added at runtime like tournaments, commands, playerdebugging, time specific actions etc.

Imma see if I can find it, in case it would be necessary else I might just rewrite the engine from that source.
Super Aids is offline  
Old 04/24/2014, 12:04   #11


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
Quote:
Originally Posted by -impulse- View Post
Why use ProjectX's scripting engine?
I don't use Python much so I couldn't find more reason as to why to use or why not to use it. Although if you're interested into performance, using compiled C#/VB scripts is faster.
Nope. IronPython can be compiled as well, and stored into the memory. It`s not a matter of performance, it`s a matter of preference (and maybe compile speed as well. I personally would suggest to everyone who wants to implement a scripting engine to go with what he/she or the other devs are more confortable with, the minimal performance differences(that is, if you handle everything correctly in the parser/whatever) don`t count as much here as the productivity rate.

On the other side, wb bro, haven`t seem you for some time now.
KraHen is offline  
Old 04/24/2014, 13:17   #12
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Quote:
Originally Posted by KraHen View Post
Nope. IronPython can be compiled as well, and stored into the memory. It`s not a matter of performance, it`s a matter of preference (and maybe compile speed as well. I personally would suggest to everyone who wants to implement a scripting engine to go with what he/she or the other devs are more confortable with, the minimal performance differences(that is, if you handle everything correctly in the parser/whatever) don`t count as much here as the productivity rate.

On the other side, wb bro, haven`t seem you for some time now.
Uhm, no. Because even if python is compiled, it is still is interpreted 2 times. First from the pyc and then as IL compared to C#/VB where it's only IL.

There's a lot of threads on this topic, one of which is:

The opinions vary, but at balance C# > IronPython.

Anyway, I am not sure how debugging would go... With C# I can generate a pdb in memory and have a full stacktrace whenever an exception appears. With IronPython the errors look weird...

I've been around. I am always skulking in the shadows.
-impulse- is offline  
Old 04/25/2014, 02:01   #13
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 992
Received Thanks: 1,110
PHP Code:
using System.CodeDom.Compiler;

public class 
ScriptEngine
{
    private static 
CodeDomProvider Provider CodeDomProvider.CreateProvider("CSharp");
    public static 
CompilerResults Compile(string CodeCompilerParameters Parameters)
    {
        
Parameters.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
        
Parameters.CompilerOptions "/t:library";
        
Parameters.GenerateInMemory true;
        
CompilerResults cr Provider.CompileAssemblyFromSource(ParametersCode);
        if (
cr.Errors.Count 0)
        {
            
//Error out
            
return null;
        }
        return 
cr;
    }

Ideas ?
{ Angelius } is offline  
Old 04/25/2014, 02:46   #14


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
Quote:
Originally Posted by -impulse- View Post
Uhm, no. Because even if python is compiled, it is still is interpreted 2 times. First from the pyc and then as IL compared to C#/VB where it's only IL.

There's a lot of threads on this topic, one of which is:

The opinions vary, but at balance C# > IronPython.

Anyway, I am not sure how debugging would go... With C# I can generate a pdb in memory and have a full stacktrace whenever an exception appears. With IronPython the errors look weird...

I've been around. I am always skulking in the shadows.
2 times for this amount of scripts is still not a problem, not even with 2k+ players, the same method is used with LUA in commercial games and it works wonders.

Anyhow, debugging is easy, with PTVS it gets really easy (also, you can debug standard python as well).
KraHen is offline  
Old 04/25/2014, 13:10   #15
 
elite*gold: 0
Join Date: Oct 2009
Posts: 768
Received Thanks: 550
Quote:
Originally Posted by { Angelius } View Post
PHP Code:
using System.CodeDom.Compiler;

public class 
ScriptEngine
{
    private static 
CodeDomProvider Provider CodeDomProvider.CreateProvider("CSharp");
    public static 
CompilerResults Compile(string CodeCompilerParameters Parameters)
    {
        
Parameters.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
        
Parameters.CompilerOptions "/t:library";
        
Parameters.GenerateInMemory true;
        
CompilerResults cr Provider.CompileAssemblyFromSource(ParametersCode);
        if (
cr.Errors.Count 0)
        {
            
//Error out
            
return null;
        }
        return 
cr;
    }

Ideas ?
This is what I use to compile and extract only the method I require from a script:


To be able to compile in parallel you have to use a different object of CompilerParameters (because the compiler parameters generates only one random temp file name, when it's constructed, not when you do the actual compiling).

My scripts look something like:

PHP Code:
using System;
using CoEmuLibrary;
using CoEmuLibrary.Packets;

class 
Main
{
    public static 
unsafe void Execute(Item itemIGameClient client)
    
//public static unsafe void Execute(IntPtr ptr, IGameClient client) // for handling pointers to packets or w/e
    
{
    }

-impulse- is offline  
Reply


Similar Threads Similar Threads
NPC scripting
09/22/2011 - Ragnarok Online - 1 Replies
Hey Leute/ Gamer und eventuell Scripter :) Ich bin seit einiger Zeit dabei mir npc scripting für RO beizubringen, ich habe auch nen wunderbaren Guide dazu gefunden und zwar : eAthena Support Board > Npc Scripting Tutorial mein Problem: Die Links sind down, nun weiß ich nicht wie ich z.B (siehe Kapitel 12) die Befehle umsetzen kann.
SCRIPTING HELP
06/08/2009 - Lineage 2 - 0 Replies
this is my 1st time at scripting so please help me out. Simple OOG Walker Chant of Life DOT heal for warcrier for group member with delay and loops LABEL(DOT) DELAY(15000) MemberStatus(MyBD,HP,<=,65) UseSkill(Chant of Life) CALL(DOT) any of my syntax is wrong? the probleem is it does not check the member hp condition.
L2 scripting
07/19/2007 - Lineage 2 - 1 Replies
hey ya guys, i would like to ask you, if there is any possibility how to make a script, that would report about your char, for eg. i will pm on my spoil from another char with any security asnwer, like howmanyitems? - and my spoil should asnwer, how many items does it have....idk -> im away from home and left my spoiler spoiling some materials or enchants, log anywhere on another char, then PM my spoil, how many items or enchants does it have....i tried something about AI answer, but i...
LUA Scripting
06/23/2006 - World of Warcraft - 2 Replies
Moin, Suche einen LUA Scripter der mir folgendes AddOn machen könnte: Mein Bankchar steht z.B. in Ironforge rum. Wenn mich nun z.B. ein Gildenspieler mit dem Text "Bankinhalt" anwhispert, soll das AddOn automatisch checken was in der Bank ist und ihm anschliessend sofort zurücksenden was in der Bank vorhanden ist und in welcher Menge. Wenn sowas möglich ist, wäre es echt cool wenn mir jemand helfen könnte. Bin gerne für ander Vorschläge offen, wenn meiner nicht geht! Schonmal Danke...



All times are GMT +1. The time now is 13:33.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.