Added comments and fixed bugs

This commit is contained in:
Cooldude2606
2019-05-20 22:41:10 +01:00
parent 13b34cbd60
commit 6961614d80
11 changed files with 221 additions and 41 deletions

View File

@@ -1,12 +1,21 @@
--- Gui structure for the toolbar (top left)
--[[
>>>> Example format
-- this is the same as any other button define, this just automatically draws it
-- you can use add_button if you already defined the button
local toolbar_button =
Toolbar.new_button('print-click')
:on_click(function(player,_element)
player.print('You clicked a button!')
end)
>>>> Functions
Toolbar.new_button(name) --- Adds a new button to the toolbar
Toolbar.add_button(button) --- Adds an existing buttton to the toolbar
Toolbar.update(player) --- Updates the player's toolbar with an new buttons or expected change in auth return
]]
local Buttons = require './buttons'
local Gui = require './core'
local Buttons = require 'expcore.gui.buttons'
local Gui = require 'expcore.gui.core'
local Roles = require 'expcore.roles'
local Event = require 'utils.event'
local Game = require 'utils.game'
@@ -16,7 +25,7 @@ local Toolbar = {
buttons = {}
}
local function toolbar_allow(player,define_name)
function Toolbar.allowed(player,define_name)
local permisison_name = Toolbar.permisison_names[define_name] or define_name
return Roles.player_allowed(player,permisison_name)
end
@@ -26,11 +35,11 @@ function Toolbar.permission_alias(define_name,permisison_name)
end
--- Adds a new button to the toolbar
-- @tparam[opt] name string the name of the button to be added
-- @tparam[opt] name string when given allows an alias to the button for the permission system
-- @treturn table the button define
function Toolbar.new_button(name)
local button = Buttons.new_button()
button:set_post_authenticator(toolbar_allow)
button:set_post_authenticator(Toolbar.allowed)
Toolbar.add_button(button)
Toolbar.permission_alias(button.name,name)
return button
@@ -69,6 +78,7 @@ function Toolbar.update(player)
element.enabled = false
end
end
log(table.inspect(Toolbar.buttons))
end
--- When there is a new player they will have the toolbar update