Replace `table.getn with # and scene with SCENE`

This commit is contained in:
Squishy (C6H12O6+NaCl+H2O)
2024-04-19 21:23:09 +07:00
parent cedc6e888e
commit 9c8628a014
13 changed files with 67 additions and 67 deletions

View File

@@ -1,4 +1,4 @@
local StickConfigScene = Scene:extend()
local StickConfigScene = SCENE:extend()
StickConfigScene.title = "Controller Config"
@@ -58,7 +58,7 @@ function StickConfigScene:render()
drawText(self.set_inputs[input], 240, 50 + i * 20, 300, "left")
end
end
if self.input_state > table.getn(configurable_inputs) then
if self.input_state > #configurable_inputs then
drawText("Press enter to confirm, delete/backspace to retry" .. (config.input and ", escape to cancel" or ""), 0, 0, 1000)
else
drawText("Press joystick input for " .. input_names[configurable_inputs[self.input_state]] .. ", tab to skip, escape to cancel", 0, 0, 1000)
@@ -77,15 +77,15 @@ function StickConfigScene:onInputPress(e)
if e.type == "key" then
-- function keys, escape, and tab are reserved and can't be remapped
if e.scancode == "escape" then
scene = InputConfigScene()
elseif self.input_state > table.getn(configurable_inputs) then
SCENE = InputConfigScene()
elseif self.input_state > #configurable_inputs then
if e.scancode == "return" then
-- save new input, then load next scene
local had_config = config.input ~= nil
if not config.input then config.input = {} end
config.input.joysticks = self.new_input
saveConfig()
scene = had_config and InputConfigScene() or TitleScene()
SCENE = had_config and InputConfigScene() or TitleScene()
elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry
self.input_state = 1
@@ -97,7 +97,7 @@ function StickConfigScene:onInputPress(e)
self.input_state = self.input_state + 1
end
elseif string.sub(e.type, 1, 3) == "joy" then
if self.input_state <= table.getn(configurable_inputs) then
if self.input_state <= #configurable_inputs then
if e.type == "joybutton" then
addJoystick(self.new_input, e.name)
if not self.new_input[e.name].buttons then