|
You last visited: Today at 22:48
Advertisement
C# or Python?
Discussion on C# or Python? within the CO2 Programming forum part of the Conquer Online 2 category.
06/04/2013, 00:31
|
#1
|
elite*gold: 0
Join Date: Apr 2013
Posts: 120
Received Thanks: 4
|
C# or Python?
So, I have been using pro4never's Albetros source lately to learn some stuff, and I have been wondering...
Are there, if any benefits to using Python over C# for NPCs or anything else?
I have found that Python can be quite annoying-- I constantly am having to go over ALL of the code to make sure there are not any "tabs" instead of spaces and other things as well. I also was thinking that since you have to write in code to use Python in the source that it would just be easier to use C#. I have been using Notepad++ with "Python" as the language as well as replacing "tab" with 4 spaces as Python requires, but I feel like using MSVS 2010U is better than trying to mess with Python. Yes, I understand that I can change the scripts for NPCs with Python without having to restart the server, but could this also be changed somehow for the C# code...?
Any thoughts, comments?
|
|
|
06/04/2013, 00:45
|
#2
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
|
We used external scripts because
A: Developers could code npcs without having access to our source. Useful when you maybe have some less experienced people on your development team.
B: Scripts are loaded as the npc is clicked. As such it updates instantly ingame when testing and developing new features.
If you want to develop using python scripts then you should use a python editor. That will solve your tab issues.
|
|
|
06/04/2013, 01:29
|
#3
|
elite*gold: 0
Join Date: Apr 2013
Posts: 120
Received Thanks: 4
|
Quote:
Originally Posted by pro4never
We used external scripts because
A: Developers could code npcs without having access to our source. Useful when you maybe have some less experienced people on your development team.
B: Scripts are loaded as the npc is clicked. As such it updates instantly ingame when testing and developing new features.
If you want to develop using python scripts then you should use a python editor. That will solve your tab issues.
|
That's good reason. As I've only myself working on the server, I didn't really consider that reason (A).
Yeah, I know the loading as clicked, I was just wondering if maybe there were other reasons like, efficiency of the code (minus loading on click) or anything.
Also, since you replied here, I was having some issues with a couple of the scripts like eh.. "AddItems" and "RemoveItems." I since have just used C# because I didn't understand what the issue was seeing as how the others seemed to work. If I come across the error again, I'll make sure to screenshot it. I believe it was something like "AddItems" didn't exist or something, but I can see it perfectly in the C# Npc.cs code. o.O
|
|
|
06/04/2013, 03:10
|
#4
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
You can also do a script engine using C#, that is what I'm using for tournaments, events, npcs and items xD
Personally I'd say use C# if your source is C#, because keeping it all to the same language will simplify things.
|
|
|
06/04/2013, 03:48
|
#5
|
elite*gold: 0
Join Date: Apr 2013
Posts: 120
Received Thanks: 4
|
Quote:
Originally Posted by Super Aids
You can also do a script engine using C#, that is what I'm using for tournaments, events, npcs and items xD
Personally I'd say use C# if your source is C#, because keeping it all to the same language will simplify things.
|
Yeah? So you can do exactly what I do with Python as external script, but with C#? I'm sure I'd have to figure out myself how to do that... >_< Changing it from Python to C# external, that is. Would you have to add in stuff like the Python one has in NPC.cs like eh.. "AddItem" "Text("texthere)"? Or could I type just as I do in the .cs files o_O
|
|
|
06/04/2013, 05:26
|
#6
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
You can call everything in your source. System.Reflection is your friend.
Here is the old version of mine, it may not be suitable unless you modify it.
In case you want an example:
Code:
public static void script_702(GameClient client, byte option) // script_ before the id is necessary!
{
switch (option)
{
case 0:
{
if (client.SpouseDatabaseUID == 0)
{
NPCHandler.SendDialog(client, "Is there someone you love and wants to marry?");
NPCHandler.SendOption(client, "I've found the love of my life.", 1);
}
else
{
NPCHandler.SendDialog(client, "Perhaps you're unhappy in your marriage?");
NPCHandler.SendOption(client, "I want to get divorced.", 1);
}
NPCHandler.SendOption(client, "No thanks.", 255);
NPCHandler.Finish(client);
break;
}
case 1:
{
if (client.SpouseDatabaseUID == 0)
NPCHandler.Marriage(client);
else
NPCHandler.Divorce(client);
break;
}
}
}
|
|
|
06/04/2013, 06:30
|
#7
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
|
Yup you can use any language you wish. I believe it was bio hazard who was working on all the scripting in albetros so I just let him do whatever he wanted. He decided on iron python so I just went along with it and added a few methods for him to use when coding npcs.
|
|
|
06/04/2013, 06:36
|
#8
|
elite*gold: 0
Join Date: Apr 2013
Posts: 120
Received Thanks: 4
|
Quote:
Originally Posted by Super Aids
You can call everything in your source. System.Reflection is your friend.
Here is the old version of mine, it may not be suitable unless you modify it.
In case you want an example:
Code:
public static void script_702(GameClient client, byte option) // script_ before the id is necessary!
{
switch (option)
{
case 0:
{
if (client.SpouseDatabaseUID == 0)
{
NPCHandler.SendDialog(client, "Is there someone you love and wants to marry?");
NPCHandler.SendOption(client, "I've found the love of my life.", 1);
}
else
{
NPCHandler.SendDialog(client, "Perhaps you're unhappy in your marriage?");
NPCHandler.SendOption(client, "I want to get divorced.", 1);
}
NPCHandler.SendOption(client, "No thanks.", 255);
NPCHandler.Finish(client);
break;
}
case 1:
{
if (client.SpouseDatabaseUID == 0)
NPCHandler.Marriage(client);
else
NPCHandler.Divorce(client);
break;
}
}
}
|
Thanks! Nice to see an example, too.
Quote:
Originally Posted by pro4never
Yup you can use any language you wish. I believe it was bio hazard who was working on all the scripting in albetros so I just let him do whatever he wanted. He decided on iron python so I just went along with it and added a few methods for him to use when coding npcs.
|
Well, that's good to know. I think Python is probably an "easier" language, but if I can still use VS to edit the NPCs externally, I think it will give me more control over what I want to do, and also be able to catch little errors I might have.
Thanks, to you both. I will try to do this.
|
|
|
06/04/2013, 15:22
|
#9
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,446
Received Thanks: 1,179
|
I did my own "scripting language" based on INI syntax to let people with NO coding knowledge do NPCs. You had only to understand the requirements & rewards field and that if you added several blocks to the page, it was like a if/elseif/else.
Today, I would go for Lua, because C# reflection must be used in C#, while Lua can be used in any language.
|
|
|
06/04/2013, 20:24
|
#10
|
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
|
I still heavily prefer Python over Lua
|
|
|
06/04/2013, 20:34
|
#11
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
|
Quote:
Originally Posted by InfamousNoone
I still heavily prefer Python over Lua
|
Amen.
I've done a little bit of scripting in LUA for various bots before and as much as python can tick me off some times, I'd definitely prefer it.
|
|
|
06/04/2013, 21:27
|
#12
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,446
Received Thanks: 1,179
|
Quote:
Originally Posted by InfamousNoone
I still heavily prefer Python over Lua
|
Quote:
Originally Posted by pro4never
Amen.
I've done a little bit of scripting in LUA for various bots before and as much as python can tick me off some times, I'd definitely prefer it.
|
Lua, although really limited due to the goal of always doing something really small, portable and fast, is fine. I've never used Python. I'm sure it has more features than Lua (not really hard to beat). It just that NPC scripting was always relayed to second plan when I worked on server projects. So, I would still go for something I already know how to implement easily
|
|
|
06/05/2013, 02:15
|
#13
|
elite*gold: 0
Join Date: Mar 2005
Posts: 1,430
Received Thanks: 1,587
|
Personally if someone took some time and did a nice IDE for Lua (no good ones to my knowledge but am happy to be proven wrong). Lua would be the best option because of its flexability. (IMO)
The downside with Lua is like with any scripting language. is The Syntax can get very untidy and a bit tricky to follow.
But, yea that can be solved to a point.
Id go for Lua over c#.
Lua over Python (i can't judge - never used Python)
Just my 2 cents worth
|
|
|
06/05/2013, 21:37
|
#14
|
elite*gold: 0
Join Date: Apr 2013
Posts: 120
Received Thanks: 4
|
Quote:
Originally Posted by CptSky
I did my own "scripting language" based on INI syntax to let people with NO coding knowledge do NPCs. You had only to understand the requirements & rewards field and that if you added several blocks to the page, it was like a if/elseif/else.
Today, I would go for Lua, because C# reflection must be used in C#, while Lua can be used in any language.
|
Quote:
Originally Posted by Ultimation
Personally if someone took some time and did a nice IDE for Lua (no good ones to my knowledge but am happy to be proven wrong). Lua would be the best option because of its flexability. (IMO)
The downside with Lua is like with any scripting language. is The Syntax can get very untidy and a bit tricky to follow.
But, yea that can be solved to a point.
Id go for Lua over c#.
Lua over Python (i can't judge - never used Python)
Just my 2 cents worth 
|
I have never even heard of, Lua, actually. Any example as to how it's actually used? Also, in regards to using INI files, I read someone say on the forums that it can take a lot of RAM to use INI files for a lot of other things? I was mainly looking for something that I can have the system check for me for stupid little mistakes like spacing, or maybe I didn't add a punctuation mark ie: ,";: etc. and for efficiency.
And I also thought maybe using C# would give me more "use" or function, I guess to say.
|
|
|
06/05/2013, 22:25
|
#15
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,383
|
Quote:
Originally Posted by Eteru
I have never even heard of, Lua, actually. Any example as to how it's actually used? Also, in regards to using INI files, I read someone say on the forums that it can take a lot of RAM to use INI files for a lot of other things? I was mainly looking for something that I can have the system check for me for stupid little mistakes like spacing, or maybe I didn't add a punctuation mark ie: ,";: etc. and for efficiency.
And I also thought maybe using C# would give me more "use" or function, I guess to say.
|
LUA is a scripting language. It's incredibly popular across many programs and my main experience with it would be commercial bots for large games such as guild wars 2, league of legends, etc.
INI files are just a way of structuring text documents so that they can be parsed easier. If you're writing INI 'scripts' you're really just writing your own little scripting language from scratch using a format that makes it easier to parse. INI is comparable to an XML document as far as purpose is concerned. Either would work very well for simple things like NPCS but it has no real 'logic' in and of itself, that's why you'd be better off using a scripting language if you were trying to write something more complex... such as monster AI using external scripts (lua would be ideal there)
The complaints about INI files and ram would be people loading the same document into memory and never disposing of it after. Therefor every time you use an NPC it would load another copy into memory. As such they start to feel that INI uses up a lot of ram when really it's just them mishandling it.
PS: LUA is quite simple to use. It's a pain to debug (in my opinion) but the actual syntax is easy. Any time I've used it I just use notepad++ for editing it. Works great for me.
Here's some example LUA from a script I wrote for the league of legends bot I mentioned to give you a taste (note, may be messy I suck with lua)
Code:
--[[Clear all elements created by ownerID (aka script ID)]]--
function RemoveObjectsByID(ownerID)
for x=#Windows,1,-1 do
for y=#Windows[x].children,1,-1 do
if Windows[x].children[y].ownerID == ownerID then
printtext("Removing child with Key: "..Windows[x].children[y].key.."\n")
table.remove(Windows[x].children, y)
end
end
if Windows[x].ownerID == ownerID then
printtext("Removing window with title: "..Windows[x].title.."\n")
table.remove(Windows, x)
end
end
end
function GetMouseState()
return {x=GetCursorX(), y=GetCursorY()}
end
function WindowContainsMouse(window,mouse)
return window.x < mouse.x
and window.x+window.width > mouse.x
and window.y < mouse.y
and window.y + 20 + #window.children*VerticalSpacing > mouse.y
end
function GetChildElementClicked(window,mouse)
return window.children[1+math.floor((mouse.y-window.y-20)/VerticalSpacing)]
end
|
|
|
 |
|
Similar Threads
|
[Python-Modul]EXP-Donator (kompatibel mit Python Loader)
11/23/2013 - Metin2 Hacks, Bots, Cheats, Exploits & Macros - 27 Replies
Moin,
da man mich danach gefragt hat und ich sowieso mal ein Beispiel für die Benutzung meines Python Loaders veröffentlichen wollte, habe ich die Gelegenheit genutzt und euch eben einen EXP-Spendebot geschrieben.
Man kann ihn einfach mit dem oben verlinkten Python Module Loader laden und ihn mit F5 aktivieren/deaktivieren.
Sobald ihr mehr als 99 Erfahrungspunkte habt (man kann nur in 100er Schritten spenden), werden alle Erfahrungspunkte an eure Gilde gespendet.
Wer Lust hat und...
|
Help to make a python file works with python loader
03/03/2013 - Metin2 - 2 Replies
Hey epvp! I want make a very. Little hack works on pythonn loader can anybody help me please?
|
Python
02/18/2013 - General Coding - 0 Replies
i make a program with python.
ciao--->Hi
Inserisci il primo numero---->1° number
Inserisci il secondo numero----->2°number
+ - * / options with button
thx :D
|
Metin2 - Python - Wie Python Hacks verschlüsseln und Server überprüfen (GF/PServe)
09/23/2012 - Metin2 - 2 Replies
Ich wollte fragen,
wie man Python Hacks am besten Verschlüsselt ?
und wie man feststellen kann ob man auf einem GF / Pserver spielt. ?
|
Python + Eric Python IDE installieren ?!
07/05/2011 - General Coding - 0 Replies
hat sich erledigt.
|
All times are GMT +2. The time now is 22:48.
|
|