Merge branch 'WIP' into Testing

This commit is contained in:
Cooldude2606 committed 2017-04-07 13:12:27 +01:00
commit 77b8d85602
2 files changed
+74 -2

No files matched your search

+1 -1
View File
@@ -1 +1 @@
itemRotated={}entityRemoved={}entityCache={}guis={frames={},buttons={}}warningAllowed=nil;timeForRegular=180;CHUNK_SIZE=32;local function a(b,c)if b.find_entities_filtered{area=c,type="decorative"}then for d,e in pairs(b.find_entities_filtered{area=c,type="decorative"})do if e.name~="red-bottleneck"and e.name~="yellow-bottleneck"and e.name~="green-bottleneck"then e.destroy()end end end end;local function f(b,g,h,i,j)a(b,{{g,h},{g+i,h+j}})end;local function k()local b=game.surfaces["nauvis"]for l in b.get_chunks()do f(b,l.x*CHUNK_SIZE,l.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(m)a(m.surface,m.area)end)function ticktohour(n)local o=tostring(math.floor(n/(216000*game.speed)))return o end;function ticktominutes(n)local p=math.floor(n/(3600*game.speed))return p end;function callAdmin(q)for d,r in pairs(game.connected_players)do if r.admin then r.print(q)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 addFrame(s)guis.frames[s]={}addButton('close',function(r,t)t.parent.parent.parent.destroy()end)end;function addTab(s,u,v,w)guis.frames[s][u]={u,v,w}addButton(u,function(r,t)openTab(r,t.parent.parent.parent.name,t.parent.parent.parent.tab,t.name)end)end;function addButton(x,y)guis.buttons[x]={x,y}end;function drawButton(s,x,z,v)s.add{name=x,type="button",caption=z,tooltip=v}end;function openTab(r,A,B,u)local C=r.gui.center[A].tabBarScroll.tabBar;for d,D in pairs(guis.frames[A])do if D[1]==u then C[D[1]].style.font_color={r=255,g=255,b=255,a=255}clearElement(B)D[3](r,B)else C[D[1]].style.font_color={r=100,g=100,b=100,a=255}end end end;function drawFrame(r,A,u)if r.gui.center[A]then r.gui.center[A].destroy()end;local s=r.gui.center.add{name=A,type='frame',caption=A,direction='vertical'}local E=s.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local C=E.add{type='flow',direction='horizontal',name='tabBar'}local B=s.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for d,D in pairs(guis.frames[A])do drawButton(C,D[1],D[1],D[2])end;openTab(r,A,B,u)drawButton(C,'close','Close','Close this window')B.style.minimal_height=300;B.style.maximal_height=300;B.style.minimal_width=500;B.style.maximal_width=500;E.style.minimal_height=60;E.style.maximal_height=60;E.style.minimal_width=500;E.style.maximal_width=500 end;function toggleVisable(s)if s then if s.style.visible==nil then s.style.visible=false else s.style.visible=not s.style.visible end end end;function clearElement(F)if F~=nil then for G,t in pairs(F.children_names)do F[t].destroy()end end end;script.on_event(defines.events.on_player_created,function(m)local r=game.players[m.player_index]r.insert{name="iron-plate",count=8}r.insert{name="pistol",count=1}r.insert{name="firearm-magazine",count=10}r.insert{name="burner-mining-drill",count=1}r.insert{name="stone-furnace",count=1}r.force.chart(r.surface,{{r.position.x-200,r.position.y-200},{r.position.x+200,r.position.y+200}})end)script.on_event(defines.events.on_player_respawned,function(m)local r=game.players[m.player_index]drawPlayerList()r.insert{name="pistol",count=1}r.insert{name="firearm-magazine",count=10}end)script.on_event(defines.events.on_player_joined_game,function(m)local r=game.players[m.player_index]r.print({"","Welcome"})if r.gui.left.PlayerList~=nil then r.gui.left.PlayerList.destroy()end;if r.gui.center.README~=nil then r.gui.center.README.destroy()end;if r.gui.top.PlayerList~=nil then r.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar()local H=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",H,false,0)if not r.admin and ticktominutes(r.online_time)<1 then drawFrame(r,'Readme','Rules')end end)script.on_event(defines.events.on_player_left_game,function(m)local r=game.players[m.player_index]drawPlayerList()end)script.on_event(defines.events.on_gui_click,function(m)local r=game.players[m.player_index]for d,I in pairs(guis.buttons)do if I[1]==m.element.name then if I[2]then I[2](r,m.element)else game.print('Invaid Button'..I[1])end;break end end end)script.on_event(defines.events.on_gui_text_changed,function(m)local r=game.players[m.player_index]if m.element.parent.parent.filterTable then local s=m.element;local J={}local K=false;if s.parent.parent.parent.name=='Admin'then K=true;J[#J+1]='online'end;if s.parent.parent.filterTable.status_input and not K then local L=s.parent.paLine truncated
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
+73 -1
View File
@@ -1,13 +1,40 @@
itemRotated = {}
entityRemoved = {}
entityCache = {}
guis = {frames={},buttons={}}
--functions can not be included in the default list or be added by code
defaults = {
itemRotated = {},
test = 0
}
warningAllowed = nil
timeForRegular = 180
CHUNK_SIZE = 32
function loadVar(t)
game.print('load')
if t == nil then
local g = nil
if game.players[1].gui.left.hidden then
g = game.players[1].gui.left.hidden.caption
else
g = 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 '..g)()
game.print(g)
else gTable = t 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
----------------------------------------------------------------------------------------
---------------------------Remove decorations-------------------------------------------
----------------------------------------------------------------------------------------
@@ -68,6 +95,44 @@ function autoMessage()
game.print('To see these links again goto: Readme > Server Info')
end
----------------------------------------------------------------------------------------
---------------------------Table Functions----------------------------------------------
----------------------------------------------------------------------------------------
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 ( k )
if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
return k
else
return "[" .. table.val_to_str( k ) .. "]"
end
end
function table.tostring( tbl )
local result, done = {}, {}
for k, v in ipairs( tbl ) do
table.insert( result, table.val_to_str( v ) )
done[ k ] = true
end
for k, v in pairs( tbl ) do
if not done[ k ] then
table.insert( result,
table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
end
end
return "{" .. table.concat( result, "," ) .. "}"
end
----------------------------------------------------------------------------------------
---------------------------Gui Functions------------------------------------------------
----------------------------------------------------------------------------------------
function addFrame(frame)
@@ -160,6 +225,10 @@ script.on_event(defines.events.on_player_respawned, function(event)
end)
script.on_event(defines.events.on_player_joined_game, function(event)
loadVar()
test = test + 1
saveVar()
game.print(test)
local player = game.players[event.player_index]
player.print({"", "Welcome"})
if player.gui.left.PlayerList ~= nil then
@@ -195,6 +264,9 @@ script.on_event(defines.events.on_gui_click, function(event)
break
end
end
test = test + 1
saveVar()
game.print(test)
end)
script.on_event(defines.events.on_gui_text_changed, function(event)