style: consistent casing

This commit is contained in:
2025-05-13 00:42:34 -03:00
parent 60db9abb31
commit c430904fa6
+9 -9
View File
@@ -218,14 +218,14 @@ function handleMessages(side, channel, replyChannel, message, dist)
end end
if not commands[message.name] then if not commands[message.name] then
log.error("unhandled command (%s)", message.name) log.error("Unhandled command (%s)", message.name)
return return
end end
local cmd = commands[message.name] local cmd = commands[message.name]
for i, v in pairs(cmd.keys) do for i, v in pairs(cmd.keys) do
if type(message.data[i]) ~= v and v ~= "optional" then if type(message.data[i]) ~= v and v ~= "optional" then
log.error("command %s requires key %s of type %s (was %s)", message.name, i, v, type(message[i])) log.error("Command %s requires key %s of type %s (was %s)", message.name, i, v, type(message[i]))
return return
end end
end end
@@ -233,10 +233,10 @@ function handleMessages(side, channel, replyChannel, message, dist)
-- cmd execution -- cmd execution
local success, err = pcall(cmd.handler, message.data, message.id) local success, err = pcall(cmd.handler, message.data, message.id)
if not success then if not success then
log.error("error occurred while executing command %s: %s", message.name, err) log.error("Error occurred while executing command %s: %s", message.name, err)
end end
log.info("processed command (%s)", message.name) log.info("Processed command (%s)", message.name)
end end
registerEventListener("modem_message", handleMessages) registerEventListener("modem_message", handleMessages)
@@ -334,7 +334,7 @@ end
registerConsoleCommand("exit", exitCommand, "Exits the program") registerConsoleCommand("exit", exitCommand, "Exits the program")
function scanCommand(args) function scanCommand(args)
log.info("broadcasting SCAN") log.info("Broadcasting SCAN")
sendToAll("SCAN", { ["hostChannel"] = HOST_CHANNEL }) sendToAll("SCAN", { ["hostChannel"] = HOST_CHANNEL })
end end
@@ -348,14 +348,14 @@ registerConsoleCommand("clear", clearCommand, "Clears the console")
function turtlesCommand(args) function turtlesCommand(args)
if #turtles == 0 then if #turtles == 0 then
log.info("no turtles registered") log.info("No turtles registered")
return return
end end
for i = 1, #turtles, 1 do for i = 1, #turtles, 1 do
local turt = turtles[i] local turt = turtles[i]
local turtleMessage = ("coords: %d, %d, %d - fuel: %d - channel: %d - id: %d - status: %s"):format( local turtleMessage = ("Coords: %d, %d, %d - fuel: %d - channel: %d - id: %d - status: %s"):format(
turt.position[1], turt.position[1],
turt.position[2], turt.position[3], turt.fuel, turt.channel, turt.id, turt.status) turt.position[2], turt.position[3], turt.fuel, turt.channel, turt.id, turt.status)
@@ -468,7 +468,7 @@ function drawStatusBar(y)
scr.setTextColor(colors.white) scr.setTextColor(colors.white)
scr.clearLine() scr.clearLine()
local str = ("turtles: %d"):format(#turtles) local str = ("Turtles: %d"):format(#turtles)
scr.write(str) scr.write(str)
end end
@@ -537,7 +537,7 @@ end
--[[ --[[
main main
]] ]]
log.general("init") log.general("Init")
while shouldRun do while shouldRun do
updateScreen() updateScreen()