MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / AddVariable

Function AddVariable

src/server/angelscript/samples/console/source/main.cpp:199–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199void AddVariable(asIScriptEngine *engine, string &arg)
200{
201 asIScriptModule *mod = engine->GetModule("console", asGM_CREATE_IF_NOT_EXISTS);
202
203 // Add a semi-colon to end the statement (if not already there)
204 if( arg.length() > 0 && arg[arg.length()-1] != ';' )
205 arg += ";";
206
207 int r = mod->CompileGlobalVar("addvar", arg.c_str(), 0);
208 if( r < 0 )
209 {
210 // TODO: Add better description of error (invalid declaration, name conflict, etc)
211 cout << "Failed to add variable. " << endl;
212 }
213 else
214 cout << "Variable added. " << endl;
215}
216
217void DeleteVariable(asIScriptEngine *engine, string &arg)
218{

Callers 1

mainFunction · 0.85

Calls 4

lengthMethod · 0.80
c_strMethod · 0.80
GetModuleMethod · 0.45
CompileGlobalVarMethod · 0.45

Tested by

no test coverage detected