From: <ave...@us...> - 2003-11-08 22:13:41
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs1:/tmp/cvs-serv25754/GUIScript Modified Files: GUIScript.cpp Log Message: Added GetRowIndex to the scripting interface Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** GUIScript.cpp 8 Nov 2003 17:19:25 -0000 1.38 --- GUIScript.cpp 8 Nov 2003 22:13:34 -0000 1.39 *************** *** 161,165 **** if((ret[0] >= '0') && (ret[0] <= '9')) { if(ret[1] == 'x') { ! int val; sscanf(ret, "0x%x", &val); return Py_BuildValue("i", val); --- 161,165 ---- if((ret[0] >= '0') && (ret[0] <= '9')) { if(ret[1] == 'x') { ! unsigned int val; sscanf(ret, "0x%x", &val); return Py_BuildValue("i", val); *************** *** 201,204 **** --- 201,221 ---- } + static PyObject * GemRB_GetTableRowIndex(PyObject */*self*/, PyObject *args) + { + int ti; + char *rowname; + + if(!PyArg_ParseTuple(args, "is", &ti, &rowname)) { + printMessage("GUIScript", "Syntax Error: GetTableRowIndex(TableIndex, RowName)\n", LIGHT_RED); + return NULL; + } + + TableMgr * tm = core->GetTable(ti); + if(tm == NULL) + return NULL; + int row = tm->GetRowIndex(rowname); + //no error if the row doesn't exist + return Py_BuildValue("i", row); + } static PyObject * GemRB_GetTableRowName(PyObject */*self*/, PyObject *args) { *************** *** 935,938 **** --- 952,958 ---- {"FindTableValue", GemRB_FindTableValue, METH_VARARGS, "Returns the first rowcount of a field of a 2DA Table."}, + + {"GetTableRowIndex", GemRB_GetTableRowIndex, METH_VARARGS, + "Returns the Index of a Row in a 2DA Table."}, {"GetTableRowName", GemRB_GetTableRowName, METH_VARARGS, |