mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Add Command Description Locale (#323)
* Update admin-chat.lua * Update admin-markers.lua * Update artillery.lua * Update bot-queue.lua * Update cheat-mode.lua * Update clear-inventory.lua * Update connect.lua * Update debug.lua * Update enemy.lua * Update find.lua * Update friendly-fire.lua * Update help.lua * Update home.lua * Update interface.lua * Update jail.lua * Update kill.lua * Update last-location.lua * Update me.lua * Update pollution.lua * Update protection.lua * Update rainbow.lua * Update ratio.lua * Update repair.lua * Update reports.lua * Update research.lua * Update roles.lua * Update roles.lua * Update search.lua * Update spawn.lua * Update spectate.lua * Update speed.lua * Update surface-clearing.lua * Update teleport.lua * Update train.lua * Update vlayer.lua * Update warnings.lua * Update waterfill.lua * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update connect.lua * Update cheat-mode.lua * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update commands.cfg * Update admin-chat.lua * Update admin-markers.lua * Update vlayer.lua * Update artillery.lua * Update bot-queue.lua * Update cheat-mode.lua * Update clear-inventory.lua * Update connect.lua * Update debug.lua * Update enemy.lua * Update find.lua * Update friendly-fire.lua * Update help.lua * Update home.lua * Update interface.lua * Update jail.lua * Update kill.lua * Update last-location.lua * Update me.lua * Update pollution.lua * Update protection.lua * Update rainbow.lua * Update ratio.lua * Update repair.lua * Update reports.lua * Update research.lua * Update roles.lua * Update search.lua * Update spawn.lua * Update spectate.lua * Update speed.lua * Update surface-clearing.lua * Update teleport.lua * Update train.lua * Update warnings.lua * Update waterfill.lua * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update commands.cfg * Update commands.cfg * Update addons.cfg * Update addons.cfg * Update data.cfg * Update data.cfg * Update gui.cfg * Update gui.cfg * Update data.cfg * Update data.cfg * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update commands.lua * Update admin-chat.lua * Update admin-markers.lua * Update artillery.lua * Update bot-queue.lua * Update cheat-mode.lua * Update clear-inventory.lua * Update connect.lua * Update debug.lua * Update enemy.lua * Update find.lua * Update help.lua * Update interface.lua * Update home.lua * Update jail.lua * Update kill.lua * Update last-location.lua * Update me.lua * Update pollution.lua * Update protection.lua * Update rainbow.lua * Update ratio.lua * Update repair.lua * Update reports.lua * Update research.lua * Update roles.lua * Update search.lua * Update spawn.lua * Update spectate.lua * Update speed.lua * Update surface-clearing.lua * Update teleport.lua * Update train.lua * Update vlayer.lua * Update warnings.lua * Update waterfill.lua * Update commands.cfg * Update commands.cfg * Update enemy.lua * Update friendly-fire.lua * Update roles.lua * Update spectate.lua * Update spectate.lua
This commit is contained in:
@@ -18,29 +18,34 @@ 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.')
|
||||
Commands.new_command('search-help', {'expcom-chelp.description'}, '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
|
||||
page = math.floor(tonumber(keyword))
|
||||
keyword = ''
|
||||
end
|
||||
|
||||
-- gets a value for pages, might have result in cache
|
||||
local pages
|
||||
local found = 0
|
||||
|
||||
if search_cache[player_index] and search_cache[player_index].keyword == keyword:lower() then
|
||||
pages = search_cache[player_index].pages
|
||||
found = search_cache[player_index].found
|
||||
|
||||
else
|
||||
pages = {{}}
|
||||
local current_page = 1
|
||||
local page_count = 0
|
||||
local commands = Commands.search(keyword, player)
|
||||
|
||||
-- loops other all commands returned by search, includes game commands
|
||||
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
|
||||
@@ -49,6 +54,7 @@ Commands.new_command('search-help', 'Searches for a keyword in all commands you
|
||||
current_page = current_page + 1
|
||||
table.insert(pages, {})
|
||||
end
|
||||
|
||||
-- adds the new command to the page
|
||||
page_count = page_count + 1
|
||||
found = found + 1
|
||||
@@ -61,6 +67,7 @@ Commands.new_command('search-help', 'Searches for a keyword in all commands you
|
||||
alias_format
|
||||
})
|
||||
end
|
||||
|
||||
-- adds the result to the cache
|
||||
search_cache[player_index] = {
|
||||
keyword=keyword:lower(),
|
||||
@@ -68,21 +75,26 @@ Commands.new_command('search-help', 'Searches for a keyword in all commands you
|
||||
found=found
|
||||
}
|
||||
end
|
||||
|
||||
-- print the requested page
|
||||
keyword = keyword == '' and '<all>' or keyword
|
||||
Commands.print({'expcom-chelp.title', keyword}, 'cyan')
|
||||
|
||||
if pages[page] then
|
||||
for _, command in pairs(pages[page]) do
|
||||
Commands.print(command)
|
||||
end
|
||||
|
||||
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}
|
||||
end
|
||||
|
||||
-- blocks command complete message
|
||||
return Commands.success
|
||||
end)
|
||||
|
||||
-- way to access global
|
||||
return search_cache
|
||||
return search_cache
|
||||
|
||||
Reference in New Issue
Block a user