mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Cleaned Code
This commit is contained in:
@@ -22,7 +22,7 @@ local Exp_commands = {}
|
||||
--Used mainly by the code to convert the inputs into a string
|
||||
function command_inputs_to_string(command)
|
||||
local str_inputs = ''
|
||||
for _,input in pairs(command[3]) do
|
||||
for _,input in pairs(command.inputs) do
|
||||
if input == true then break end
|
||||
str_inputs = str_inputs..'<'..input..'> '
|
||||
end
|
||||
@@ -30,13 +30,13 @@ function command_inputs_to_string(command)
|
||||
end
|
||||
--Can be used to ensure the right number of inputs are given
|
||||
function get_command_args(event,command)
|
||||
if not event.parameter then if #command[3] > 0 then return 'Invalid' else return end end
|
||||
if not event.parameter then if #command.inputs > 0 then return 'Invalid' else return end end
|
||||
local args = {}
|
||||
for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if command[3][#command[3]] == true then
|
||||
if #args < #command[3]-1 then return 'Invalid' end
|
||||
if command.inputs[#command.inputs] == true then
|
||||
if #args < #command.inputs-1 then return 'Invalid' end
|
||||
else
|
||||
if #args ~= #command[3] then return 'Invalid' end
|
||||
if #args ~= #command.inputs then return 'Invalid' end
|
||||
end return args
|
||||
end
|
||||
--name is what is used in /command
|
||||
@@ -54,24 +54,24 @@ function define_command(name,help,inputs,restriction,event)
|
||||
end
|
||||
--The magic for the commands. It is a hard bit of code so GL; but it will call the command event have some sanitisaion of the input
|
||||
function load_command(command)
|
||||
if commands.commands[command[1]] then return end
|
||||
commands.add_command(command[1],command_inputs_to_string(command)..command[2],function(event)
|
||||
if commands.commands[command.name] then return end
|
||||
commands.add_command(command.name,command_inputs_to_string(command)..command.help,function(event)
|
||||
local command_data = nil
|
||||
for _,command_d in pairs(Exp_commands) do if event.name == command_d[1] then command_data = command_d break end end
|
||||
if event.player_index then
|
||||
local player = game.players[event.player_index]
|
||||
local temp_restriction = nil
|
||||
if type(command[4]) == 'number' then temp_restriction = command[4] end
|
||||
local restriction = temp_restriction or string_to_rank(command[4]).power or 0
|
||||
if type(command.restriction) == 'number' then temp_restriction = command.restriction end
|
||||
local restriction = temp_restriction or string_to_rank(command.restriction).power or 0
|
||||
if get_rank(player).power > restriction then player.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
local args = get_command_args(event,command)
|
||||
if args == 'Invalid' then player.print('Invalid Input, /'..command[1]..' '..command_inputs_to_string(command)) return end
|
||||
command[5](player,event,args)
|
||||
if args == 'Invalid' then player.print('Invalid Input, /'..command.name..' '..command_inputs_to_string(command)) return end
|
||||
command.event(player,event,args)
|
||||
player.print('Command Complete')
|
||||
else
|
||||
local args = get_command_args(event,command)
|
||||
if args == 'Invalid' then print('Invalid Input, /'..command[1]..' '..command_inputs_to_string(command)) return end
|
||||
command[5]('<server>',event,args)
|
||||
if args == 'Invalid' then print('Invalid Input, /'..command.name..' '..command_inputs_to_string(command)) return end
|
||||
command.event('<server>',event,args)
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -39,23 +39,23 @@ function sudo(command,args,custom_return_name)
|
||||
local args = args or {}
|
||||
local return_name = custom_return_name or tostring(game.tick)..tostring(command)..tostring(#global.sudo.commands)
|
||||
table.insert(global.sudo.commands,{fun=command,args=args,return_name=return_name})
|
||||
return {'sudo-temp-var',return_name}
|
||||
return {sudo='sudo-temp-var',name=return_name}
|
||||
end
|
||||
end
|
||||
--update the time on a temp var or add it as a new one
|
||||
function refresh_temp_var(name,value,offset)
|
||||
local offset = offset or temp_var_time
|
||||
if global.sudo.temp_varibles[name] then
|
||||
global.sudo.temp_varibles[name][2] = game.tick+offset
|
||||
global.sudo.temp_varibles[name].remove_time = game.tick+offset
|
||||
else
|
||||
global.sudo.temp_varibles[name] = {data=value,remove_time=game.tick+offset}
|
||||
end
|
||||
end
|
||||
-- gets the data stored in a temp varible
|
||||
function get_temp_var_data(name)
|
||||
function get_temp_var_data(var)
|
||||
local to_return = nil
|
||||
if global.sudo.temp_varibles[name] then to_return = global.sudo.temp_varibles[name].data
|
||||
elseif name[2] and global.sudo.temp_varibles[name[2]] then to_return = global.sudo.temp_varibles[name[2]].data end
|
||||
if global.sudo.temp_varibles[var] then to_return = global.sudo.temp_varibles[var].data
|
||||
elseif var.name and global.sudo.temp_varibles[var.name] then to_return = global.sudo.temp_varibles[var.name].data end
|
||||
return to_return
|
||||
end
|
||||
-- returns the lenth of the temp varible list and command queue, is string is true then it is retured as a string
|
||||
@@ -78,7 +78,7 @@ Event.register(defines.events.on_tick, function(event)
|
||||
local args = {}
|
||||
-- retrives and temp varibles
|
||||
for n,value in pairs(command.args) do
|
||||
if type(value) == 'list' and value[1] == 'sudo-temp-var' then args[n] = global.sudo.temp_varibles[value[2]][1]
|
||||
if type(value) == 'list' and value.sudo == 'sudo-temp-var' then args[n] = global.sudo.temp_varibles[value.name].data
|
||||
else args[n] = value end
|
||||
end
|
||||
-- makes new temp value and runs command
|
||||
|
||||
@@ -35,7 +35,7 @@ function add_frame.tab(name,default_display,default_tooltip,restriction,frame,ev
|
||||
if not name then error('Tab requires a name') end
|
||||
if not frame then error('Tab requires a frame') end
|
||||
table.insert(frames.tabs,{name,default_display,frame,event})
|
||||
for _,f in pairs(frames.center) do if f[1] == frame then table.insert(f[3],{name,restriction}) end end
|
||||
for _,f in pairs(frames.center) do if f.name == frame then table.insert(f.tabs,{name,restriction}) end end
|
||||
ExpGui.add_input.button(name,default_display,default_tooltip,draw_frame.tab)
|
||||
end
|
||||
--Draw the center GUI for the player; do not call manually, must use other functions to call
|
||||
@@ -43,20 +43,20 @@ ExpGui.add_input.button('close_center','Close','Close this GUI',function(player,
|
||||
function draw_frame.center(player,element)
|
||||
local frame_data = nil
|
||||
for _,frame in pairs(frames.center) do if element.name == frame[1] then frame_data = frame break end end
|
||||
if player.gui.is_valid_sprite_path(frame_data[2]) then frame_data[2] = frame_data[1] end
|
||||
if player.gui.center[frame_data[1]] then player.gui.center.clear() return else player.gui.center.clear() end
|
||||
local frame = player.gui.center.add{name=frame_data[1],type='frame',caption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
if frame_data[4] and type(frame_data[4]) == 'function' then frame_data[4](player,frame) return end
|
||||
if player.gui.is_valid_sprite_path(frame_data.display) then frame_data.display = frame_data.name end
|
||||
if player.gui.center[frame_data.name] then player.gui.center.clear() return else player.gui.center.clear() end
|
||||
local frame = player.gui.center.add{name=frame_data.name,type='frame',caption=frame_data.display,direction='vertical',style=mod_gui.frame_style}
|
||||
if frame_data.event and type(frame_data.event) == 'function' then frame_data.event(player,frame) return end
|
||||
local tab_bar_scroll = frame.add{type = "scroll-pane", name= "tab_bar_scroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"}
|
||||
local tab_bar = tab_bar_scroll.add{type='flow',direction='horizontal',name='tab_bar'}
|
||||
local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"}
|
||||
for n,t in pairs(frame_data[3]) do
|
||||
for n,t in pairs(frame_data.tabs) do
|
||||
local temp_restriction = nil
|
||||
if type(t[2]) == 'number' then temp_restriction = t[2] end
|
||||
local restriction = temp_restriction or string_to_rank(t[2]).power or 0
|
||||
if restriction >= get_rank(player).power then ExpGui.add_input.draw_button(tab_bar,t[1]) end
|
||||
if type(t.restriction) == 'number' then temp_restriction = t.restriction end
|
||||
local restriction = temp_restriction or string_to_rank(t.restriction).power or 0
|
||||
if restriction >= get_rank(player).power then ExpGui.add_input.draw_button(tab_bar,t.name) end
|
||||
end
|
||||
draw_frame.tab(player,tab_bar[frame_data[3][1][1]])
|
||||
draw_frame.tab(player,tab_bar[frame_data.tabs[1].name)
|
||||
ExpGui.add_input.draw_button(tab_bar,'close_center')
|
||||
tab.style.minimal_height = 300
|
||||
tab.style.maximal_height = 300
|
||||
@@ -76,7 +76,7 @@ function draw_frame.tab(player,element)
|
||||
btn.style.font_color = {r = 100, g = 100, b = 100,a=255}
|
||||
end end
|
||||
element.parent.parent.parent.tab.clear()
|
||||
for _,tab in pairs(frames.tabs) do if element.name == tab[1] then tab[4](player,element.parent.parent.parent.tab) break end end
|
||||
for _,tab in pairs(frames.tabs) do if element.name == tab.name then tab.event(player,element.parent.parent.parent.tab) break end end
|
||||
end
|
||||
|
||||
Event.register(Event.rank_change,function(event) event.player.gui.center.clear() end)
|
||||
|
||||
@@ -34,10 +34,10 @@ end
|
||||
function add_input.draw_button(frame,name,display,tooltip)
|
||||
if not frame or not frame.valid then error('No frame to draw to') end
|
||||
if not name then error('No button to draw') end
|
||||
for _,btn in pairs(inputs.buttons) do
|
||||
if btn[1] == name then
|
||||
local display = display or btn[2] or btn[1]
|
||||
local tooltip = tooltip or btn[3]
|
||||
for _,button in pairs(inputs.buttons) do
|
||||
if button.name == name then
|
||||
local display = display or button.display or button.name
|
||||
local tooltip = tooltip or button.tooltip
|
||||
if frame.gui.is_valid_sprite_path(display) then
|
||||
frame.add{name=name, type = "sprite-button", sprite=display, tooltip=tooltip, style = mod_gui.button_style}
|
||||
else
|
||||
@@ -52,8 +52,8 @@ function add_input.draw_text(frame,name,display)
|
||||
if not frame or not frame.valid then error('No frame to draw to') end
|
||||
if not name then error('No text filed to draw') end
|
||||
for _,text in pairs(inputs.text) do
|
||||
if text[1] == name then
|
||||
local display = display or text[2] or text[1]
|
||||
if text.name == name then
|
||||
local display = display or text.display or text.name
|
||||
frame.add{name=name, type='textfield'}
|
||||
frame[name].caption=display
|
||||
break
|
||||
@@ -64,9 +64,9 @@ end
|
||||
Event.register(defines.events.on_gui_click, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
if event.element.type == 'button' or event.element.type == 'sprite-button' then
|
||||
for _,btn in pairs(inputs.buttons) do
|
||||
if btn[1] == event.element.name then
|
||||
if btn[4] then btn[4](player,event.element) else rank_print('Button without Function '..btn[1],'Mod') end break
|
||||
for _,button in pairs(inputs.buttons) do
|
||||
if button.name == event.element.name then
|
||||
if button.event then button.event(player,event.element) else rank_print('Button without Function '..button.name,'Mod') end break
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -75,8 +75,8 @@ end)
|
||||
Event.register(defines.events.on_gui_text_changed, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
for _,text in pairs(inputs.text) do
|
||||
if text[1] == event.element.name then
|
||||
if text[3] then text[3](player,event.element) end break
|
||||
if text.name == event.element.name then
|
||||
if text.event then text.event(player,event.element) end break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -37,25 +37,25 @@ function draw_frame.left(player,element,update)
|
||||
local frame_data = nil
|
||||
local left = mod_gui.get_frame_flow(player)
|
||||
if not update then
|
||||
for _,frame in pairs(frames.left) do if element.name == frame[1] then frame_data = frame break end end
|
||||
if left[frame_data[1]] then ExpGui.toggle_visible(left[frame_data[1]]) return end
|
||||
frame = left.add{name=frame_data[1],type='frame',caption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
for _,frame in pairs(frames.left) do if element.name == frame.name then frame_data = frame break end end
|
||||
if left[frame_data.name] then ExpGui.toggle_visible(left[frame_data.name]) return end
|
||||
frame = left.add{name=frame_data.name,type='frame',caption=frame_data.display,direction='vertical',style=mod_gui.frame_style}
|
||||
else
|
||||
for _,frame in pairs(frames.left) do if element == frame[1] then frame_data = frame break end end
|
||||
frame = left[frame_data[1]]
|
||||
for _,frame in pairs(frames.left) do if element == frame.name then frame_data = frame break end end
|
||||
frame = left[frame_data.name]
|
||||
end
|
||||
if frame then frame.clear() frame_data[3](player,frame) end
|
||||
if frame then frame.clear() frame_data.event(player,frame) end
|
||||
end
|
||||
--used to load all left GUIs
|
||||
Event.register(defines.events.on_player_joined_game,function(event)
|
||||
local player = game.players[event.player_index]
|
||||
for _,frame_data in pairs(frames.left) do
|
||||
local left = mod_gui.get_frame_flow(player)
|
||||
if left[frame_data[1]] then left[frame_data[1]].style.visible = frame_data[4] ExpGui.draw_frame.left(player,frame_data[1],true)
|
||||
if left[frame_data.name] then left[frame_data.name].style.visible = frame_data.vis ExpGui.draw_frame.left(player,frame_data.name,true)
|
||||
else
|
||||
local frame = left.add{name=frame_data[1],type='frame',caption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
frame_data[3](player,frame)
|
||||
frame.style.visible = frame_data[4]
|
||||
local frame = left.add{name=frame_data.name,type='frame',caption=frame_data.display,direction='vertical',style=mod_gui.frame_style}
|
||||
frame_data.event(player,frame)
|
||||
frame.style.visible = frame_data.vis
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -63,7 +63,7 @@ end)
|
||||
Event.register(Event.rank_change,function(event)
|
||||
for _,frame_data in pairs(frames.left) do
|
||||
local left = mod_gui.get_frame_flow(event.player)
|
||||
if left[frame_data[1]] then left[frame_data[1]].style.visible = frame_data[4] end
|
||||
if left[frame_data.name] then left[frame_data.name].style.visible = frame_data.vis end
|
||||
end
|
||||
end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
|
||||
@@ -18,6 +18,7 @@ local credits = {{
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
-- Mainly used as a plan for how the gui is stored also as a header for the credit
|
||||
ExpGui = {
|
||||
add_frame={
|
||||
--center
|
||||
|
||||
@@ -23,18 +23,18 @@ local yes = {'yes','y','true','ye'}
|
||||
local no = {'no','false','nay'}
|
||||
--filters that are used. Feel free to add more
|
||||
player_table_functions.filters = {
|
||||
--{name,is_text,function(player,input) return true end}
|
||||
{'is_admin',false,function(player) return player.admin end},
|
||||
{'player_name',true,function(player,input) if input and player.name:lower():find(input:lower()) then return true end end},
|
||||
{'online',false,function(player) return player.connected end},
|
||||
{'offline',false,function(player) return not player.connected end},
|
||||
{'online_time',true,function(player,input) if input and tonumber(input) and tonumber(input) < tick_to_min(player.online_time) then return true elseif not input or not tonumber(input) then return true end end},
|
||||
{'rank',true,function(player,input) if input and string_to_rank(input) and get_rank(player).power <= string_to_rank(input).power then return true elseif not input or not string_to_rank(input) then return true end end}
|
||||
--{name,is_text,function(player,input) return true/false end}
|
||||
{name='is_admin',is_text=false,test=function(player) return player.admin end},
|
||||
{name='player_name',is_text=true,test=function(player,input) if input and player.name:lower():find(input:lower()) then return true end end},
|
||||
{name='online',is_text=false,test=function(player) return player.connected end},
|
||||
{name='offline',is_text=false,test=function(player) return not player.connected end},
|
||||
{name='online_time',is_text=true,test=function(player,input) if input and tonumber(input) and tonumber(input) < tick_to_min(player.online_time) then return true elseif not input or not tonumber(input) then return true end end},
|
||||
{name='rank',is_text=true,test=function(player,input) if input and string_to_rank(input) and get_rank(player).power <= string_to_rank(input).power then return true elseif not input or not string_to_rank(input) then return true end end}
|
||||
}
|
||||
--set up all the text inputs
|
||||
for _,filter in pairs(player_table_functions.filters) do
|
||||
if filter[2] then
|
||||
ExpGui.add_input.text(filter[1],'Enter '..filter[1]:gsub('_',' '),function(player,element) ExpGui.player_table.redraw(player,element) end)
|
||||
if filter.is_text then
|
||||
ExpGui.add_input.text(filter.name,'Enter '..filter.name:gsub('_',' '),function(player,element) ExpGui.player_table.redraw(player,element) end)
|
||||
end
|
||||
end
|
||||
--used to draw filters from the list above
|
||||
@@ -42,7 +42,7 @@ function player_table_functions.draw_filters(player,frame,filters)
|
||||
local input_bar = frame.add{type='flow',name='input_bar',direction='horizontal'}
|
||||
for _,name in pairs(filters) do
|
||||
local filter_data = nil
|
||||
for _,filter in pairs(player_table_functions.filters) do if filter[1] == name then filter_data = filter break end end
|
||||
for _,filter in pairs(player_table_functions.filters) do if filter.name == name then filter_data = filter break end end
|
||||
if filter_data and filter_data[2] then
|
||||
ExpGui.add_input.draw_text(input_bar,name)
|
||||
end
|
||||
@@ -52,9 +52,9 @@ end
|
||||
function player_table_functions.get_filters(frame)
|
||||
local filters = {}
|
||||
for _,filter in pairs(player_table_functions.filters) do
|
||||
if frame.input_bar[filter[1]] then
|
||||
if frame.input_bar[filter[1]].text:find('%S') then
|
||||
table.insert(filters,{filter[1],frame.input_bar[filter[1]].text})
|
||||
if frame.input_bar[filter.name] then
|
||||
if frame.input_bar[filter.name].text:find('%S') then
|
||||
table.insert(filters,{filter.name,frame.input_bar[filter.name].text})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -65,7 +65,7 @@ function player_table_functions.player_match(player,filter,input)
|
||||
for _,f in pairs(player_table_functions.filters) do
|
||||
if filter == f or filter == f[1] then if filter == f[1] then filter = f break end end
|
||||
end
|
||||
if filter[3] and type(filter[3]) == 'function' then return filter[3](player,input) end
|
||||
if filter.test and type(filter.test) == 'function' then return filter.test(player,input) end
|
||||
end
|
||||
--used by script on filter texts
|
||||
function player_table_functions.redraw(player,element)
|
||||
@@ -80,38 +80,38 @@ function player_table_functions.draw(player,frame,filters,input_location)
|
||||
--setup the table
|
||||
if frame.player_table then frame.player_table.destroy() end
|
||||
player_table = frame.add{name='player_table', type="table", colspan=5}
|
||||
player_table.style.minimal_width = 500
|
||||
player_table.style.maximal_width = 500
|
||||
player_table.style.minimal_width = 500
|
||||
player_table.style.maximal_width = 500
|
||||
player_table.style.horizontal_spacing = 10
|
||||
player_table.add{name="id", type="label", caption="Id"}
|
||||
player_table.add{name="player_name", type="label", caption="Name"}
|
||||
player_table.add{name="id", type="label", caption="Id"}
|
||||
player_table.add{name="player_name", type="label", caption="Name"}
|
||||
player_table.add{name="status", type="label", caption="Status"}
|
||||
player_table.add{name="online_time", type="label", caption="Online Time"}
|
||||
player_table.add{name="rank", type="label", caption="Rank"}
|
||||
player_table.add{name="online_time", type="label", caption="Online Time"}
|
||||
player_table.add{name="rank", type="label", caption="Rank"}
|
||||
for i,p in pairs(game.players) do
|
||||
--filter cheaking
|
||||
local add=true
|
||||
for _,filter in pairs(filters) do
|
||||
if #filter == 2 and add then
|
||||
local result = player_table_functions.player_match(p,filter[1],filter[2])
|
||||
if not result and filter[2] == true then result = filter[2] end
|
||||
local result = player_table_functions.player_match(p,filter.name,filter.is_text)
|
||||
if not result and filter.is_text == true then result = filter.is_text end
|
||||
add = result or false
|
||||
end
|
||||
end
|
||||
for _,filter in pairs(player_table_functions.get_filters(input_location)) do
|
||||
if add then
|
||||
add = player_table_functions.player_match(p,filter[1],filter[2]) or false
|
||||
add = player_table_functions.player_match(p,filter.name,filter.is_text) or false
|
||||
end
|
||||
end
|
||||
--add the player
|
||||
if add then--and player.name ~= p.name then
|
||||
player_table.add{name=p.name.."_id", type="label", caption=i}
|
||||
player_table.add{name=p.name..'_name', type="label", caption=p.name}
|
||||
player_table.add{name=p.name..'_name', type="label", caption=p.name}
|
||||
if p.connected == true
|
||||
then player_table.add{name=p.name.."status", type="label", caption="Online"}
|
||||
else player_table.add{name=p.name.."s", type="label", caption="Offline"} end
|
||||
player_table.add{name=p.name.."online_time", type="label", caption=tick_to_display_format(p.online_time)}
|
||||
player_table.add{name=p.name.."rank", type="label", caption=get_rank(p).short_hand}
|
||||
player_table.add{name=p.name.."rank", type="label", caption=get_rank(p).short_hand}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,9 +55,9 @@ function draw_frame.popup_button(player,element)
|
||||
local frame_data = nil
|
||||
for _,frame in pairs(frames.popup) do if element.name == frame[1] then frame_data = frame break end end
|
||||
local popups = mod_gui.get_frame_flow(player).popups
|
||||
if popups[frame_data[1]..'_on_click'] then popups[frame_data[1]..'_on_click'].destroy() return end
|
||||
local frame = get_next_popup(popups,frame_data[1])
|
||||
frame_data[3](player,frame)
|
||||
if popups[frame_data.name..'_on_click'] then popups[frame_data.name..'_on_click'].destroy() return end
|
||||
local frame = get_next_popup(popups,frame_data.name)
|
||||
frame_data.on_click(player,frame)
|
||||
end
|
||||
--used to draw a popup style can be called at any time; can not be called from a button directly
|
||||
function draw_frame.popup(style,args)
|
||||
@@ -67,7 +67,7 @@ function draw_frame.popup(style,args)
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local popups = mod_gui.get_frame_flow(player).popups
|
||||
local frame = get_next_popup(popups)
|
||||
frame_data[4](player,frame,args)
|
||||
frame_data.event(player,frame,args)
|
||||
end
|
||||
end
|
||||
--used to make the popup area
|
||||
|
||||
@@ -31,13 +31,13 @@ function toolbar.draw(player)
|
||||
if not player then error('Need a player to draw to') end
|
||||
local toolbar_frame = mod_gui.get_button_flow(player)
|
||||
toolbar_frame.clear()
|
||||
for _,btn in pairs(toolbar.buttons) do
|
||||
for _,button in pairs(toolbar.buttons) do
|
||||
local rank = get_rank(player)
|
||||
local temp_restriction = nil
|
||||
if type(btn[2]) == 'number' then temp_restriction = btn[2] end
|
||||
local restriction = temp_restriction or string_to_rank(btn[2]).power or 0
|
||||
if type(button.restriction) == 'number' then temp_restriction = button.restriction end
|
||||
local restriction = temp_restriction or string_to_rank(button.restriction).power or 0
|
||||
if restriction >= rank.power then
|
||||
ExpGui.add_input.draw_button(toolbar_frame,btn[1])
|
||||
ExpGui.add_input.draw_button(toolbar_frame,button.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user