| 37 | string p_name = "player"; |
| 38 | |
| 39 | int main(int argc, char **argv) |
| 40 | { |
| 41 | // Create the script engine |
| 42 | asIScriptEngine *engine = asCreateScriptEngine(); |
| 43 | if( engine == 0 ) |
| 44 | { |
| 45 | cout << "Failed to create script engine." << endl; |
| 46 | return -1; |
| 47 | } |
| 48 | |
| 49 | // Configure the script engine with all the functions, |
| 50 | // and variables that the script should be able to use. |
| 51 | ConfigureEngine(engine); |
| 52 | |
| 53 | // Print some useful information and start the input loop |
| 54 | cout << "Sample console using AngelScript " << asGetLibraryVersion() << " to perform scripted tasks." << endl; |
| 55 | cout << "Type 'help' for more information." << endl; |
| 56 | |
| 57 | // TODO: Allow multiple lines per command by ending each line with a backslash. |
| 58 | |
| 59 | for(;;) |
| 60 | { |
| 61 | string input; |
| 62 | input.resize(256); |
| 63 | string cmd, arg; |
| 64 | |
| 65 | cout << "> "; |
| 66 | cin.getline(&input[0], 256); |
| 67 | |
| 68 | // Trim unused characters |
| 69 | input.resize(strlen(input.c_str())); |
| 70 | |
| 71 | size_t pos; |
| 72 | if( (pos = input.find(" ")) != string::npos ) |
| 73 | { |
| 74 | cmd = input.substr(0, pos); |
| 75 | arg = input.substr(pos+1); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | cmd = input; |
| 80 | arg = ""; |
| 81 | } |
| 82 | |
| 83 | // Interpret the command |
| 84 | if( cmd == "exec" ) |
| 85 | ExecString(engine, arg); |
| 86 | else if( cmd == "addfunc" ) |
| 87 | AddFunction(engine, arg); |
| 88 | else if( cmd == "delfunc" ) |
| 89 | DeleteFunction(engine, arg); |
| 90 | else if( cmd == "addvar" ) |
| 91 | AddVariable(engine, arg); |
| 92 | else if( cmd == "delvar" ) |
| 93 | DeleteVariable(engine, arg); |
| 94 | else if( cmd == "help" ) |
| 95 | PrintHelp(); |
| 96 | else if( cmd == "listfuncs" ) |
nothing calls this directly
no test coverage detected