Few Bugs Fixed

This commit is contained in:
Cooldude2606
2018-06-07 14:59:12 +01:00
parent 5a40fe6649
commit ef8345216a
11 changed files with 55 additions and 60 deletions

View File

@@ -201,6 +201,5 @@ script.on_event('on_gui_closed',function(event)
if event.element and event.element.valid then event.element.destroy() end
end)
-- when the player rank is changed it closses the center guis
-- second return is join event and third is rank change event
return center, nil, center.clear
center.on_rank_change = center.clear
return center

View File

@@ -371,6 +371,6 @@ function inputs.add_drop_down(name,items,index,callback)
end
-- second return is join event and third is rank change event
return inputs, nil, nil
return inputs
-- to see examples look at GuiParts/test.lua

View File

@@ -144,13 +144,13 @@ function left._left.toggle(event)
if not success then error(err)
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 is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
if Ranking.get_rank(player):allowed(_left.name) then open = true
else open = {gui.unauthorized} end
end
else open = err end
else
if is_type(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 then
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
if Ranking.get_rank(player):allowed(_left.name) then open = true
else open = {gui.unauthorized} end
end
@@ -164,8 +164,7 @@ function left._left.toggle(event)
elseif open ~= true then player_return({'gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end
end
-- second return is join event and third is rank change event
return left, function(event)
left.on_player_joined_game = function(event)
-- draws the left guis when a player first joins, fake_event is just because i am lazy
local player = Game.get_player(event)
local frames = Gui.data.left or {}
@@ -173,4 +172,6 @@ return left, function(event)
local fake_event = {player_index=player.index,element={name=name}}
left.open(fake_event)
end
end, nil
end
return left

View File

@@ -10,7 +10,7 @@
local popup = {}
popup._popup = {}
function popup._load()
function popup.load()
popup._popup.close = Gui.inputs.add{
type='button',
name='popup-close',
@@ -107,5 +107,6 @@ function popup._popup:add_left(obj)
self.left = Gui.left.add(obj)
end
-- second return is join event and third is rank change event
return popup, popup.flow, nil
popup.on_player_joined_game = popup.flow
return popup

View File

@@ -34,7 +34,7 @@ function toolbar.draw(player)
toolbar_frame.clear()
if not Gui.data.toolbar then return end
for name,button in pairs(Gui.data.toolbar) do
if is_type(Ranking,'table') and Ranking._presets and Ranking._presets().meta.rank_count > 0 then
if is_type(Ranking,'table') and Ranking.meta.rank_count > 0 then
local rank = Ranking.get_rank(player)
if rank:allowed(name) then
button:draw(toolbar_frame)
@@ -43,5 +43,6 @@ function toolbar.draw(player)
end
end
-- second return is join event and third is rank change event
return toolbar, toolbar.draw, toolbar.draw
toolbar.on_rank_change = toolbar.draw
toolbar.on_player_joined_game = toolbar.draw
return toolbar