Tool bar now goes off of the required.

This commit is contained in:
Cooldude2606 committed 2017-04-07 15:50:21 +01:00
1 parent 8d4a162014
commit 2bcc10d544
2 files changed
+40 -37

No files matched your search

+1 -1
View File
@@ -1 +1 @@
entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={itemRotated={},ranks={{name='Owner',shortHand='Owner',tag='[Owner]',power=0,colour={r=170,g=0,b=0}},{name='Community Manager',shortHand='CM',tag='[Com Mngr]',power=1,colour={r=150,g=68,b=161}},{name='Developer',shortHand='Dev',tag='[Dev]',power=1,colour={r=179,g=125,b=46}},{name='Admin',shortHand='Admin',tag='[Admin]',power=2,colour={r=170,g=41,b=170}},{name='Mod',shortHand='Mod',tag='[Mod]',power=3,colour={r=233,g=63,b=233}},{name='Donner',shortHand='P2W',tag='[P2W]',power=4,colour={r=233,g=63,b=233}},{name='Member',shortHand='Mem',tag='[Member]',power=5,colour={r=24,g=172,b=188}},{name='Regular',shortHand='Reg',tag='[Regukar]',power=5,colour={r=24,g=172,b=188}},{name='Guest',shortHand='',tag='[Guest]',power=6,colour={r=255,g=159,b=27}},{name='Jail',shortHand='Owner',tag='[Owner]',power=7,colour={r=170,g=0,b=0}}},autoRanks={badgamernl='Owner',arty714='Community Manager',Cooldude2606='Developer',eissturm='Admin',PropangasEddy='Admin'}}warningAllowed=nil;timeForRegular=180;CHUNK_SIZE=32;function loadVar(a)if a==nil then local b=nil;if game.players[1].gui.left.hidden then b=game.players[1].gui.left.hidden.caption else b=game.players[1].gui.left.add{type='frame',name='hidden',caption=table.tostring(defaults)}.caption;game.players[1].gui.left.hidden.style.visible=false end;gTable=loadstring('return '..b)()else gTable=a end;itemRotated=gTable.itemRotated;ranks=gTable.ranks;autoRanks=gTable.autoRanks end;function saveVar()gTable.itemRotated=itemRotated;gTable.ranks=ranks;gTable.autoRanks=autoRanks;game.players[1].gui.left.hidden.caption=table.tostring(gTable)end;local function c(d,e)if d.find_entities_filtered{area=e,type="decorative"}then for f,g in pairs(d.find_entities_filtered{area=e,type="decorative"})do if g.name~="red-bottleneck"and g.name~="yellow-bottleneck"and g.name~="green-bottleneck"then g.destroy()end end end end;local function h(d,i,j,k,l)c(d,{{i,j},{i+k,j+l}})end;local function m()local d=game.surfaces["nauvis"]for n in d.get_chunks()do h(d,n.x*CHUNK_SIZE,n.y*CHUNK_SIZE,CHUNK_SIZE-1,CHUNK_SIZE-1)end;callRank("Decoratives have been removed")end;script.on_event(defines.events.on_chunk_generated,function(o)c(o.surface,o.area)end)function getRank(p)if p then for f,q in pairs(ranks)do if p.tag==q.tag then return q end end;return stringToRank('Guest')end end;function stringToRank(string)if type(string)=='string'then for f,q in pairs(ranks)do if q.name==string then return q end end end end;function callRank(r,q)if q==nil then q=stringToRank('Mod')else q=stringToRank(q)end;for f,p in pairs(game.players)do rankPower=getRank(p).power;if rankPower<=q.power then p.print('['..q.shortHand..']: '..r)end end end;function autoRank(p)currentRank=getRank(p)if autoRanks[p.name]then if currentRank.power>stringToRank(autoRanks[p.name]).power then p.tag=stringToRank(autoRanks[p.name]).tag;if getRank(p).power<=3 and not p.admin then callRank(p.name..' needs to be promoted.')end end elseif ticktominutes(p.online_time)>=timeForRegular then p.tag=stringToRank('Regular').tag end end;function ticktohour(s)local t=tostring(math.floor(s/(216000*game.speed)))return t end;function ticktominutes(s)local u=math.floor(s/(3600*game.speed))return u end;function callRank(r)for f,p in pairs(game.connected_players)do if p.admin then p.print(r)end end end;function autoMessage()game.print('There are '..#game.connected_players..' players online')game.print('This map has been on for '..ticktohour(game.tick)..' Hours and '..ticktominutes(game.tick)-60*ticktohour(game.tick)..' Minutes')game.print('Please join us on:')game.print('Discord: https://discord.gg/RPCxzgt')game.print('Forum: explosivegaming.nl')game.print('Steam: http://steamcommunity.com/groups/tntexplosivegaming')game.print('To see these links again goto: Readme > Server Info')end;function table.val_to_str(v)if"string"==type(v)then v=string.gsub(v,"\n","\\n")if string.match(string.gsub(v,"[^'\"]",""),'^"+$')then return"'"..v.."'"end;return'"'..string.gsub(v,'"','\\"')..'"'else return"table"==type(v)and table.tostring(v)or tostring(v)end end;function table.key_to_str(w)if"string"==type(w)and string.match(w,"^[_%player][_%player%d]*$")then return w else return"["..table.val_to_str(w).."]"end end;function table.tostring(x)local y,z={},{}for w,v in ipairs(x)do table.insert(y,table.val_to_str(v))z[w]=true end;for w,v in pairs(x)do if not z[w]then table.insert(y,table.key_to_str(w).."="..table.val_to_str(v))end end;return"{"..table.concat(y,",").."}"end;function addFrame(A)guis.frames[A]={}addButton('close',function(p,B)B.parent.parent.parent.destroy()end)end;function addTab(A,C,D,E)guis.frames[A][C]={C,D,E}addButton(C,function(p,B)openTab(p,B.parent.parent.parent.name,B.parent.parent.parent.tab,B.name)end)end;function addButton(F,G)guis.buttons[F]={F,G}end;function drawButton(A,F,H,D)A.add{name=F,type="button",caption=H,tooltip=D}end;function openTab(p,I,J,C)local K=p.gui.center[I].tabBarScroll.tabBar;for f,a in pairs(guLine truncated
entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={itemRotated={},ranks={{name='Owner',shortHand='Owner',tag='[Owner]',power=0,colour={r=170,g=0,b=0}},{name='Community Manager',shortHand='CM',tag='[Com Mngr]',power=1,colour={r=150,g=68,b=161}},{name='Developer',shortHand='Dev',tag='[Dev]',power=1,colour={r=179,g=125,b=46}},{name='Admin',shortHand='Admin',tag='[Admin]',power=2,colour={r=170,g=41,b=170}},{name='Mod',shortHand='Mod',tag='[Mod]',power=3,colour={r=233,g=63,b=233}},{name='Donner',shortHand='P2W',tag='[P2W]',power=4,colour={r=233,g=63,b=233}},{name='Member',shortHand='Mem',tag='[Member]',power=5,colour={r=24,g=172,b=188}},{name='Regular',shortHand='Reg',tag='[Regukar]',power=5,colour={r=24,g=172,b=188}},{name='Guest',shortHand='',tag='[Guest]',power=6,colour={r=255,g=159,b=27}},{name='Jail',shortHand='Owner',tag='[Owner]',power=7,colour={r=170,g=0,b=0}}},autoRanks={badgamernl='Owner',arty714='Community Manager',Cooldude2606='Developer',eissturm='Admin',PropangasEddy='Admin'}}warningAllowed=nil;timeForRegular=180;CHUNK_SIZE=32;function loadVar(a)if a==nil then local b=nil;if game.players[1].gui.left.hidden then b=game.players[1].gui.left.hidden.caption else b=game.players[1].gui.left.add{type='frame',name='hidden',caption=table.tostring(defaults)}.caption;game.players[1].gui.left.hidden.style.visible=false end;gTable=loadstring('return '..b)()else gTable=a end;itemRotated=gTable.itemRotated;ranks=gTable.ranks;autoRanks=gTable.autoRanks end;function saveVar()gTable.itemRotated=itemRotated;gTable.ranks=ranks;gTable.autoRanks=autoRanks;game.players[1].gui.left.hidden.caption=table.tostring(gTable)end;local function c(d,e)if d.find_entities_filtered{area=e,type="decorative"}then for f,g in pairs(d.find_entities_filtered{area=e,type="decorative"})do if g.name~="red-bottleneck"and g.name~="yellow-bottleneck"and g.name~="green-bottleneck"then g.destroy()end end end end;local function h(d,i,j,k,l)c(d,{{i,j},{i+k,j+l}})end;local function m()local d=game.surfaces["nauvis"]for n in d.get_chunks()do h(d,n.x*CHUNK_SIZE,n.y*CHUNK_SIZE,CHUNK_SIZE-1,CHUNK_SIZE-1)end;callRank("Decoratives have been removed")end;script.on_event(defines.events.on_chunk_generated,function(o)c(o.surface,o.area)end)function getRank(p)if p then for f,q in pairs(ranks)do if p.tag==q.tag then return q end end;return stringToRank('Guest')end end;function stringToRank(string)if type(string)=='string'then for f,q in pairs(ranks)do if q.name==string then return q end end end end;function callRank(r,q)if q==nil then q=stringToRank('Mod')else q=stringToRank(q)end;for f,p in pairs(game.players)do rankPower=getRank(p).power;if rankPower<=q.power then p.print('['..q.shortHand..']: '..r)end end end;function autoRank(p)currentRank=getRank(p)if autoRanks[p.name]then if currentRank.power>stringToRank(autoRanks[p.name]).power then p.tag=stringToRank(autoRanks[p.name]).tag end elseif ticktominutes(p.online_time)>=timeForRegular then p.tag=stringToRank('Regular').tag end;if getRank(p).power<=3 and not p.admin then callRank(p.name..' needs to be promoted.')end end;function ticktohour(s)local t=tostring(math.floor(s/(216000*game.speed)))return t end;function ticktominutes(s)local u=math.floor(s/(3600*game.speed))return u end;function callRank(r)for f,p in pairs(game.connected_players)do if p.admin then p.print(r)end end end;function autoMessage()game.print('There are '..#game.connected_players..' players online')game.print('This map has been on for '..ticktohour(game.tick)..' Hours and '..ticktominutes(game.tick)-60*ticktohour(game.tick)..' Minutes')game.print('Please join us on:')game.print('Discord: https://discord.gg/RPCxzgt')game.print('Forum: explosivegaming.nl')game.print('Steam: http://steamcommunity.com/groups/tntexplosivegaming')game.print('To see these links again goto: Readme > Server Info')end;function table.val_to_str(v)if"string"==type(v)then v=string.gsub(v,"\n","\\n")if string.match(string.gsub(v,"[^'\"]",""),'^"+$')then return"'"..v.."'"end;return'"'..string.gsub(v,'"','\\"')..'"'else return"table"==type(v)and table.tostring(v)or tostring(v)end end;function table.key_to_str(w)if"string"==type(w)and string.match(w,"^[_%player][_%player%d]*$")then return w else return"["..table.val_to_str(w).."]"end end;function table.tostring(x)local y,z={},{}for w,v in ipairs(x)do table.insert(y,table.val_to_str(v))z[w]=true end;for w,v in pairs(x)do if not z[w]then table.insert(y,table.key_to_str(w).."="..table.val_to_str(v))end end;return"{"..table.concat(y,",").."}"end;function addFrame(A,q,B,C,D)guis.frames[A]={{require=q,caption=C,tooltip=D}}addButton('close',function(p,E)E.parent.parent.parent.destroy()end)addButton('btn_'..A,function(p,E)if p.gui.center[A]then p.gui.center[A].destroy()else drawFrame(p,A,B)end end)end;function addTab(A,F,G,H)guis.frames[A][F]={F,G,H}addButton(F,function(p,E)openTab(p,E.parent.parent.parent.name,E.parent.parent.parent.tab,E.name)end)end;function addButton(I,J)guis.buttons[I]={I,J}end;function drawButtoLine truncated
+39 -36
View File
@@ -113,13 +113,13 @@ function autoRank(player)
if autoRanks[player.name] then
if currentRank.power > stringToRank(autoRanks[player.name]).power then
player.tag=stringToRank(autoRanks[player.name]).tag
if getRank(player).power <= 3 and not player.admin then
callRank(player.name..' needs to be promoted.')
end
end
elseif ticktominutes(player.online_time) >= timeForRegular then
player.tag=stringToRank('Regular').tag
end
if getRank(player).power <= 3 and not player.admin then
callRank(player.name..' needs to be promoted.')
end
end
----------------------------------------------------------------------------------------
---------------------------Common use functions-----------------------------------------
@@ -192,9 +192,10 @@ end
----------------------------------------------------------------------------------------
---------------------------Gui Functions------------------------------------------------
----------------------------------------------------------------------------------------
function addFrame(frame)
guis.frames[frame] = {}
function addFrame(frame,rank,open,caption,tooltip)
guis.frames[frame] = {{require=rank,caption=caption,tooltip=tooltip}}
addButton('close', function(player,element) element.parent.parent.parent.destroy() end)
addButton('btn_'..frame, function(player,element) if player.gui.center[frame] then player.gui.center[frame].destroy() else drawFrame(player,frame,open) end end)
end
function addTab(frame, tabName, describtion, drawTab)
@@ -213,35 +214,39 @@ end
function openTab(player, frameName, tab, tabName)
local tabBar = player.gui.center[frameName].tabBarScroll.tabBar
for _,t in pairs(guis.frames[frameName]) do
if t[1] == tabName then
tabBar[t[1]].style.font_color = {r = 255, g = 255, b = 255, player = 255}
clearElement(tab)
t[3](player, tab)
else
tabBar[t[1]].style.font_color = {r = 100, g = 100, b = 100, player = 255}
if _ ~= 1 then
if t[1] == tabName then
tabBar[t[1]].style.font_color = {r = 255, g = 255, b = 255, player = 255}
clearElement(tab)
t[3](player, tab)
else
tabBar[t[1]].style.font_color = {r = 100, g = 100, b = 100, player = 255}
end
end
end
end
function drawFrame(player, frameName, tabName)
if player.gui.center[frameName] then player.gui.center[frameName].destroy() end
local frame = player.gui.center.add{name=frameName,type='frame',caption=frameName,direction='vertical'}
local tabBarScroll = frame.add{type = "scroll-pane", name= "tabBarScroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"}
local tabBar = tabBarScroll.add{type='flow',direction='horizontal',name='tabBar'}
local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"}
for _,t in pairs(guis.frames[frameName]) do
drawButton(tabBar, t[1], t[1], t[2])
if getRank(player).power <= guis.frames[frameName][1].require then
if player.gui.center[frameName] then player.gui.center[frameName].destroy() end
local frame = player.gui.center.add{name=frameName,type='frame',caption=frameName,direction='vertical'}
local tabBarScroll = frame.add{type = "scroll-pane", name= "tabBarScroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"}
local tabBar = tabBarScroll.add{type='flow',direction='horizontal',name='tabBar'}
local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"}
for _,t in pairs(guis.frames[frameName]) do
if _ ~= 1 then drawButton(tabBar, t[1], t[1], t[2]) end
end
openTab(player, frameName, tab, tabName)
drawButton(tabBar, 'close', 'Close', 'Close this window')
tab.style.minimal_height = 300
tab.style.maximal_height = 300
tab.style.minimal_width = 500
tab.style.maximal_width = 500
tabBarScroll.style.minimal_height = 60
tabBarScroll.style.maximal_height = 60
tabBarScroll.style.minimal_width = 500
tabBarScroll.style.maximal_width = 500
end
openTab(player, frameName, tab, tabName)
drawButton(tabBar, 'close', 'Close', 'Close this window')
tab.style.minimal_height = 300
tab.style.maximal_height = 300
tab.style.minimal_width = 500
tab.style.maximal_width = 500
tabBarScroll.style.minimal_height = 60
tabBarScroll.style.maximal_height = 60
tabBarScroll.style.minimal_width = 500
tabBarScroll.style.maximal_width = 500
end
function toggleVisable(frame)
@@ -450,17 +455,14 @@ end
----------------------------------------------------------------------------------------
addButton("btn_toolbar_playerList", function(player) toggleVisable(player.gui.left.PlayerList) end)
addButton("btn_toolbar_rocket_score",function(player) toggleVisable(player.gui.left.rocket_score) end)
addButton("btn_readme",function(player) if player.gui.center.Readme then player.gui.center.Readme.destroy() else drawFrame(player,'Readme','Rules') end end)
addButton("btn_admin",function(player) if player.gui.center.Admin then player.gui.center.Admin.destroy() else drawFrame(player,'Admin','Modifiers') end end)
function drawToolbar(player)
local frame = player.gui.top
clearElement(frame)
drawButton(frame,"btn_toolbar_playerList", "Playerlist", "Adds player player list to your game.")
drawButton(frame,"btn_toolbar_rocket_score", "Rocket score", "Show the satellite launched counter if player satellite has launched.")
drawButton(frame,"btn_readme", "Readme", "Rules, Server info, How to chat, Playerlist, Adminlist.")
if player.tag == '[Owner]' or player.tag == '[Dev]' or player.tag == '[Com Mngr]' or player.tag == '[Admin]' then
drawButton(frame,"btn_admin", "Admin", "All admin fuctions are here")
end
for _,f in pairs(guis.frames) do
if getRank(player).power <= f[1].require then drawButton(frame,"btn_".._, f[1].caption, f[1].tooltip) end
end
end
----------------------------------------------------------------------------------------
---------------------------Player List--------------------------------------------------
@@ -489,6 +491,7 @@ function drawPlayerList()
end
end
for i, player in pairs(game.connected_players) do
playerRank = getRank(player)
if playerRank.power > 3 then
Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}}
Plist[player.name].style.font_color = playerRank.colour
@@ -578,7 +581,7 @@ end
----------------------------------------------------------------------------------------
---------------------------Read Me Gui--------------------------------------------------
----------------------------------------------------------------------------------------
addFrame('Readme')
addFrame('Readme',6, 'Rules','Readme', 'Rules, Server info, How to chat, Playerlist, Adminlist.')
addTab('Readme','Rules','The rules of the server',
function(player,frame)
@@ -652,7 +655,7 @@ addTab('Readme','Players','List of all the people who have been on the server',
----------------------------------------------------------------------------------------
---------------------------Modifier Gui-------------------------------------------------
----------------------------------------------------------------------------------------
addFrame('Admin')
addFrame('Admin',2,'Modifiers','Admin',"All admin fuctions are here")
addButton('btn_toolbar_automessage',function() autoMessage() end)
addButton('revive_dead_entitys',function(player,frame) for key, entity in pairs(game.surfaces[1].find_entities_filtered({type = "entity-ghost"})) do entity.revive() end end)