0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Python Plugin for C-Script
#21612
12/30/03 07:49
12/30/03 07:49
|
Joined: Mar 2002
Posts: 1,123 California
Cellulaer
OP
Expert
|
OP
Expert
Joined: Mar 2002
Posts: 1,123
California
|
First Beta version of GSPython.dll is now available. You can write Python code inside your c-script files. At the moment the only thing you can pass back and forth between Python and Acknex are strings. Any feedback would be appreciated. Download Now Example: Code:
include <gspython.wdl>;
// Define a string for you to use. I default it to 1000 characters here. string MyPythonString[1000];
text python_txt {
layer = 1; pos_x = 50; pos_y = 50; strings = 1; font = standard_font; string = MyPythonString; alpha = 100; flags = narrow, transparent, visible;
}
function EvaluatePython() { dll_handle = dll_open("GSPython.dll"); // Fill our test string with something str_cpy(MyPythonString,"123");
// Create and Initialize the Python Engine Python_Init();
// Link MyPythonString to a string variable defined in Python named AckNexStr. // Changes to one effect changes to the other. Python_LinkStr("AckNexStr",MyPythonString); // Evaluate code. Python("
# Print goes nowhere right now print 2+2
# Test the Acknex<->Python string interface AckNexStr.Value = AckNexStr.Value + '456' + AckNexStr.Value
");
// Free the Python Engine Python_Free(); dll_close(dll_handle); }
|
|
|
Re: Python Plugin for C-Script
[Re: Orange Brat]
#21614
12/30/03 08:21
12/30/03 08:21
|
Joined: Mar 2002
Posts: 1,123 California
Cellulaer
OP
Expert
|
OP
Expert
Joined: Mar 2002
Posts: 1,123
California
|
I don't know the Python language either. However, from what I've seen it does give you a lot of options for accessing databases, the file system, data processing, data manipulation, OS information, etc. If you already knew Python it would probably be useful verses having to learn c-script (if/when I get the other Acknex objects accessable via the plugin in Python). Bottom line is that it gives you a lot of the power of C++ or Object Pascal in a scripting language embedded in c-script.
Another example would be that I also have an Object Pascal plugin which functions similarly to the Python plugin (has an Object Pascal interpreter). Personally since I program in Object Pascal all the time it is most benificially to be able to write Object Pascal script right inside my c-script files. I ran read/write INI files, the registry, and whatever else I can think of without having to re-compile a DLL every time. Plus there is support for types, classes, and objects.
Lastly with both languages in the above examples it would allow the user to easily MOD source code for whatever game you distributed (if you allowed them to) via a standardized language. You could have a group of effects files written in Python and the user could add their own effects files (I don't know if c-script can be used in this fashion at design time).
Implimenting Python was requested by a couple users so it wasn't more than the work of a few hours to do.
|
|
|
Re: Python Plugin for C-Script
[Re: clone45]
#21617
12/30/03 11:47
12/30/03 11:47
|
Joined: Mar 2002
Posts: 1,123 California
Cellulaer
OP
Expert
|
OP
Expert
Joined: Mar 2002
Posts: 1,123
California
|
Delphi has a Python interface available for it here. I haven't as of yet seen a Perl interface for Delphi. I'm currently working on implimenting Python access to Entities.
|
|
|
Re: Python Plugin for C-Script
[Re: Cellulaer]
#21620
01/14/04 08:27
01/14/04 08:27
|
Joined: Mar 2002
Posts: 1,123 California
Cellulaer
OP
Expert
|
OP
Expert
Joined: Mar 2002
Posts: 1,123
California
|
Released GSPython v0.91 *BETA*
Added the ability to link Acknex Entities and Particle as Python objects. You can also call custom WDL functions from inside Python.
dllfunction Python_LinkEnt(VarName, VarEntity);
// VarName is the name of the Python variable you are creating.
// VarEntity is the Acknex entity you are linking it to.
// Everything is support except .link.
// Access .min[0..2] with .min0, .min1, .min2
// Access .max[0..2] with .max0, .max1, .max2
// Access .skill[1..48] with .skill1, .skill2, etc.
dllfunction Python_LinkPar(VarName, VarParticle);
// VarName is the name of the Python variable you are creating.
// VarParticle is the Acknex particle you are linking it to.
// Everything is support except .link. and .bmap
// Access .skill[1..4] with .skill1, .skill2, etc.
|
|
|
|