Make the source pass the CI lint
The central pipeline lints where the old inline one did not, and it aborts on any warning. Nothing here was actually wrong: 166 of the 243 warnings were the TIC-80 API and the game's own globals being undeclared, which is what .luacheckrc is for — the same shape impostor already uses. The rest was trailing whitespace on 14 lines, now stripped. INPUT_KEY_X is unused but kept: it belongs to the LEFT/RIGHT/A/B/X/Y set and removing it would leave a gap in the mapping, so luacheck is told to allow the family. Verified locally by merging the sources the way the pipeline does and running luacheck over the result: 0 warnings, 0 errors. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
|||||||
|
-- .luacheckrc
|
||||||
|
-- Configuration for luacheck
|
||||||
|
--
|
||||||
|
-- The CI lint step aborts on any warning, so both the project's own globals
|
||||||
|
-- and the TIC-80 API functions this game calls have to be declared here.
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
-- the game's own globals
|
||||||
|
"Context",
|
||||||
|
"init_game",
|
||||||
|
|
||||||
|
-- TIC-80 callbacks and API
|
||||||
|
"TIC",
|
||||||
|
"btn",
|
||||||
|
"btnp",
|
||||||
|
"cls",
|
||||||
|
"exit",
|
||||||
|
"keyp",
|
||||||
|
"mget",
|
||||||
|
"mset",
|
||||||
|
"rect",
|
||||||
|
"rectb",
|
||||||
|
"spr",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- The INPUT_KEY_* constants are a coherent set (LEFT/RIGHT/A/B/X/Y); some are
|
||||||
|
-- not bound yet, and dropping them would leave gaps in the mapping.
|
||||||
|
ignore = { "211/INPUT_KEY_.*" }
|
||||||
|
|
||||||
|
std = "lua51" -- TIC-80 runs Lua 5.1
|
||||||
@@ -45,7 +45,7 @@ function init_game()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TIC()
|
function TIC()
|
||||||
init_game()
|
init_game()
|
||||||
|
|
||||||
cls(Config.colors.black)
|
cls(Config.colors.black)
|
||||||
local handler = STATE_HANDLERS[Context.active_window]
|
local handler = STATE_HANDLERS[Context.active_window]
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ end
|
|||||||
function UI.word_wrap(text, max_chars_per_line)
|
function UI.word_wrap(text, max_chars_per_line)
|
||||||
if text == nil then return {""} end
|
if text == nil then return {""} end
|
||||||
local lines = {}
|
local lines = {}
|
||||||
|
|
||||||
for input_line in (text .. "\n"):gmatch("(.-)\n") do
|
for input_line in (text .. "\n"):gmatch("(.-)\n") do
|
||||||
local current_line = ""
|
local current_line = ""
|
||||||
local words_in_line = 0
|
local words_in_line = 0
|
||||||
@@ -50,18 +50,18 @@ function UI.word_wrap(text, max_chars_per_line)
|
|||||||
current_line = word
|
current_line = word
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if words_in_line > 0 then
|
if words_in_line > 0 then
|
||||||
table.insert(lines, current_line)
|
table.insert(lines, current_line)
|
||||||
else
|
else
|
||||||
table.insert(lines, "")
|
table.insert(lines, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #lines == 0 then
|
if #lines == 0 then
|
||||||
return {""}
|
return {""}
|
||||||
end
|
end
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,15 +39,15 @@ function ConfigurationWindow.draw()
|
|||||||
for i, control in ipairs(ConfigurationWindow.controls) do
|
for i, control in ipairs(ConfigurationWindow.controls) do
|
||||||
local current_y = y_start + (i - 1) * 12
|
local current_y = y_start + (i - 1) * 12
|
||||||
local color = Config.colors.green
|
local color = Config.colors.green
|
||||||
|
|
||||||
if control.type == "numeric_stepper" then
|
if control.type == "numeric_stepper" then
|
||||||
local value = control.get()
|
local value = control.get()
|
||||||
local label_text = control.label
|
local label_text = control.label
|
||||||
local value_text = string.format(control.format, value)
|
local value_text = string.format(control.format, value)
|
||||||
|
|
||||||
-- Calculate x position for right-aligned value
|
-- Calculate x position for right-aligned value
|
||||||
local value_x = x_value_right_align - (#value_text * char_width)
|
local value_x = x_value_right_align - (#value_text * char_width)
|
||||||
|
|
||||||
if i == ConfigurationWindow.selected_control then
|
if i == ConfigurationWindow.selected_control then
|
||||||
color = Config.colors.item
|
color = Config.colors.item
|
||||||
Print.text("<", x_start -8, current_y, color)
|
Print.text("<", x_start -8, current_y, color)
|
||||||
@@ -70,7 +70,7 @@ function ConfigurationWindow.draw()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Print.text("Press B to go back", x_start, 120, Config.colors.light_grey)
|
Print.text("Press B to go back", x_start, 120, Config.colors.light_grey)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
function IntroWindow.draw()
|
function IntroWindow.draw()
|
||||||
local x = (Config.screen.width - 132) / 2 -- Centered text
|
local x = (Config.screen.width - 132) / 2 -- Centered text
|
||||||
Print.text(Context.intro.text, x, Context.intro.y, Config.colors.green)
|
Print.text(Context.intro.text, x, Context.intro.y, Config.colors.green)
|
||||||
end
|
end
|
||||||
|
|
||||||
function IntroWindow.update()
|
function IntroWindow.update()
|
||||||
Context.intro.y = Context.intro.y - Context.intro.speed
|
Context.intro.y = Context.intro.y - Context.intro.speed
|
||||||
|
|
||||||
-- Count lines in intro text to determine when scrolling is done
|
-- Count lines in intro text to determine when scrolling is done
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ function MenuWindow.refresh_menu_items()
|
|||||||
table.insert(Context.menu_items, {label = "Load Game", action = MenuWindow.load_game})
|
table.insert(Context.menu_items, {label = "Load Game", action = MenuWindow.load_game})
|
||||||
table.insert(Context.menu_items, {label = "Configuration", action = MenuWindow.configuration})
|
table.insert(Context.menu_items, {label = "Configuration", action = MenuWindow.configuration})
|
||||||
table.insert(Context.menu_items, {label = "Exit", action = MenuWindow.exit})
|
table.insert(Context.menu_items, {label = "Exit", action = MenuWindow.exit})
|
||||||
|
|
||||||
Context.selected_menu_item = 1 -- Reset selection after refreshing
|
Context.selected_menu_item = 1 -- Reset selection after refreshing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ function PopupWindow.update()
|
|||||||
selected_item.action()
|
selected_item.action()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Input.menu_back() then
|
if Input.menu_back() then
|
||||||
GameWindow.set_state(WINDOW_GAME)
|
GameWindow.set_state(WINDOW_GAME)
|
||||||
end
|
end
|
||||||
@@ -92,7 +92,7 @@ function PopupWindow.draw()
|
|||||||
Print.text(line, 50, current_y, Config.colors.light_grey)
|
Print.text(line, 50, current_y, Config.colors.light_grey)
|
||||||
current_y = current_y + 8 -- Move to the next line (8 pixels for default font height + padding)
|
current_y = current_y + 8 -- Move to the next line (8 pixels for default font height + padding)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Adjust menu position based on the number of wrapped lines
|
-- Adjust menu position based on the number of wrapped lines
|
||||||
if not Context.dialog.showing_description then
|
if not Context.dialog.showing_description then
|
||||||
UI.draw_menu(Context.dialog.menu_items, Context.dialog.selected_menu_item, 50, current_y + 2)
|
UI.draw_menu(Context.dialog.menu_items, Context.dialog.selected_menu_item, 50, current_y + 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user