void QueueScriptFunction(ScriptInstType sc_inst, const char *fn_name, size_t param_count, const RuntimeScriptValue &p1, const RuntimeScriptValue &p2) { if (inside_script) // queue the script for the run after current script is finished curscript->run_another (fn_name, sc_inst, param_count, p1, p2); else // if no script is currently running, run the requested script right away RunScriptFunction(sc_inst, fn_name, param_count, p1, p2); }
bool ReadScriptDescriptor::RunScriptFunction(const std::string& filename, const std::string& function_name, bool global) { // The error message handling is done into OpenFile() if (!OpenFile(filename)) return false; if (!DoesFunctionExist(function_name)) { PRINT_ERROR << "No '" << function_name << "' function!" << std::endl; CloseFile(); return false; } if (!global) OpenTablespace(); bool ran = RunScriptFunction(function_name); CloseFile(); return ran; }
void post_script_cleanup() { // should do any post-script stuff here, like go to new room if (ccError) quit(ccErrorString); ExecutingScript copyof = scripts[num_scripts-1]; // write_log("Instance finished."); if (scripts[num_scripts-1].forked) delete scripts[num_scripts-1].inst; num_scripts--; inside_script--; if (num_scripts > 0) curscript = &scripts[num_scripts-1]; else { curscript = NULL; } // if (abort_executor) user_disabled_data2=aborted_ip; int old_room_number = displayed_room; // run the queued post-script actions for (int ii = 0; ii < copyof.numPostScriptActions; ii++) { int thisData = copyof.postScriptActionData[ii]; switch (copyof.postScriptActions[ii]) { case ePSANewRoom: // only change rooms when all scripts are done if (num_scripts == 0) { new_room(thisData, playerchar); // don't allow any pending room scripts from the old room // in run_another to be executed return; } else curscript->queue_action(ePSANewRoom, thisData, "NewRoom"); break; case ePSAInvScreen: invscreen(); break; case ePSARestoreGame: cancel_all_scripts(); try_restore_save(thisData); return; case ePSARestoreGameDialog: restore_game_dialog(); return; case ePSARunAGSGame: cancel_all_scripts(); load_new_game = thisData; return; case ePSARunDialog: do_conversation(thisData); break; case ePSARestartGame: cancel_all_scripts(); restart_game(); return; case ePSASaveGame: save_game(thisData, copyof.postScriptSaveSlotDescription[ii]); break; case ePSASaveGameDialog: save_game_dialog(); break; default: quitprintf("undefined post script action found: %d", copyof.postScriptActions[ii]); } // if the room changed in a conversation, for example, abort if (old_room_number != displayed_room) { return; } } int jj; for (jj = 0; jj < copyof.numanother; jj++) { old_room_number = displayed_room; QueuedScript &script = copyof.ScFnQueue[jj]; RunScriptFunction(script.Instance, script.FnName, script.ParamCount, script.Param1, script.Param2); if (script.Instance == kScInstRoom && script.ParamCount == 1) { // some bogus hack for "on_call" event handler play.roomscript_finished = 1; } // if they've changed rooms, cancel any further pending scripts if ((displayed_room != old_room_number) || (load_new_game)) break; } copyof.numanother = 0; }