Added commands tab

This commit is contained in:
Cooldude2606
2020-03-25 21:18:03 +00:00
parent e493b573fb
commit 8362e5a397
5 changed files with 53 additions and 29 deletions

View File

@@ -211,7 +211,7 @@ local default = Roles.new_role('Guest','')
:allow{
'command/tag',
'command/tag-clear',
'command/chelp',
'command/search-help',
'command/list-roles',
'command/find-on-map',
'command/report',

View File

@@ -10,7 +10,7 @@ to-self=Player can not be teleported to themselves.
[expcom-chelp]
title=Help results for "__1__":
footer=[__1__ results found; page __2__ of __3__]
footer=[__1__ results found: page __2__ of __3__]
format=/__1__ __2__ - __3__ __4__
alias=Alias: __1__
out-of-range=__1__ is an invalid page number.
@@ -61,8 +61,8 @@ wip=This command is temporary and will be replaced at some point in the future.
[expcom-ratio]
notSelecting=Please select an entetiy with a recpie.
item-in=You need __1__ per seconds of [item=__2__].
fluid-in=You need __1__ per seconds of [fluid=__2__].
item-in=You need __1__ per second of [item=__2__].
fluid-in=You need __1__ per second of [fluid=__2__].
item-out=This will result in: __1__ [item=__2__] per second.
fluid-out=This will result in: __1__ [fluid=__2__] per second.
machines=And you will need __1__ machines (with the same speed as this one) for this.

View File

@@ -125,6 +125,7 @@ rules-14=Do not beg for roles, advertise other servers, or link to harmful sites
rules-15=Use common sense, report rule breakers, and Administrators have the final word.
commands-tab=Commands
commands-tooltip=Commands which you are able to use
commands-general=We have lots of custom commands which you are able to use. Below you can find a list of all the commands that you are allowed to use and what they do. If you need more information or want to search for a command you can use our /search-help command.
servers-tab=Servers
servers-tooltip=Links to our other servers and sites
backers-tab=Backers

View File

@@ -18,7 +18,8 @@ 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('chelp','Searches for a keyword in all commands you are allowed to use.')
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}

View File

@@ -6,6 +6,7 @@
local Gui = require 'expcore.gui' --- @dep expcore.gui
local Roles = require 'expcore.roles' --- @dep expcore.roles
local Commands = require 'expcore.commands' --- @dep expcore.commands
local Event = require 'utils.event' --- @dep utils.event
local Game = require 'utils.game' --- @dep utils.game
@@ -42,6 +43,24 @@ end)
horizontal_align = 'center'
}
--- Title element with bars on each side
-- @element title
local title =
Gui.element(function(_,parent,bar_size,caption)
local title_flow = parent.add{ type='flow' }
title_flow.style.vertical_align = 'center'
Gui.bar(title_flow,bar_size)
local title_label = title_flow.add{
type = 'label',
caption = caption,
style = 'heading_1_label'
}
Gui.bar(title_flow)
return title_label
end)
--- Content area for the welcome tab
-- @element welcome_content
Tab({'readme.welcome-tab'},{'readme.welcome-tooltip'},
@@ -58,15 +77,7 @@ Gui.element(function(_,parent)
top_vertical_flow.style.horizontal_align = 'center'
-- Add the title to the top flow
local title_flow = top_vertical_flow.add{ type='flow' }
title_flow.style.vertical_align = 'center'
Gui.bar(title_flow,85)
title_flow.add{
type = 'label',
caption = 'Welcome to '..server_details.name,
style = 'caption_label'
}
Gui.bar(title_flow,85)
title(top_vertical_flow,62,'Welcome to '..server_details.name)
-- Add the description to the top flow
description_label(top_vertical_flow,380,server_details.description)
@@ -94,28 +105,20 @@ Gui.element(function(_,parent)
local container = parent.add{ type='flow', direction='vertical' }
-- Add the title to the content
local title_flow = container.add{ type='flow' }
title_flow.style.vertical_align = 'center'
Gui.bar(title_flow,267)
title_flow.add{
type = 'label',
caption = {'readme.rules-tab'},
style = 'heading_1_label'
}
Gui.bar(title_flow,267)
title(container,267,{'readme.rules-tab'})
-- Add the tab description
description_label(container,575,{'readme.rules-general'})
Gui.bar(container)
-- Add a table for the rules
container.add{ type='flow' }
local rules = Gui.scroll_table(container,275,1)
rules.style = 'bordered_table'
rules.style.top_margin = 2
-- Add the rules to the table
for i = 1,15 do
description_label(rules,545,{'readme.rules-'..i})
description_label(rules,555,{'readme.rules-'..i})
end
return container
@@ -124,11 +127,30 @@ end))
--- Content area for the commands tab
-- @element commands_content
Tab({'readme.commands-tab'},{'readme.commands-tooltip'},
Gui.element{
type = 'label',
caption = 'Commands'
})
Gui.element(function(_,parent)
local container = parent.add{ type='flow', direction='vertical' }
local player = Gui.get_player_from_element(parent)
-- Add the title to the content
title(container,250,{'readme.commands-tab'})
-- Add the tab description
description_label(container,575,{'readme.commands-general'})
Gui.bar(container)
-- Add a table for the rules
container.add{ type='flow' }
local commands = Gui.scroll_table(container,275,2)
commands.style = 'bordered_table'
-- Add the rules to the table
for name,command in pairs(Commands.get(player)) do
description_label(commands,100,name)
description_label(commands,440,command.help)
end
return container
end))
--- Content area for the servers tab
-- @element servers_content
Tab({'readme.servers-tab'},{'readme.servers-tooltip'},