From 812d03bd3bdf1dd25de4772d13b841e30760d648 Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Sun, 31 Dec 2017 18:03:16 +0000 Subject: [PATCH] Added override for the can open --- ExpCore/GuiParts/left.lua | 11 ++++++++++- ExpCore/GuiParts/test.lua | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ExpCore/GuiParts/left.lua b/ExpCore/GuiParts/left.lua index af07ff5f..f34d2273 100644 --- a/ExpCore/GuiParts/left.lua +++ b/ExpCore/GuiParts/left.lua @@ -10,6 +10,10 @@ Discord: https://discord.gg/r6dC2uK local left = {} left._left = {} +-- used for debugging +function left.override_open(state) + global.over_ride_left_can_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} -- @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 @@ -134,7 +138,12 @@ function left._left.toggle(event) if is_type(_left.can_open,'function') then local success, err = pcall(_left.can_open,player) if not success then error(err) - elseif err == true then open = true end + elseif err == true then open = true + elseif global.over_ride_left_can_open then + if is_type(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 then + if Ranking.get_rank(player):allowed(_left.name) then open = true end + end + end else if is_type(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 then if Ranking.get_rank(player):allowed(_left.name) then open = true end diff --git a/ExpCore/GuiParts/test.lua b/ExpCore/GuiParts/test.lua index e682da18..849e4b98 100644 --- a/ExpCore/GuiParts/test.lua +++ b/ExpCore/GuiParts/test.lua @@ -124,7 +124,7 @@ end):add_tab('tab-2','Tab 2','Just a tab',function(frame) end end) --- testing the left gui, open_test_on_all_left_guis is realy long just so it is very unlickly to be used +-- testing the left gui Gui.left.add{ name='test-left', caption='Gui Left', @@ -134,7 +134,7 @@ Gui.left.add{ frame.add{type='label',caption=player.name} end end, - can_open=function(player) return player.index == 1 or global.open_test_on_all_left_guis end + can_open=function(player) return player.index == 1 end } local text_popup = Gui.inputs.add_text('test-popup-text',true,'Message To Send',function(player,text,element)