fysxasteroids/engine/VariablesCommands.cc

28 lines
553 B
C++

#include "Variables.h"
namespace Engine {
bool Cmd_Set (const std::vector<std::string> args) {
if (args.size() != 2) {
CommandSetErrorString ("Usage: set <name> <value>\nSets variables <name> to value <value>.");
return false;
}
Variable *test = GetVariable (args[0]);
if (test) {
test->SetStringValue (args[1]);
test->SetFloatValue (atof (args[1].c_str()));
return true;
}
CommandSetErrorString ("Variable '" + args[0] +"' not found!");
return false;
}
void Variables::OnRegisterCommands () {
AddCommand ("set", Cmd_Set);
}
}