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)
|
local success, result = pcall(result)
|
||||||
if not success then
|
if not success then
|
||||||
return "^#f00;error: " .. result
|
return "^#f00;error: " .. result
|
||||||
|
elseif result == nil then
|
||||||
|
return nil
|
||||||
else
|
else
|
||||||
local success, printed = pcall(sb.printJson, result)
|
local success, printed = pcall(sb.printJson, result)
|
||||||
if not success then
|
if not success then
|
||||||
|
@ -91,9 +91,12 @@ StringList ClientCommandProcessor::handleCommand(String const& commandLine) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto player = m_universeClient->mainPlayer();
|
auto player = m_universeClient->mainPlayer();
|
||||||
if (auto messageResult = player->receiveMessage(connectionForEntity(player->entityId()), "/" + command, { allArguments }))
|
if (auto messageResult = player->receiveMessage(connectionForEntity(player->entityId()), "/" + command, {allArguments})) {
|
||||||
result.append(messageResult->isType(Json::Type::String) ? *messageResult->stringPtr() : messageResult->repr(1, true));
|
if (messageResult->isType(Json::Type::String))
|
||||||
else
|
result.append(*messageResult->stringPtr());
|
||||||
|
else if (!messageResult->isNull())
|
||||||
|
result.append(messageResult->repr(1, true));
|
||||||
|
} else
|
||||||
m_universeClient->sendChat(commandLine, ChatSendMode::Broadcast);
|
m_universeClient->sendChat(commandLine, ChatSendMode::Broadcast);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
Reference in New Issue
Block a user