-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Scoreboard command to the info.lua #246
Conversation
I just noticed that my ide removed all the indentation. I don't know if this is a problem |
Hi and welcome to the project. About the whitespace: |
This is basically it for the command, I will add Comments and more comprehensive error message then It will be good to merge I think |
I'll review this tomorrow in depth. It looks good generally, but the documentation messages could do with some standardisation, and the commands could do with some changes to correspond better to the vanilla ones. |
I used this as reference for the commands, I tried to be as accurate as possible with the commands but there was not the outputs of the commands so I made it a bit like I though I will launch a minecraft world to test and documents the outputs more accurately, I just have no time this w-e, I will try to do this next week |
I want to make sure the code is clean and follow the project's structure so I checked other files as cmd_effect.lua for instance. But I don't understand, Why does the Response Variable is returned as this doesn't seem to be handle by cuberite but also, why should I return the content of cPlayer:sendMessage to Response as this function doesn't seems to return anything... |
It's used for the console command to print the response: Lines 67 to 69 in baf6a4e
There are additional functions that return the message when appropriate: Lines 72 to 97 in baf6a4e
|
I am currently implementing the console side of the command but I have a problem... scoreboard by cuberite work as a per world basis. so when a player execute a scoreboard command I usually get the player's world to create the scoreboard... but when the console does it. what should I do? |
The tags file is used by ctags for quick tag finding, but as this is generate do on every small changes with `ctags -R .` this should not be in the git repo
cmd_scoreboard.lua
Outdated
if gPlayer then | ||
gPlayer:SendMessage(Objective:GetDisplayName() .. " -> " .. Objective:GetName() .. ": " .. get_key_for_value(criterias, Objective:GetType())) | ||
else | ||
LOG(Objective:GetDisplayName() .. " -> " .. Objective:GetName() .. ": " .. get_key_for_value(criterias, Objective:GetType())) -- TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering... is there a better way to send the result of a command (with multiple line) than doing it with LOG()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how the /tps command does it:
Lines 34 to 42 in baf6a4e
function HandleTpsCommand(Split, Player) | |
local Response = {} | |
table.insert(Response, "Global TPS: " .. GetAverageNum(GlobalTps)) | |
for WorldName, WorldTps in pairs(TpsCache) do | |
table.insert(Response, "World \"" .. WorldName .. "\": " .. GetAverageNum(WorldTps) .. " TPS") | |
end | |
return true, SendMessage(Player, table.concat(Response, "\n")) | |
end |
I don't remember if we have other commands in the new format that output multiple lines.
Edit: another one
https://github.com/cuberite/Core/blob/master/cmd_players.lua
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm quite done ?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use PascalCase in general.
There we go, Ready again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all done
@tonitch Could you create a follow-up PR addressing some unhandled exceptions when invalid command arguments are provided? |
Implementing /scoreboard as part of the #158
info.lua updated for an overview of the work to do