Start Of Old to New Rank system (0.15 pre)

This commit is contained in:
Cooldude2606 committed 2017-04-07 13:36:22 +01:00
1 parent 83736bfeb2
commit c1cee6256d
2 files changed
+56 -8

No files matched your search

+1 -1
View File
@@ -1 +1 @@
entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={itemRotated={},test=0}warningAllowed=nil;timeForRegular=180;CHUNK_SIZE=32;function loadVar(a)game.print('load')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)()game.print(b)else gTable=a end;itemRotated=gTable.itemRotated;test=gTable.test end;function saveVar()gTable.itemRotated=itemRotated;gTable.test=test;game.print('save '..table.tostring(gTable))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;callAdmin("Decoratives have been removed")end;script.on_event(defines.events.on_chunk_generated,function(o)c(o.surface,o.area)end)function ticktohour(p)local q=tostring(math.floor(p/(216000*game.speed)))return q end;function ticktominutes(p)local r=math.floor(p/(3600*game.speed))return r end;function callAdmin(s)for f,t in pairs(game.connected_players)do if t.admin then t.print(s)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(u)if"string"==type(u)then u=string.gsub(u,"\n","\\n")if string.match(string.gsub(u,"[^'\"]",""),'^"+$')then return"'"..u.."'"end;return'"'..string.gsub(u,'"','\\"')..'"'else return"table"==type(u)and table.tostring(u)or tostring(u)end end;function table.key_to_str(v)if"string"==type(v)and string.match(v,"^[_%a][_%a%d]*$")then return v else return"["..table.val_to_str(v).."]"end end;function table.tostring(w)local x,y={},{}for v,u in ipairs(w)do table.insert(x,table.val_to_str(u))y[v]=true end;for v,u in pairs(w)do if not y[v]then table.insert(x,table.key_to_str(v).."="..table.val_to_str(u))end end;return"{"..table.concat(x,",").."}"end;function addFrame(z)guis.frames[z]={}addButton('close',function(t,A)A.parent.parent.parent.destroy()end)end;function addTab(z,B,C,D)guis.frames[z][B]={B,C,D}addButton(B,function(t,A)openTab(t,A.parent.parent.parent.name,A.parent.parent.parent.tab,A.name)end)end;function addButton(E,F)guis.buttons[E]={E,F}end;function drawButton(z,E,G,C)z.add{name=E,type="button",caption=G,tooltip=C}end;function openTab(t,H,I,B)local J=t.gui.center[H].tabBarScroll.tabBar;for f,a in pairs(guis.frames[H])do if a[1]==B then J[a[1]].style.font_color={r=255,g=255,b=255,a=255}clearElement(I)a[3](t,I)else J[a[1]].style.font_color={r=100,g=100,b=100,a=255}end end end;function drawFrame(t,H,B)if t.gui.center[H]then t.gui.center[H].destroy()end;local z=t.gui.center.add{name=H,type='frame',caption=H,direction='vertical'}local K=z.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local J=K.add{type='flow',direction='horizontal',name='tabBar'}local I=z.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for f,a in pairs(guis.frames[H])do drawButton(J,a[1],a[1],a[2])end;openTab(t,H,I,B)drawButton(J,'close','Close','Close this window')I.style.minimal_height=300;I.style.maximal_height=300;I.style.minimal_width=500;I.style.maximal_width=500;K.style.minimal_height=60;K.style.maximal_height=60;K.style.minimal_width=500;K.style.maximal_width=500 end;function toggleVisable(z)if z then if z.style.visible==nil then z.style.visible=false else z.style.visible=not z.style.visible end end end;function clearElement(L)if L~=nil then for M,A in pairs(L.children_names)do L[A].destroy()end end end;script.on_event(defines.events.on_player_created,function(o)local t=game.players[o.player_index]t.insert{name="iron-plate",count=8}t.insert{name="pistol",count=1}t.insert{name="firearm-magazine",count=10}t.insert{name="burner-mining-drill",count=1}t.insert{name="stone-furnace",count=1}t.force.chart(t.surface,{{t.position.x-200,t.position.y-200},{t.position.x+200,t.position.y+200}})end)script.on_event(defines.events.on_player_respawned,function(o)local t=game.players[o.player_index]drawPlayerList()t.insert{name="pistol",count=1}t.insert{name="firearm-magazineLine truncated
entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={itemRotated={},test=0,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}}},autoRank={badgamernl='Owner',arty714='Community Manager',Cooldude2606='Developer',eissturm='Admin',PropangasEddy='Admin'}}warningAllowed=nil;timeForRegular=180;CHUNK_SIZE=32;function loadVar(a)game.print('load')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)()game.print(b)else gTable=a end;itemRotated=gTable.itemRotated;test=gTable.test;ranks=gTable.ranks;autoRank=gTable.autoRank end;function saveVar()gTable.itemRotated=itemRotated;gTable.test=test;gTable.ranks=ranks;gTable.autoRank=autoRank;game.print('save '..table.tostring(gTable))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 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=3 else q=q.power end;for f,p in pairs(game.players)do rankPower=getRank(p).power;if rankPower<=q then p.print(r)end 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,"^[_%a][_%a%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(guis.frames[I])do if a[1]==C then K[a[1]].style.font_color={r=255,g=255,b=255,a=255}clearElement(J)a[3](p,J)else K[a[1]].style.font_color={r=100,g=100,b=100,a=255}end end end;function drawFrame(p,I,C)if p.gui.center[I]then p.gui.center[I].destroy()end;local A=p.gui.center.add{name=I,type='frame',caption=I,direction='vertical'}local L=A.add{type="scrLine truncated
+55 -7
View File
@@ -5,7 +5,26 @@ guis = {frames={},buttons={}}
--functions can not be included in the default list or be added by code
defaults = {
itemRotated = {},
test = 0
test = 0,
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}}
},
autoRank={
badgamernl='Owner',
arty714='Community Manager',
Cooldude2606='Developer',
eissturm='Admin',PropangasEddy='Admin'
--insert other player ranks here
}
}
warningAllowed = nil
@@ -27,11 +46,15 @@ function loadVar(t)
else gTable = t end
itemRotated = gTable.itemRotated
test = gTable.test
ranks= gTable.ranks
autoRank= gTable.autoRank
end
function saveVar()
gTable.itemRotated = itemRotated
gTable.test = test
gTable.ranks = ranks
gTable.autoRank = autoRank
game.print('save '..table.tostring(gTable))
game.players[1].gui.left.hidden.caption = table.tostring(gTable)
end
@@ -57,15 +80,40 @@ local function clearDecorations()
for chunk in surface.get_chunks() do
removeDecorations(surface, chunk.x * CHUNK_SIZE, chunk.y * CHUNK_SIZE, CHUNK_SIZE - 1, CHUNK_SIZE - 1)
end
callAdmin("Decoratives have been removed")
callRank("Decoratives have been removed")
end
script.on_event(defines.events.on_chunk_generated, function(event)
removeDecorationsArea( event.surface, event.area )
end)
----------------------------------------------------------------------------------------
---------------------------Common use functions---------------------------------------
---------------------------Rank functions-----------------------------------------------
----------------------------------------------------------------------------------------
function getRank(player)
if player then
for _,rank in pairs(ranks) do
if player.tag == rank.tag then return rank end
end
end
end
function stringToRank(string)
if type(string) == 'string' then
for _,rank in pairs(ranks) do
if rank.name == string then return rank end
end
end
end
function callRank(msg, rank)
if rank == nil then rank = 3 else rank = rank.power end -- default mod or higher
for _, player in pairs(game.players) do
rankPower = getRank(player).power
if rankPower <= rank then player.print(msg) end
end
end
----------------------------------------------------------------------------------------
---------------------------Common use functions-----------------------------------------
----------------------------------------------------------------------------------------
function ticktohour (tick)
local hour = tostring(math.floor(tick/(216000*game.speed)))
@@ -77,7 +125,7 @@ function ticktominutes (tick)
return minutes
end
function callAdmin(msg)
function callRank(msg)
for _, player in pairs(game.connected_players) do
if player.admin then
player.print(msg)
@@ -300,7 +348,7 @@ script.on_event(defines.events.on_marked_for_deconstruction, function(event)
if event.entity.type ~= "tree" and event.entity.type ~= "simple-entity" then
event.entity.cancel_deconstruction("player")
eplayer.print("You are not allowed to do this yet, play for a bit longer. Try again in about: " .. math.floor((timeForRegular - ticktominutes(eplayer.online_time))) .. " minutes")
callAdmin(eplayer.name .. " tryed to deconstruced something")
callRank(eplayer.name .. " tryed to deconstruced something")
end
elseif event.entity.type == "tree" or event.entity.type == "simple-entity" then
event.entity.destroy()
@@ -314,7 +362,7 @@ script.on_event(defines.events.on_built_entity, function(event)
if event.created_entity.type == "tile-ghost" then
event.created_entity.destroy()
eplayer.print("You are not allowed to do this yet, play for a bit longer. Try: " .. math.floor((timeForRegular - ticktominutes(eplayer.online_time))) .. " minutes")
callAdmin(eplayer.name .. " tryed to place concrete/stone with robots")
callRank(eplayer.name .. " tryed to place concrete/stone with robots")
end
end
end)