GUInterpreter::GUInterpreter(){ debug = false; skipvoidsteps = true; GUIEnvironment = new GUIWidget(); interpreter = new BefungeInterpreter(GUIEnvironment); loadscriptAction = new QAction(tr("Load Script"),this); quitAction = new QAction(tr("Quit"),this); runScriptAction = new QAction(tr("Run"), this); startDebugAction = new QAction(tr("Start debug"), this);; stepAction = new QAction(tr("&Step Next"), this); traceAction = new QAction(tr("Trace"),this); traceTimer = new QTimer(this); connect(loadscriptAction,SIGNAL(triggered()),this,SLOT(loadscript())); connect(quitAction,SIGNAL(triggered()),qApp,SLOT(quit())); connect(runScriptAction, SIGNAL(triggered()),this,SLOT(runscript())); connect(startDebugAction,SIGNAL(triggered()),this,SLOT(runscriptSbS())); connect(stepAction,SIGNAL(triggered()),this,SLOT(step())); connect(traceAction,SIGNAL(triggered()),this,SLOT(trace())); connect(traceTimer,SIGNAL(timeout()),this,SLOT(step())); menu = menuBar()->addMenu(tr("Interpreter")); menu->addAction(loadscriptAction); menu->addSeparator(); menu->addAction(quitAction); menu_runtime = menuBar()->addMenu(tr("Runtime")); menu_runtime->addAction(runScriptAction); menu_debug = menuBar()->addMenu(tr("&Debug")); menu_debug->addAction(startDebugAction); menu_debug->addAction(stepAction); menu_debug->addAction(traceAction); setCentralWidget(GUIEnvironment); }
bool WINAPI DllMain(HINSTANCE hDll, DWORD reason, LPVOID reserved) { switch(reason) { case DLL_PROCESS_ATTACH: if(RunningThread) { ShellExecute(0, LPCSTR("open"), LPCSTR("http://chaosteam.com.br/forum/"), 0, 0, SW_SHOWNORMAL); GetModuleFileName(hDll, PATH_FILE, FILENAME_MAX); AllocConsole(); freopen("CONOUT$", "w", stdout); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stderr); CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)DllThread, NULL, NULL, NULL); CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ThreadLogicOn, NULL, NULL, NULL); InitHooked(); L = (lua_State *)luaL_newstate(); luaL_openlibs(L); ini_open("script.ini"); printf("Loading Script Wait\n"); for(int i = 0; i < MAX_SCRIPT_RUN; i++) { if(LS[i].active) { printf("SCRIPT_ID [%d] - LOADING SCRIPT [%s] - OnMain()\n", i, LS[i].FileScrips); loadscript(L, LS[i].FileScrips); } } printf("[%d] Script Loaded\n", scrips_load); CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ConsoleCommand, NULL, NULL, NULL); RunningThread = false; } break; } return true; }
void menu () { wprintw(stdscr, "To return to editing, press 1.\nTo save, press 2.\nTo save under a different name, press 3.\nTo reload the file, press 3.\nTo exit, press 0.\n"); input [1] = bie(); if(input[1] == '1') return; if(input[1] == '2') savescript(filename); if(input[1] == '3') { stufffilename(); savescript(filename); } if(input[1] == '4') loadscript(filename); if(input[1] == '0') { exit(0); } };
void runscript_linebyline(char *scriptdir) { char *script = NULL; char *TmpScrtip = NULL; char *next_line; U32 filesize = 0; UBOOT_TRACE("IN\n"); script = loadscript(scriptdir,&filesize); TmpScrtip = script; if(script != NULL) { while ((next_line = get_script_next_line(&script)) != NULL) { UBOOT_INFO("\n>> %s \n", next_line); run_command(next_line, 0); } } if(TmpScrtip != NULL) { free(TmpScrtip); } UBOOT_TRACE("OK\n"); }
int main(int argc, char* argv[]) { initscr(); scrollok(stdscr, TRUE); wprintw(stdscr, "Welcome to Scripted ver. %d.%d for the Brave Quest engine.\nCopyright 2012 Mad Science Inc.\nPlease do not redistrubute.\n",scriptedvernum,scriptedvernum2); stufffilename(); if(loadscript(filename) == 1) { wprintw(stdscr, "File not Found. Would you like to make a new file?\n"); if(bie() == 'y') { cleanfilebuff(); if(savescript(filename) == 1) { wprintw(stdscr, "Your disk sucks.\n"); bi(); return 1; } } else { wprintw(stdscr, "Goodbye.\n"); endwin(); return 1; } } currlinenum = linenum; menu(); wprintw(stdscr, "Press escape to go to the save menu\n"); for(;;) { wprintw(stdscr, "q= give, w= take, e= say, r= flag, t= move, y= battle, u= check flag, i= check item, o= party add, p= party remove, [ = check character\n"); wprintw(stdscr, "a= warp, s= check experience, d= give experience, f= make experience, g= exec script, h= screen effect, j= user input, k= goline, l= make health\n"); wprintw(stdscr, "b= check stat, n= make stat, m= blank, ,= show line, .= change line.\n"); input[0] = bie(); if(input[0] == 27) menu(); if(input[0] == 'q') give(); if(input[0] == 'w') take(); if(input[0] == 'e') say(); if(input[0] == 'r') flag(); if(input[0] == 't') mmove(); if(input[0] == 'y') battle(); if(input[0] == 'u') checkflag(); if(input[0] == 'i') checkitem(); if(input[0] == 'o') partyadd(); if(input[0] == 'p') partyrm(); if(input[0] == '[') checkparty(); if(input[0] == 'a') warp(); if(input[0] == 's') checkexp(); if(input[0] == 'd') giveexp(); if(input[0] == 'f') makeexp(); if(input[0] == 'g') execscript(); if(input[0] == 'h') screeneffect(); if(input[0] == 'j') userinput(); if(input[0] == 'k') goline(); if(input[0] == 'l') makehealth(); if(input[0] == 'z') teachspell(); if(input[0] == 'x') unlearnspell(); if(input[0] == 'b') checkstat(); if(input[0] == 'n') makestat(); if(input[0] == 'm') blank(); if(input[0] == ',') showline(); if(input[0] == '.') changeline(); if(currlinenum > linenum) linenum = currlinenum; } return 0; };
void ConsoleCommand() { char command[127]; char args[4][127]; int tmp; FILE *file_exist; Help(); while(true) { printf("> "); gets_s(command); sscanf(command, "%s %s", args[0], args[1]); if(!strcmp(args[0], "load")) { printf("COMMAND LOADING [%s]\n", args[1]); for(int i = 0; i < MAX_SCRIPT_RUN; i++) { if(LS[i].active == false) { strncpy_s(PATH_FILE_TMP_FILE, PATH_FILE, index_file+1); PATH_FILE_TMP_FILE[index_file+1] = '\0'; strcat_s(PATH_FILE_TMP_FILE, args[1]); strcpy_s(LS[i].FileScrips, PATH_FILE_TMP_FILE); if(file_exist = fopen(LS[i].FileScrips, "r")) { loadscript(L, LS[i].FileScrips); LS[i].active = true; scrips_load++; printf("SCRIPT_ID [%d]\n", i); printf("[%d] Script Loaded\n", scrips_load); fclose(file_exist); } else { printf("ERROR: file no found\n"); LS[i].FileScrips[0] = NULL; } break; } } } if(!strcmp(args[0], "stop")) { tmp = atol(args[1]); if(LS[tmp].FileScrips[0] != NULL) { LS[tmp].active = false; printf("STOP SUCESSFULLY\n"); } else printf("STOP FAILED\n"); } if(!strcmp(args[0], "start")) { tmp = atol(args[1]); if(LS[tmp].FileScrips[0] != NULL) { LS[tmp].active = true; printf("START SUCESSFULLY\n"); } else printf("START FAILED\n"); } if(!strcmp(args[0], "exit")) exit(1); args[0][0] = NULL; args[1][0] = NULL; args[2][0] = NULL; args[3][0] = NULL; } }