only print Lua command result if it's not null
This commit is contained in:
parent
f95fbc3a37
commit
9e7a2e9bb9
@ -21,6 +21,8 @@ command("run", function(src)
|
||||
local success, result = pcall(result)
|
||||
if not success then
|
||||
return "^#f00;error: " .. result
|
||||
elseif result == nil then
|
||||
return nil
|
||||
else
|
||||
local success, printed = pcall(sb.printJson, result)
|
||||
if not success then
|
||||
|
@ -91,9 +91,12 @@ StringList ClientCommandProcessor::handleCommand(String const& commandLine) {
|
||||
}
|
||||
} else {
|
||||
auto player = m_universeClient->mainPlayer();
|
||||
if (auto messageResult = player->receiveMessage(connectionForEntity(player->entityId()), "/" + command, { allArguments }))
|
||||
result.append(messageResult->isType(Json::Type::String) ? *messageResult->stringPtr() : messageResult->repr(1, true));
|
||||
else
|
||||
if (auto messageResult = player->receiveMessage(connectionForEntity(player->entityId()), "/" + command, {allArguments})) {
|
||||
if (messageResult->isType(Json::Type::String))
|
||||
result.append(*messageResult->stringPtr());
|
||||
else if (!messageResult->isNull())
|
||||
result.append(messageResult->repr(1, true));
|
||||
} else
|
||||
m_universeClient->sendChat(commandLine, ChatSendMode::Broadcast);
|
||||
}
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user