Fixed Existing Lua Check Errors

This commit is contained in:
Cooldude2606
2020-05-26 18:21:10 +01:00
parent 2aaeb06be3
commit 32507492b8
76 changed files with 1622 additions and 1617 deletions

View File

@@ -10,7 +10,7 @@ require 'config.expcore.command_general_parse'
local results_per_page = 5
local search_cache = {}
Global.register(search_cache,function(tbl)
Global.register(search_cache, function(tbl)
search_cache = tbl
end)
@@ -18,12 +18,12 @@ end)
-- @command chelp
-- @tparam string keyword the keyword that will be looked for
-- @tparam number page the page of help to view, must be in range of pages
Commands.new_command('search-help','Searches for a keyword in all commands you are allowed to use.')
:add_alias('chelp','shelp','commands')
:add_param('keyword',true)
:add_param('page',true,'integer')
:set_defaults{keyword='',page=1}
:register(function(player,keyword,page,raw)
Commands.new_command('search-help', 'Searches for a keyword in all commands you are allowed to use.')
:add_alias('chelp', 'shelp', 'commands')
:add_param('keyword', true)
:add_param('page', true, 'integer')
:set_defaults{keyword='', page=1}
:register(function(player, keyword, page)
local player_index = player and player.index or 0
-- if keyword is a number then treat it as page number
if tonumber(keyword) then
@@ -40,20 +40,20 @@ Commands.new_command('search-help','Searches for a keyword in all commands you a
pages = {{}}
local current_page = 1
local page_count = 0
local commands = Commands.search(keyword,player)
local commands = Commands.search(keyword, player)
-- loops other all commands returned by search, includes game commands
for _,command_data in pairs(commands) do
for _, command_data in pairs(commands) do
-- if the number of results if greater than the number already added then it moves onto a new page
if page_count >= results_per_page then
page_count = 0
current_page = current_page + 1
table.insert(pages,{})
table.insert(pages, {})
end
-- adds the new command to the page
page_count = page_count + 1
found = found + 1
local alias_format = #command_data.aliases > 0 and {'expcom-chelp.alias',table.concat(command_data.aliases,', ')} or ''
table.insert(pages[current_page],{
local alias_format = #command_data.aliases > 0 and {'expcom-chelp.alias', table.concat(command_data.aliases, ', ')} or ''
table.insert(pages[current_page], {
'expcom-chelp.format',
command_data.name,
command_data.description,
@@ -70,15 +70,15 @@ Commands.new_command('search-help','Searches for a keyword in all commands you a
end
-- print the requested page
keyword = keyword == '' and '<all>' or keyword
Commands.print({'expcom-chelp.title',keyword},'cyan')
Commands.print({'expcom-chelp.title', keyword}, 'cyan')
if pages[page] then
for _,command in pairs(pages[page]) do
for _, command in pairs(pages[page]) do
Commands.print(command)
end
Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
Commands.print({'expcom-chelp.footer', found, page, #pages}, 'cyan')
else
Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
return Commands.error{'expcom-chelp.out-of-range',page}
Commands.print({'expcom-chelp.footer', found, page, #pages}, 'cyan')
return Commands.error{'expcom-chelp.out-of-range', page}
end
-- blocks command complete message
return Commands.success