mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-29 04:06:39 +09:00
Eddit To ExpGamingCore.Gui and Added ExpGamingPlayer.Polls
This commit is contained in:
@@ -57,15 +57,15 @@ commands.validate = {
|
||||
['boolean']=function(value,event) local value = value.lower() if value == 'true' or valule == 'yes' or value == 'y' or value == '1' then return true else return false end end,
|
||||
['string']=function(value,event) return tostring(value) end,
|
||||
['string-inf']=function(value,event) return tostring(value) end,
|
||||
['string-len']=function(value,event,max) return tostring(value) and tostring(value):len() <= max and tostring(value) or commands.error{'commands.error-string-len'} end,
|
||||
['number']=function(value,event) return tonumber(value) or commands.error{'commands.error-number'} end,
|
||||
['number-int']=function(value,event) return tonumber(value) and math.floor(tonumber(value)) or commands.error{'commands.error-number'} end,
|
||||
['number-range']=function(value,event,min,max) return tonumber(value) and tonumber(value) > min and tonumber(value) <= max and tonumber(value) or commands.error{'commands.error-number-range'} end,
|
||||
['number-range-int']=function(value,event,min,max) return tonumber(value) and math.floor(tonumber(value)) > min and math.floor(tonumber(value)) <= max and math.floor(tonumber(value)) or commands.error{'commands.error-number-range'} end,
|
||||
['player']=function(value,event) return Game.get_player(player) or commands.error{'commands.error-player'} end,
|
||||
['player-online']=function(value,event) local player,err = commands.validate['player'](value) return err and commands.error(err) or player.conected and player or commands.error{'commands.error-player-online'} end,
|
||||
['player-alive']=function(value,event) local player,err = commands.validate['player-online'](value) return err and commands.error(err) or player.character and player.character.health > 0 and player or commands.error{'commands.error-player-alive'} end,
|
||||
['player-rank']=function(value,event) local player,err = commands.validate['player'](value) return err and commands.error(err) or not player.admin and Game.get_player(event).admin and player or commands.error{'commands.error-player-rank'} end,
|
||||
['string-len']=function(value,event,max) return tostring(value) and tostring(value):len() <= max and tostring(value) or commands.error{'ExpGamingCore_Command.error-string-len'} end,
|
||||
['number']=function(value,event) return tonumber(value) or commands.error{'ExpGamingCore_Command.error-number'} end,
|
||||
['number-int']=function(value,event) return tonumber(value) and math.floor(tonumber(value)) or commands.error{'ExpGamingCore_Command.error-number'} end,
|
||||
['number-range']=function(value,event,min,max) return tonumber(value) and tonumber(value) > min and tonumber(value) <= max and tonumber(value) or commands.error{'ExpGamingCore_Command.error-number-range'} end,
|
||||
['number-range-int']=function(value,event,min,max) return tonumber(value) and math.floor(tonumber(value)) > min and math.floor(tonumber(value)) <= max and math.floor(tonumber(value)) or commands.error{'ExpGamingCore_Command.error-number-range'} end,
|
||||
['player']=function(value,event) return Game.get_player(player) or commands.error{'ExpGamingCore_Command.error-player'} end,
|
||||
['player-online']=function(value,event) local player,err = commands.validate['player'](value) return err and commands.error(err) or player.conected and player or commands.error{'ExpGamingCore_Command.error-player-online'} end,
|
||||
['player-alive']=function(value,event) local player,err = commands.validate['player-online'](value) return err and commands.error(err) or player.character and player.character.health > 0 and player or commands.error{'ExpGamingCore_Command.error-player-alive'} end,
|
||||
['player-rank']=function(value,event) local player,err = commands.validate['player'](value) return err and commands.error(err) or not player.admin and Game.get_player(event).admin and player or commands.error{'ExpGamingCore_Command.error-player-rank'} end,
|
||||
['player-rank-online']=function(value,event) local player,err = commands.validate['player-online'](value) if err then return commands.error(err) end local player,err = commands.validate['player-rank'](player) if err then return commands.error(err) end return player end,
|
||||
['player-rank-alive']=function(value,event) local player,err = commands.validate['player-alive'](value) if err then return commands.error(err) end local player,err = commands.validate['player-rank'](player) if err then return commands.error(err) end return player end,
|
||||
}
|
||||
@@ -176,13 +176,13 @@ local function run_custom_command(command)
|
||||
local success, err = pcall(callback,player_name,command.name,command)
|
||||
if not success then error(err)
|
||||
elseif not err then
|
||||
player_return({'commands.unauthorized'},defines.textcolor.crit)
|
||||
player_return({'ExpGamingCore_Command.unauthorized'},defines.textcolor.crit)
|
||||
logMessage(player_name,command,'Failed to use command (Unauthorized)',commands.validate_args(command))
|
||||
if game.player then game.player.play_sound{path='utility/cannot_build'} end
|
||||
return
|
||||
end
|
||||
end elseif data.default_admin_only == true and game.player and not game.player.admin then
|
||||
player_return({'commands.unauthorized'},defines.textcolor.crit)
|
||||
player_return({'ExpGamingCore_Command.unauthorized'},defines.textcolor.crit)
|
||||
logMessage(player_name,command,'Failed to use command (Unauthorized)',commands.validate_args(command))
|
||||
if game.player then game.player.play_sound{path='utility/cannot_build'} end
|
||||
return
|
||||
@@ -190,7 +190,7 @@ local function run_custom_command(command)
|
||||
-- gets the args for the command
|
||||
local args, err = commands.validate_args(command)
|
||||
if args == commands.error then
|
||||
player_return({'commands.'..err,command.name,commands.format_inputs(data)},defines.textcolor.high)
|
||||
player_return({'ExpGamingCore_Command.'..err,command.name,commands.format_inputs(data)},defines.textcolor.high)
|
||||
logMessage(player_name,command,'Failed to use command (Invalid Args)',args)
|
||||
if game.player then game.player.play_sound{path='utility/deconstruct_big'} end
|
||||
return
|
||||
@@ -198,7 +198,7 @@ local function run_custom_command(command)
|
||||
-- runs the command
|
||||
local success, err = pcall(data.callback,command,args)
|
||||
if not success then error(err) end
|
||||
if err ~= commands.error and player_name ~= 'server' then player_return({'commands.command-ran'},defines.textcolor.info) end
|
||||
if err ~= commands.error and player_name ~= 'server' then player_return({'ExpGamingCore_Command.command-ran'},defines.textcolor.info) end
|
||||
logMessage(player_name,command,'Used command',args)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[commands]
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Unbefugt: Zugang verweigert. Du hast keinen Zugriff auf diese Befehle!
|
||||
invalid-inputs=ungültige Eingabe, /__1__ __2__
|
||||
invalid-range=ungültige Reichweite, Min: __1__, Max: __2__
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[commands]
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
|
||||
error-string-len=Invalid Length, Max: __1__
|
||||
error-number=Invalid Number: Command failed to run
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[commands]
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
|
||||
invalid-inputs=Invalid Input, /__1__ __2__
|
||||
invalid-range=Invalid Range, Min: __1__, Max: __2__
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[commands]
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Onbevoegd: toegang wordt geweigerd vanwege ongeldige inloggegevens
|
||||
invalid-inputs=Onjuiste invoer, /__1__ __2__
|
||||
invalid-range=Onjuiste radius, Min: __1__, Max: __2__
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[commands]
|
||||
[ExpGamingCore_Command]
|
||||
unauthorized=401 - Otillåten: Tillgång nekas på grund av otillräcklig säkerhetsprövning.
|
||||
invalid-inputs=Igiltig inmatning, /__1__ __2__
|
||||
invalid-range=Invalid räckvid, Min: __1__, Max: __2__
|
||||
|
||||
@@ -177,4 +177,5 @@ script.on_event('on_init',function(event)
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
-- calling will attempt to define a new group
|
||||
return setmetatable(Group,{__call=function(tbl,...) tbl.define(...) end})
|
||||
@@ -1,4 +1,4 @@
|
||||
[gui]
|
||||
[ExpGamingCore_Gui]
|
||||
unauthorized=401 - Unbefugt: Du hast keinen Zugriff auf diese Befehle!
|
||||
cant-open=Du kannst dieses Menü nicht öffnen, Grund: __1__
|
||||
cant-open-no-reason=Du kannst dieses Menü gerade nicht öffnen.
|
||||
@@ -1,4 +1,4 @@
|
||||
[gui]
|
||||
[ExpGamingCore_Gui]
|
||||
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
|
||||
cant-open=You can't open this panel right now, reason: __1__
|
||||
cant-open-no-reason=You can't open this panel right now
|
||||
@@ -1,4 +1,4 @@
|
||||
[gui]
|
||||
[ExpGamingCore_Gui]
|
||||
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
|
||||
cant-open=You can not open this panel right now, reason: __1__
|
||||
cant-open-no-reason=You can not open this panel right now
|
||||
@@ -1,4 +1,4 @@
|
||||
[gui]
|
||||
[ExpGamingCore_Gui]
|
||||
unauthorized=401 - Onbevoegd: toegang wordt geweigerd vanwege ongeldige inloggegevens
|
||||
cant-open=Je kan dit momenteel niet openen. Reden: __1__
|
||||
cant-open-no-reason=Je kan dit momenteel niet openen.
|
||||
@@ -1,4 +1,4 @@
|
||||
[gui]
|
||||
[ExpGamingCore_Gui]
|
||||
unauthorized=401 -Otillåten: Tillgång nekas på grund av otillräcklig säkerhetsprövning.
|
||||
cant-open=Du kan inte öppna den här panelen just nu, orsak: __1__
|
||||
cant-open-no-reason=Du kan inte öppna den här panelen just nu
|
||||
@@ -13,17 +13,18 @@ local mod_gui = require("mod-gui")
|
||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||
|
||||
local center = {}
|
||||
center._center = {}
|
||||
center._prototype = {}
|
||||
|
||||
--- Adds a new obj to the center gui
|
||||
-- @usage Gui.center.add{name='foo',caption='Foo',tooltip='Testing',draw=function}
|
||||
-- @usage return_value(player) -- opens the center gui for that player
|
||||
-- @param obj contains the new object, needs name, fraw is opt and is function(root_frame)
|
||||
-- @return the object made, used to add tabs
|
||||
-- @return the object made, used to add tabs, calling the returned value will open the center for the given player
|
||||
function center.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.name,'string') then return end
|
||||
verbose('Created Center Gui: '..obj.name)
|
||||
setmetatable(obj,{__index=center._center})
|
||||
setmetatable(obj,{__index=center._prototype,__call=function(self,...) center.open(player,self.name) end})
|
||||
obj.tabs = {}
|
||||
obj._tabs = {}
|
||||
Gui.data('center',obj.name,obj)
|
||||
@@ -86,7 +87,7 @@ end
|
||||
|
||||
-- used on the button press when the toolbar button is press, can be overriden
|
||||
-- not recomented for direct use see Gui.center.open
|
||||
function center._center.open(event)
|
||||
function center._prototype.open(event)
|
||||
local player = Game.get_player(event)
|
||||
local _center = Gui.data.center[event.element.name]
|
||||
local center_flow = center.get_flow(player)
|
||||
@@ -109,7 +110,7 @@ end
|
||||
|
||||
-- this is the default draw function if one is not provided, can be overriden
|
||||
-- not recomented for direct use see Gui.center.open
|
||||
function center._center:draw(frame)
|
||||
function center._prototype:draw(frame)
|
||||
Gui.bar(frame,510)
|
||||
local tab_bar = frame.add{
|
||||
type='frame',
|
||||
@@ -161,7 +162,7 @@ function center._center:draw(frame)
|
||||
local first_tab = nil
|
||||
for name,button in pairs(self.tabs) do
|
||||
first_tab = first_tab or name
|
||||
button:draw(tab_bar_scroll_flow).style.font_color = defines.color.white
|
||||
button(tab_bar_scroll_flow).style.font_color = defines.color.white
|
||||
end
|
||||
self._tabs[self.name..'_'..first_tab](tab_scroll_flow)
|
||||
tab_bar_scroll_flow.children[1].style.font_color = defines.color.orange
|
||||
@@ -175,7 +176,7 @@ end
|
||||
-- @tparam[opt] string tooltip the tooltip that is on the button
|
||||
-- @tparam function callback this is called when button is pressed with function(root_frame)
|
||||
-- @return self to allow chaining of _center:add_tab
|
||||
function center._center:add_tab(name,caption,tooltip,callback)
|
||||
function center._prototype:add_tab(name,caption,tooltip,callback)
|
||||
verbose('Created Tab: '..self.name..'/'..name)
|
||||
self._tabs[self.name..'_'..name] = callback
|
||||
self.tabs[name] = Gui.inputs.add{
|
||||
@@ -210,4 +211,5 @@ center._events = {[defines.events.on_gui_closed]=function(event)
|
||||
end}
|
||||
|
||||
center.on_role_change = center.clear
|
||||
return center
|
||||
-- calling will attempt to add a new gui
|
||||
return setmetatable(center,{__call=function(self,...) self.add(...) end})
|
||||
@@ -13,7 +13,7 @@ local mod_gui = require("mod-gui")
|
||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||
|
||||
local inputs = {}
|
||||
inputs._input = {}
|
||||
inputs._prototype = {}
|
||||
-- these are just so you can have short cuts to this
|
||||
inputs.events = {
|
||||
error='error',
|
||||
@@ -30,7 +30,7 @@ inputs.events = {
|
||||
-- @param event the event to raise callback on | can be number of the event | can be a key of inputs.events
|
||||
-- @tparam function callback the function you want to run on the event
|
||||
-- @treturn table returns self so you can chain together
|
||||
function inputs._input:on_event(event,callback)
|
||||
function inputs._prototype:on_event(event,callback)
|
||||
if not is_type(callback,'function') then return self end
|
||||
if inputs.events[event] then event = inputs.events[event] end
|
||||
if event == 'error' then self._error = callback return self end
|
||||
@@ -42,7 +42,7 @@ end
|
||||
-- @usage button:draw(frame)
|
||||
-- @param root the element you want to add the input to
|
||||
-- @return returns the element that was added
|
||||
function inputs._input:draw(root)
|
||||
function inputs._prototype:draw(root)
|
||||
local player = Game.get_player(root.player_index)
|
||||
if is_type(self.draw_data.caption,'string') and player.gui.is_valid_sprite_path(self.draw_data.caption) then
|
||||
local data = table.deepcopy(self.draw_data)
|
||||
@@ -89,8 +89,9 @@ end
|
||||
|
||||
--- Add a new input, this is the same as doing frame.add{} but returns a diffrent object
|
||||
-- @usage Gui.inputs.add{type='button',name='test',caption='Test'}
|
||||
-- @usage return_value(frame) -- draws the button onto that frame
|
||||
-- @tparam table obj the new element to add if caption is a sprite path then sprite is used
|
||||
-- @treturn table the custom input object
|
||||
-- @treturn table the custom input object, calling the returned calue will draw the button
|
||||
function inputs.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.type,'string') then return end
|
||||
@@ -110,7 +111,7 @@ function inputs.add(obj)
|
||||
obj.draw_data = table.deepcopy(obj)
|
||||
obj.data = {}
|
||||
obj.events = {}
|
||||
setmetatable(obj,{__index=inputs._input})
|
||||
setmetatable(obj,{__index=inputs._prototype,__call=function(self,...) self:draw(...) end})
|
||||
Gui.data('inputs_'..type,obj.name,obj)
|
||||
return obj
|
||||
end
|
||||
@@ -378,7 +379,7 @@ function inputs.add_drop_down(name,items,index,callback)
|
||||
return drop_down
|
||||
end
|
||||
|
||||
-- second return is join event and third is rank change event
|
||||
return inputs
|
||||
-- calling will attempt to add a new input
|
||||
return setmetatable(inputs,{__call=function(self,...) self.add(...) end})
|
||||
|
||||
-- to see examples look at GuiParts/test.lua
|
||||
|
||||
@@ -15,7 +15,7 @@ local mod_gui = require("mod-gui")
|
||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||
|
||||
local left = {}
|
||||
left._left = {}
|
||||
left._prototype = {}
|
||||
|
||||
-- used for debugging
|
||||
function left.override_open(state)
|
||||
@@ -23,13 +23,14 @@ function left.override_open(state)
|
||||
end
|
||||
--- Used to add a left gui frame
|
||||
-- @usage Gui.left.add{name='foo',caption='Foo',tooltip='just testing',open_on_join=true,can_open=function,draw=function}
|
||||
-- @usage return_value(player) -- toggles visiblity for that player, if no player then updates for all players
|
||||
-- @param obj this is what will be made, needs a name and a draw function(root_frame), open_on_join can be used to set the deaful state true/false, can_open is a test to block it from opening but is not needed
|
||||
-- @return the object that is made to... well idk but for the future
|
||||
-- @return the object that is made, calling the returned value with out a param will update the gui, else will toggle visiblity for that player
|
||||
function left.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.name,'string') then return end
|
||||
verbose('Created Left Gui: '..obj.name)
|
||||
setmetatable(obj,{__index=left._left})
|
||||
setmetatable(obj,{__index=left._prototype,__call=function(self,player) if player then self:toggle{player=player,element={name=self.name}} else left.update(self.name) end end})
|
||||
Gui.data('left',obj.name,obj)
|
||||
Gui.toolbar.add(obj.name,obj.caption,obj.tooltip,obj.toggle)
|
||||
return obj
|
||||
@@ -122,7 +123,7 @@ function left.close(left_name)
|
||||
end
|
||||
|
||||
-- this is used to draw the gui for the first time (these guis are never destoryed), used by the script
|
||||
function left._left.open(event)
|
||||
function left._prototype.open(event)
|
||||
local player = Game.get_player(event)
|
||||
local _left = Gui.data.left[event.element.name]
|
||||
local left_flow = mod_gui.get_frame_flow(player)
|
||||
@@ -139,7 +140,7 @@ function left._left.open(event)
|
||||
end
|
||||
|
||||
-- this is called when the toolbar button is pressed
|
||||
function left._left.toggle(event)
|
||||
function left._prototype.toggle(event)
|
||||
local player = Game.get_player(event)
|
||||
local _left = Gui.data.left[event.element.name]
|
||||
local left_flow = mod_gui.get_frame_flow(player)
|
||||
@@ -167,8 +168,8 @@ function left._left.toggle(event)
|
||||
else
|
||||
left.style.visible = false
|
||||
end
|
||||
if open == false then player_return({'gui.cant-open-no-reason'},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'}
|
||||
elseif open ~= true then player_return({'gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end
|
||||
if open == false then player_return({'ExpGamingCore_Gui.cant-open-no-reason'},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'}
|
||||
elseif open ~= true then player_return({'ExpGamingCore_Gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end
|
||||
end
|
||||
|
||||
left.on_player_joined_game = function(event)
|
||||
@@ -185,4 +186,5 @@ function left:on_init()
|
||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end
|
||||
end
|
||||
|
||||
return left
|
||||
-- calling will attempt to add a new gui
|
||||
return setmetatable(left,{__call=function(self,...) self.add(...) end})
|
||||
@@ -12,10 +12,10 @@ local mod_gui = require("mod-gui")
|
||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||
|
||||
local popup = {}
|
||||
popup._popup = {}
|
||||
popup._prototype = {}
|
||||
|
||||
function popup.load()
|
||||
popup._popup.close = Gui.inputs.add{
|
||||
popup._prototype.close = Gui.inputs.add{
|
||||
type='button',
|
||||
name='popup-close',
|
||||
caption='utility/set_bar_slot',
|
||||
@@ -28,13 +28,14 @@ end
|
||||
|
||||
--- Used to add a popup gui style
|
||||
-- @usage Gui.left.add{name='foo',caption='Foo',draw=function}
|
||||
-- @usage return_value(data,player) -- opens popup for one player use popup.open to open for more than one player
|
||||
-- @param obj this is what will be made, needs a name and a draw function(root_frame,data)
|
||||
-- @return the object that is made to... well idk but for the future
|
||||
-- @return the object that is made, calling the returned value will open the popup for that player
|
||||
function popup.add(obj)
|
||||
if not is_type(obj,'table') then return end
|
||||
if not is_type(obj.name,'string') then return end
|
||||
verbose('Created Popup Gui: '..obj.name)
|
||||
setmetatable(obj,{__index=popup._popup})
|
||||
setmetatable(obj,{__index=popup._prototype,__call=function(self,data,player) local players = player and {player} or nil popup.open(self.name,data,players) end})
|
||||
local name = obj.name; obj.name = nil
|
||||
Gui.data('popup',name,obj)
|
||||
obj.name = name
|
||||
@@ -73,7 +74,7 @@ function popup.open(style,data,players)
|
||||
direction='vertical',
|
||||
style='image_frame'
|
||||
}
|
||||
_popup.close:draw(_frame)
|
||||
_popup.close(_frame)
|
||||
if is_type(_popup.draw,'function') then
|
||||
local success, err = pcall(_popup.draw,frame,data)
|
||||
if not success then error(err) end
|
||||
@@ -97,7 +98,7 @@ function popup.open(style,data,players)
|
||||
direction='vertical',
|
||||
style='image_frame'
|
||||
}
|
||||
thread.data.popup.close:draw(_frame)
|
||||
thread.data.popup.close(_frame)
|
||||
if is_type(thread.data.popup.draw,'function') then
|
||||
local success, err = pcall(thread.data.popup.draw,frame,thread.data.data)
|
||||
if not success then error(err) end
|
||||
@@ -106,11 +107,12 @@ function popup.open(style,data,players)
|
||||
end
|
||||
end
|
||||
|
||||
function popup._popup:add_left(obj)
|
||||
function popup._prototype:add_left(obj)
|
||||
obj.name = obj.name or self.name
|
||||
self.left = Gui.left.add(obj)
|
||||
end
|
||||
|
||||
popup.on_player_joined_game = popup.flow
|
||||
|
||||
return popup
|
||||
-- calling will attempt to add a new popup style
|
||||
return setmetatable(popup,{__call=function(self,...) self.add(...) end})
|
||||
@@ -20,7 +20,7 @@ local toolbar = {}
|
||||
-- @tparam string caption can be a sprite path or text to show
|
||||
-- @tparam string tooltip the help to show for the button
|
||||
-- @tparam function callback the function which is called on_click
|
||||
-- @treturn table the button object that was made
|
||||
-- @treturn table the button object that was made, calling the returned value will draw the toolbar button added
|
||||
function toolbar.add(name,caption,tooltip,callback)
|
||||
verbose('Created Toolbar Button: '..name)
|
||||
local button = Gui.inputs.add{type='button',name=name,caption=caption,tooltip=tooltip}
|
||||
@@ -41,9 +41,9 @@ function toolbar.draw(player)
|
||||
for name,button in pairs(Gui.data.toolbar) do
|
||||
if is_type(Role,'table') then
|
||||
if Role.allowed(player,name) then
|
||||
button:draw(toolbar_frame)
|
||||
button(toolbar_frame)
|
||||
end
|
||||
else button:draw(toolbar_frame) end
|
||||
else button(toolbar_frame) end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,4 +53,5 @@ end
|
||||
|
||||
toolbar.on_role_change = toolbar.draw
|
||||
toolbar.on_player_joined_game = toolbar.draw
|
||||
return toolbar
|
||||
-- calling with only a player will draw the toolbar for that player, more params will attempt to add a button
|
||||
return setmetatable(toolbar,{__call=function(self,player,extra,...) if extra then self.add(player,extra,...) else self.draw(player) end end})
|
||||
@@ -18,7 +18,7 @@ local Role = {
|
||||
order={},
|
||||
flags={},
|
||||
actions={},
|
||||
meta={times={},groups={}},
|
||||
meta={times={},groups={},count=0},
|
||||
roles=setmetatable({},{
|
||||
__index=table.autokey,
|
||||
__newindex=function(tbl,key,value)
|
||||
@@ -43,6 +43,7 @@ local Role = {
|
||||
if self.meta.groups[role.group.name].highest > index then self.meta.groups[role.group.name].highest = index end
|
||||
if self.meta.groups[role.group.name].lowest < index then self.meta.groups[role.group.name].lowest = index end
|
||||
if previous then setmetatable(previous.allow,{__index=role.allow}) end
|
||||
self.meta.count = self.meta.count+1
|
||||
role.index = index
|
||||
previous = role
|
||||
end
|
||||
@@ -487,4 +488,5 @@ script.on_event(defines.events.on_tick,function(event)
|
||||
end)
|
||||
|
||||
-- Module Return
|
||||
-- calling will attempt to define a new role
|
||||
return setmetatable(Role,{__call=function(tbl,...) tbl.define(...) end})
|
||||
@@ -4,7 +4,7 @@ commands.add_validation('player-rank',function(value,event)
|
||||
local player,err = commands.validate['player'](value)
|
||||
return err and commands.error(err)
|
||||
or Role.get_highest(player).index > Role.get_highest(event).index and player
|
||||
or commands.error{'commands.error-player-rank'}
|
||||
or commands.error{'ExpGamingCore_Command.error-player-rank'}
|
||||
end)
|
||||
|
||||
commands.add_validation('player-rank-online',function(value,event)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
[Server]
|
||||
[ExpGamingCore_Server]
|
||||
interface-description=Runs the given input from the script
|
||||
@@ -23,7 +23,7 @@ Server.add_module_to_interface('Server','ExpGamingCore.Server')
|
||||
--- Runs the given input from the script
|
||||
-- @command interface
|
||||
-- @param code The code that will be ran
|
||||
commands.add_command('interface',{'Server.interface-description'}, {
|
||||
commands.add_command('interface',{'ExpGamingCore_Server.interface-description'}, {
|
||||
['code']={true,'string-inf'}
|
||||
}, function(event,args)
|
||||
local callback = args.code
|
||||
|
||||
Reference in New Issue
Block a user