31 lines
1023 B
Lua
31 lines
1023 B
Lua
-- states/new_game.lua
|
|||
|
|
--
|
||
|
|
-- Not a list — a single text field for the character's name. So this uses a
|
||
|
|
-- custom read() rather than the focus/list probe.
|
||
|
|
--
|
||
|
|
-- `inputText` is an upvalue of keypressed (which handles backspace and tab).
|
||
|
|
-- Note the game only enables textinput here, so our hotkey layer stays out of
|
||
|
|
-- this state (see hotkeys.lua textEntryStates) and typed brackets reach the game.
|
||
|
|
|
||
|
|
return {
|
||
|
|
-- Spoken when the screen opens, since the on-screen hint window is the only
|
||
|
|
-- thing explaining what to do.
|
||
|
|
onOpen = 'Enter your character name. Tab suggests a name, Enter confirms.',
|
||
|
|
|
||
|
|
read = function(stateTable, menus)
|
||
|
|
local inputText = menus.getUpvalue(stateTable.keypressed, "inputText")
|
||
|
|
|
||
|
|
if type(inputText) ~= "string" then
|
||
|
|
return nil, nil
|
||
|
|
end
|
||
|
|
|
||
|
|
if inputText == "" then
|
||
|
|
return "Name, blank", "blank"
|
||
|
|
end
|
||
|
|
|
||
|
|
-- Key is the text itself, so the driver re-announces on every change
|
||
|
|
-- (typing, backspace, tab-suggest) but not on keys that change nothing.
|
||
|
|
return inputText, inputText
|
||
|
|
end,
|
||
|
|
}
|