From 9fffbb88da1062911c42146f4e9022a045177f75 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 2 Mar 2011 15:43:20 -0500 Subject: [PATCH] console things, set commands use keywords for arguments. --- build/example.py | 10 + build/tpt_console.py | 108 +++++ console_README | 47 ++ getheader.py | 13 + includes/interface.h | 2 +- src/interface.c | 58 ++- src/main.c | 1103 ++++++++++++++++++++++++------------------ 7 files changed, 869 insertions(+), 472 deletions(-) create mode 100644 build/example.py create mode 100644 build/tpt_console.py create mode 100644 console_README create mode 100644 getheader.py diff --git a/build/example.py b/build/example.py new file mode 100644 index 000000000..826b3dfdb --- /dev/null +++ b/build/example.py @@ -0,0 +1,10 @@ +import tpt +import random +import time +# example script + +def noise(typ,amount=50): + for xx in range(4,612): + for yy in range(4,384): + if(random.randrange(0,100) at , + tpt.reset_velocity() resets all velocity + tpt.reset_pressure() resets all pressure + tpt.reset_sparks() resets all sparks + tpt.set_life(type,life) sets the life of all particles with type + to (set to -1 for all) + tpt.set_type(type1,type2) sets the type of all particles with type + to (set to -1 for all) + tpt.set_temp(type,temp) sets the temp of all particles with type + to (set to -1 for all) + tpt.set_tmp(type,tmp) sets the tmp of all particles with type + to (set to -1 for all) + tpt.set_x(type,x) sets the x of all particles with type + to (set to -1 for all) + tpt.set_y(type,y) sets the y of all particles with type + to (set to -1 for all) + tpt.set_vx(type,vx) sets the vx of all particles with type + to (set to -1 for all) + tpt.set_vy(type,vy) sets the vy of all particles with type + to (set to -1 for all) + tpt.set_ctype(type,ctype) sets the ctype of all particles with type + to (set to -1 for all) + tpt.pause() pause the game(note that closing the console + pauses the game) + tpt.unpause() unpause the game(note that closing the console + pauses the game) + tpt.toggle_pause() toggle pause(note that closing the console + pauses the game) + tpt.close_console() closes the console and pauses the game + tpt.open_console() opens the console + tpt.toggle_console() toggles the console + +NOTE: these functions don't do bounds checking, which means that they CAN AND + WILL CRASH the powder toy. be carefull. + +### TIPS&TRICKS ### +all functions that need a particle type expect a number. but instead of doing +tpt.set_life(32,life) you can do tpt.set_life(element['uran'],life) + +### COMPILING ### +before you compile you should have python 2.x installed. +you must run the "getheader.py" script to get the correct linking options, add +these options to the makefile \ No newline at end of file diff --git a/getheader.py b/getheader.py new file mode 100644 index 000000000..558726c4f --- /dev/null +++ b/getheader.py @@ -0,0 +1,13 @@ +import sys +import os.path +path=os.path.join(sys.exec_prefix,"include","python%s"%sys.version[:3]) +#print "headers at ",repr(path) +#-lpython2.3 -lm -L/usr/lib/python2.3/config +args="-lpython%s -lm -L%s"%(sys.version[:3],os.path.join(sys.exec_prefix,"lib","python%s"%sys.version[:3],"config")) +print " linux args are" +print args,"-I%s"%path + +path=os.path.join(sys.exec_prefix,"include") +args="-lpython%s -lm -L%s"%(sys.version[:3],os.path.join(sys.exec_prefix,"lib","config"))#,"python%s"%sys.version[:3] +print "\n windows args are" +print args,"-I%s"%path \ No newline at end of file diff --git a/includes/interface.h b/includes/interface.h index ea1f9a5be..d63770afd 100644 --- a/includes/interface.h +++ b/includes/interface.h @@ -225,7 +225,7 @@ void open_link(char *uri); int report_ui(pixel *vid_buf, char *save_id); -char *console_ui(pixel *vid_buf, char error[255]); +char *console_ui(pixel *vid_buf, char error[255],char console_more); int console_parse_coords(char *txt, int *x, int *y, char *err); int console_parse_type(char *txt, int *element, char *err); int console_parse_partref(char *txt, int *which, char *err); diff --git a/src/interface.c b/src/interface.c index 5e8eed45f..07355a45f 100644 --- a/src/interface.c +++ b/src/interface.c @@ -3839,13 +3839,15 @@ struct command_history { }; typedef struct command_history command_history; command_history *last_command = NULL; -char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands +command_history *last_command2 = NULL; +char *console_ui(pixel *vid_buf,char error[255],char console_more) { int mx,my,b,cc,ci = -1; pixel *old_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); command_history *currentcommand; + command_history *currentcommand2; ui_edit ed; ed.x = 15; - ed.y = 210; + ed.y = 207; ed.w = XRES; ed.nx = 1; ed.def = ""; @@ -3854,9 +3856,19 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show ed.hide = 0; ed.multiline = 0; ed.cursor = 0; + //fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190); memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); fillrect(old_buf, -1, -1, XRES, 220, 0, 0, 0, 190); - + currentcommand2 = malloc(sizeof(command_history)); + memset(currentcommand2, 0, sizeof(command_history)); + currentcommand2->prev_command = last_command2; + currentcommand2->command = mystrdup(error); + last_command2 = currentcommand2; + cc = 0; + while(cc < 80){ + fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2)); + cc++; + } while (!sdl_poll()) { b = SDL_GetMouseState(&mx, &my); @@ -3866,11 +3878,10 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show //clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent? memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE); - draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE); - drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.3 (by cracker64)\n" - "Current commands are quit, set, reset, load, create, file, kill, sound\n" //TODO: help command - ,255, 187, 187, 255); - + draw_line(vid_buf, 0, 219, XRES+BARSIZE-1, 219, 228, 228, 228, XRES+BARSIZE); + drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)" //TODO: help command + ,255, 255, 255, 255); + cc = 0; currentcommand = last_command; while(cc < 10) @@ -3893,9 +3904,36 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show break; } } + cc = 0; + currentcommand2 = last_command2; + while(cc < 10) + { + if(currentcommand2==NULL) + break; + drawtext(vid_buf, 215, 175-(cc*12), currentcommand2->command, 255, 225, 225, 255); + if(currentcommand2->prev_command!=NULL) + { + if(cc<9) { + currentcommand2 = currentcommand2->prev_command; + } else if(currentcommand2->prev_command!=NULL) { + free(currentcommand2->prev_command); + currentcommand2->prev_command = NULL; + } + cc++; + } + else + { + break; + } + } - if(error) - drawtext(vid_buf, 15, 190, error,255, 187, 187, 255); + //if(error && ed.str[0]=='\0') + //drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200); + if(console_more==0) + drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240); + else + drawtext(vid_buf, 5, 207, "...", 255, 255, 255, 240); + ui_edit_draw(vid_buf, &ed); ui_edit_process(mx, my, b, &ed); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); diff --git a/src/main.c b/src/main.c index 178a38b13..782625561 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "Python.h" #include #include #include @@ -1174,6 +1175,565 @@ char my_uri[] = "http://" SERVER "/Update.api?Action=Download&Architecture=" "SSE" #endif ; + + +char console_error[255] = ""; + +/* + * PYTHON FUNCTIONS + * instructions on making a function callable from python: + * first you make a function that accepts (PyObject *self, PyObject *args) as arguments + * then you use PyArg_ParseTuple to parse the arguments, handle everything the function should do. + * register the function by adding a line to static PyMethodDef EmbMethods[] = { + * the line should look like this: + * {"PyFunctionname", Functionname, METH_VARARGS,"short help string"}, + * for more information on the PyWhatever functions look here: + * http://docs.python.org/extending/extending.html + */ + +//functions callable from python: +static PyObject* +emb_create(PyObject *self, PyObject *args) +{ + int x,y,t; + if(!PyArg_ParseTuple(args, "III:create",&x,&y,&t)) + return NULL; + // + return Py_BuildValue("i",create_part(-1,x,y,t)); +} +//sys_pause = !sys_pause +emb_pause(PyObject *self, PyObject *args) +{ + int x,y,t; + if(!PyArg_ParseTuple(args, ":unpause")) + return NULL; + // + sys_pause=1; + return Py_BuildValue("i",1); +} + +emb_unpause(PyObject *self, PyObject *args) +{ + int x,y,t; + if(!PyArg_ParseTuple(args, ":pause")) + return NULL; + // + sys_pause=0; + return Py_BuildValue("i",1); +} + +emb_toggle_pause(PyObject *self, PyObject *args) +{ + int x,y,t; + if(!PyArg_ParseTuple(args, ":toggle_pause")) + return NULL; + // + sys_pause=!sys_pause; + return Py_BuildValue("i",1); +} + +//console_mode + +emb_toggle_console(PyObject *self, PyObject *args) +{ + int x,y,t; + if(!PyArg_ParseTuple(args, ":toggle_console")) + return NULL; + // + console_mode=!console_mode; + return Py_BuildValue("i",1); +} + +emb_open_console(PyObject *self, PyObject *args) +{ + int x,y,t; + if(!PyArg_ParseTuple(args, ":toggle_console")) + return NULL; + // + console_mode=1; + return Py_BuildValue("i",1); +} + +emb_close_console(PyObject *self, PyObject *args) +{ + int x,y,t; + if(!PyArg_ParseTuple(args, ":toggle_console")) + return NULL; + // + console_mode=0; + return Py_BuildValue("i",1); +} + + +emb_log(PyObject *self, PyObject *args) +{ + char *buffer; + if(!PyArg_ParseTuple(args, "s:log",&buffer)) + return NULL; + // + strcpy(console_error,buffer); + puts(buffer); + return Py_BuildValue("i",1); +} + +char console_more=0; + +emb_console_more(PyObject *self, PyObject *args) +{ + if(!PyArg_ParseTuple(args, ":log")) + return NULL; + // + console_more=1; + return Py_BuildValue("i",1); +} + +emb_console_less(PyObject *self, PyObject *args) +{ + if(!PyArg_ParseTuple(args, ":log")) + return NULL; + // + console_more=0; + return Py_BuildValue("i",1); +} + +//drawtext(vid_buf, 15, 175-(cc*12), currentcommand->command, 255, 255, 255, 255); + + +emb_reset_pressure(PyObject *self, PyObject *args) +{ + if(!PyArg_ParseTuple(args, ":reset_pressure")) + return NULL; + // + for (int nx = 0; nx=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].life = life; + } + return Py_BuildValue("i",1); +} + +emb_set_type(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *type = ""; + char *kwlist[] = {"totype", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "s|sIII:set_type",kwlist ,&type,&name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + console_parse_type(type, &life, console_error); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].type = life; + } + return Py_BuildValue("i",1); +} + +emb_set_temp(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *kwlist[] = {"totemp", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].temp = life; + } + return Py_BuildValue("i",1); +} + +emb_set_tmp(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *kwlist[] = {"totmp", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].tmp = life; + } + return Py_BuildValue("i",1); +} + +emb_set_x(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *type = ""; + char *kwlist[] = {"tox", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].x = life; + } + return Py_BuildValue("i",1); +} + +emb_set_y(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *kwlist[] = {"toy", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].y = life; + } + return Py_BuildValue("i",1); +} + +emb_set_ctype(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *type = ""; + char *kwlist[] = {"toctype", "toctypeint", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "s|IsIII:set_type",kwlist ,&type, &life, &name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + if(!life) + console_parse_type(type, &life, console_error); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].ctype = life; + } + return Py_BuildValue("i",1); +} + +emb_set_vx(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *kwlist[] = {"tovx", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].vx = life; + } + return Py_BuildValue("i",1); +} + +emb_set_vy(PyObject *self, PyObject *args, PyObject *keywds) +{ + int i = -1,life,j,x=-1,y=-1; + char *name = ""; + char *kwlist[] = {"tovy", "from", "i", "x", "y", NULL}; + if(!PyArg_ParseTupleAndKeywords(args, keywds, "I|sIII:set_type",kwlist ,&life,&name,&i,&x,&y)) + return NULL; + // + if(strcmp(name,"")==0 && x==-1 && y==-1 && i==-1) + return Py_BuildValue("s","Need more args(coords,i,or a particle name)"); + if(strcmp(name,"all")==0) + { + for(i=0; i=0 && x=0 && y>8].type != PT_NONE) + parts[pmap[y][x]>>8].vy = life; + } + return Py_BuildValue("i",1); +} + +static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here! + {"create", emb_create, METH_VARARGS, "create a particle."}, + {"log", emb_log, METH_VARARGS, "logs an error string to the console."}, + {"reset_pressure", emb_reset_pressure, METH_VARARGS, "resets all the pressure."}, + {"reset_velocity", emb_reset_velocity, METH_VARARGS, "resets all the velocity."}, + {"reset_sparks", emb_reset_sparks, METH_VARARGS, "resets all the sparks."}, + {"set_life", emb_set_life, METH_VARARGS|METH_KEYWORDS, "sets life of a specified particle."}, + {"set_type", emb_set_type, METH_VARARGS|METH_KEYWORDS, "sets type of a specified particle."}, + {"set_temp", emb_set_temp, METH_VARARGS|METH_KEYWORDS, "sets temp of a specified particle."}, + {"set_tmp", emb_set_tmp, METH_VARARGS|METH_KEYWORDS, "sets tmp of a specified particle."}, + {"set_x", emb_set_x, METH_VARARGS|METH_KEYWORDS, "sets x of a specified particle."}, + {"set_y", emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets y of a specified particle."}, + {"set_ctype", emb_set_y, METH_VARARGS|METH_KEYWORDS, "sets ctype of a specified particle."}, + {"set_vx", emb_set_vx, METH_VARARGS|METH_KEYWORDS, "sets vx of a specified particle."}, + {"set_vy", emb_set_vy, METH_VARARGS|METH_KEYWORDS, "sets vy of a specified particle."}, + {"pause", emb_pause, METH_VARARGS, "pause the game."}, + {"unpause", emb_unpause, METH_VARARGS, "unpause the game."}, + {"toggle_pause", emb_toggle_pause, METH_VARARGS, "toggle game pause."}, + {"open_console", emb_open_console, METH_VARARGS, "open the game console."}, + {"close_console", emb_close_console, METH_VARARGS, "close the game console."}, + {"toggle_console", emb_toggle_console, METH_VARARGS, "toggle the game console."}, + {"console_more", emb_console_more, METH_VARARGS, "turns the more indicator on."}, + {"console_less", emb_console_less, METH_VARARGS, "turns the more indicator off."}, + {NULL, NULL, 0, NULL} +}; + int main(int argc, char *argv[]) { int hud_enable = 1; @@ -1192,7 +1752,7 @@ int main(int argc, char *argv[]) void *http_ver_check; void *http_session_check = NULL; char *ver_data=NULL, *check_data=NULL, *tmp; - char console_error[255] = ""; + //char console_error[255] = ""; int i, j, bq, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, old_ver_len; #ifdef INTERNAL int vs = 0; @@ -1207,6 +1767,7 @@ int main(int argc, char *argv[]) SDL_AudioSpec fmt; int username_flash = 0, username_flash_t = 1; GSPEED = 1; + PyObject *pname,*pmodule,*pfunc,*pvalue,*pargs; /* Set 16-bit stereo audio at 22Khz */ fmt.freq = 22050; @@ -1216,6 +1777,44 @@ int main(int argc, char *argv[]) fmt.callback = mixaudio; fmt.userdata = NULL; + //initialise python console + Py_Initialize(); + Py_InitModule("tpt", EmbMethods); + //change the path to find all the correct modules + PyRun_SimpleString("import sys\nsys.path.append('.')"); + PyRun_SimpleString("print 'python present.'"); + //load the console module and whatnot + pname=PyString_FromString("tpt_console");//create string object + pmodule = PyImport_Import(pname);//import module + if(pmodule!=NULL) + { + Py_DECREF(pname);//throw away the string object + pfunc=PyObject_GetAttrString(pmodule,"handle");//get the handler function + if(pfunc && PyCallable_Check(pfunc))//check if it's really a function + { + //it is + printf("python console ready to go.\n"); + /*pargs=Py_BuildValue("(s)","test"); + pvalue = PyObject_CallObject(pfunc, pargs); + Py_DECREF(pargs); + pargs=NULL; + //Py_DECREF(pvalue); + //puts("a"); + pvalue=NULL;*/ + } + else + { + //oops! mangled console.py? + printf("unable to find handle function, mangled console.py?\n"); + return -1; + } + } + else + { + printf("unable to find console module, missing file?\n"); + return -1; + } + #ifdef MT numCores = core_count(); #endif @@ -1910,23 +2509,6 @@ int main(int argc, char *argv[]) }*/ } } - if(console_mode) - { - char *console; - //char error[255] = "error!"; - sys_pause = 1; - console = console_ui(vid_buf,console_error); - console = mystrdup(console); - strcpy(console_error,""); - if(process_command(vid_buf,console,&console_error)==-1) - { - free(console); - break; - } - free(console); - if(!console_mode) - hud_enable = 1; - } bq = b; b = SDL_GetMouseState(&x, &y); @@ -2745,7 +3327,27 @@ int main(int argc, char *argv[]) } fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, 140); drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, 200); + } + + if(console_mode) + { + char *console; + //char error[255] = "error!"; + sys_pause = 1; + console = console_ui(vid_buf,console_error,console_more); + console = mystrdup(console); + strcpy(console_error,""); + if(process_command(vid_buf,console,&console_error,pfunc)==-1) + { + free(console); + break; + } + free(console); + if(!console_mode) + hud_enable = 1; + } + sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE); //Setting an element for the stick man @@ -2767,9 +3369,16 @@ int main(int argc, char *argv[]) } SDL_CloseAudio(); http_done(); + //make sure no threads are blocking us + //fork_unblock + pargs=Py_BuildValue("(s)","fork_unblock()");//this deamonises all threads. + pvalue = PyObject_CallObject(pfunc, pargs); + Py_DECREF(pargs); + pargs=NULL; + Py_Finalize();//cleanup any python stuff. return 0; } -int process_command(pixel *vid_buf,char *console,char *console_error) { +int process_command(pixel *vid_buf,char *console,char *console_error,PyObject *pfunc) { int y,x,nx,ny,i,j,k,m; int do_next = 1; char xcoord[10]; @@ -2778,6 +3387,7 @@ int process_command(pixel *vid_buf,char *console,char *console_error) { char console3[15]; char console4[15]; char console5[15]; + PyObject *pvalue,*pargs; //sprintf(console_error, "%s", console); if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0) { @@ -2786,449 +3396,20 @@ int process_command(pixel *vid_buf,char *console,char *console_error) { { return -1; } - else if(strcmp(console2, "file")==0 && console3) - { - if(file_script){ - FILE *f=fopen(console3, "r"); - if(f) - { - char fileread[5000];//TODO: make this change with file size - char pch[5000]; - char tokens[10]; - int tokensize; - nx = 0; - ny = 0; - j = 0; - m = 0; - if(console4) - console_parse_coords(console4, &nx , &ny, console_error); - memset(pch,0,sizeof(pch)); - memset(fileread,0,sizeof(fileread)); - fread(fileread,1,5000,f); - for(i=0; i