refactor existing logic to use new function

develop
Myk Taylor 2023-04-17 13:04:42 -07:00
parent e9f6695ace
commit f6031e6a79
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 6 additions and 7 deletions

@ -12,10 +12,10 @@ local function get_command(cmdline)
end end
function should_hide_armok(cmdline) function should_hide_armok(cmdline)
local first_word = get_command(cmdline) local command = get_command(cmdline)
return dfhack.getHideArmokTools() and return dfhack.getHideArmokTools() and
helpdb.is_entry(first_word) and helpdb.is_entry(command) and
helpdb.get_entry_tags(first_word).armok helpdb.get_entry_tags(command).armok
end end
-- ----------------- -- -- ----------------- --
@ -245,10 +245,9 @@ end
function Menu:onSelect(_, choice) function Menu:onSelect(_, choice)
if not choice or #self.subviews == 0 then return end if not choice or #self.subviews == 0 then return end
local first_word = choice.command:trim():split(' +')[1] local command = get_command(choice.command)
if first_word:startswith(':') then first_word = first_word:sub(2) end self.subviews.help.text_to_wrap = helpdb.is_entry(command) and
self.subviews.help.text_to_wrap = helpdb.is_entry(first_word) and helpdb.get_entry_short_help(command) or 'Command not found'
helpdb.get_entry_short_help(first_word) or 'Command not found'
self.subviews.help_panel:updateLayout() self.subviews.help_panel:updateLayout()
end end