Added new 'type' function, other mods

This commit is contained in:
2021-02-07 15:35:31 -05:00
parent 076daaa3a2
commit 8c15e56fe9
6 changed files with 64 additions and 28 deletions

View File

@@ -48,34 +48,23 @@ void LuaConsole::add(std::string line) {
raw_input_ += line;
raw_input_ += '\n';
lines_ += 1;
char cmd = raw_input_[0];
// All commands are a single character.
if ((raw_input_[1] != ' ')&&(raw_input_[1] != '\n')) {
action_ = DO_SYNTAX;
syntax_ = "Commands are a single character followed by arguments";
return;
}
// Analyze non-lua commands.
if ((cmd != 'r') && (cmd != 'l')) {
lua_expression_ = "";
if (lines_ == 1) {
// Try to interpret it as a special command.
if (lines_ == 1) {
split_words();
if ((words_.size() >= 1)&&(words_[0].size() == 1)) {
action_ = DO_COMMAND;
split_words();
} else {
action_ = DO_SYNTAX;
syntax_ = "slash command has more than one line";
return;
}
return;
}
words_.clear();
// Strip the leading punctuation from lua commands.
std::string partial;
if (cmd == 'r') {
partial = std::string("return ") + raw_input_.substr(2);
if (raw_input_[0] == '=') {
partial = std::string("return ") + raw_input_.substr(1);
} else {
partial = raw_input_.substr(2);
partial = raw_input_;
}
// Analyze lua expressions.