12monkeys
Prince
I need some help for a specific problem. I try to implement the function CySelectionGroup.genereate(Path) into one of my mods. Here is the Python API definition of the function :
with the following explanation :
Problem now, is the last parameter "int*". I'm not able to do a call by reference of an int type with Python (or maybe I'm simply to stupid).
So, does anybody know how to do a call by reference of such a standard type?
Alternatively : is anybody able to write a small C lib, which we can import into our Python code, which can be used as an interface for that function?
The definition could be like this :
The return parameter is the number of PathTurn. If the function fails, it return -1. This should be an adequate replacement of the former bool return values.
That means, the lib could look like this :
(Sorry, its quite long ago that I wrote some C, so excuse my syntax and typos)
Is there anybody out there, who is able to write that tiny little lib????
EDIT :
sorry I forgot to mention, that the C function must be a method of the python class CySelectionGroup. I have no clue, how to do that in C.
Code:
BOOL generatePath(CyPlot pFromPlot, CyPlot pToPlot, INT iFlags,
BOOL bReuse, INT piPathTurns)
with the following explanation :
Code:
bool (CyPlot* pFromPlot, CyPlot* pToPlot, int iFlags,
bool bReuse, int* piPathTurns)
Problem now, is the last parameter "int*". I'm not able to do a call by reference of an int type with Python (or maybe I'm simply to stupid).
So, does anybody know how to do a call by reference of such a standard type?
Alternatively : is anybody able to write a small C lib, which we can import into our Python code, which can be used as an interface for that function?
The definition could be like this :
Code:
int (CyPlot* pFromPlot, CyPlot* pToPlot, int iFlags, bool bReuse, int iPathTurns)
The return parameter is the number of PathTurn. If the function fails, it return -1. This should be an adequate replacement of the former bool return values.
That means, the lib could look like this :
Code:
#include <Python.h>
import CoreLib.DLL // Civ4 Core Lib DLL. DOn't know if this call is right
int MyGeneratePath(PyObject *pFromPlot, PyObject *pToPlot, int iFlags, bool bReuse, int iPathTurns)
{
if (generatePath(pFromPlot, pToPlot, iFlags, bReuse, iPathTurns)) {
return iPathTurns;
} else {
return -1;
}
}
Is there anybody out there, who is able to write that tiny little lib????
EDIT :
sorry I forgot to mention, that the C function must be a method of the python class CySelectionGroup. I have no clue, how to do that in C.