mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-12 07:54:52 +09:00
Working Globle Table
This commit is contained in:
1 parent
2d102e4f4b
commit
83736bfeb2
2 files changed
+36
-12
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
itemRotated={}entityRemoved={}entityCache={}guis={frames={},buttons={}}defaults={test={1,2,3},test2='test',test3=5}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 initVar()local s=nil;if game.players[1].gui.left.hidden then s=game.players[1].gui.left.hidden.caption else s=game.players[1].gui.left.add{type='frame',name='hidden',caption=table.tostring(defaults)}.caption end;gTable=loadstring('return '..s)()game.print(s)game.print(gTable.test[1])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(t)if"string"==type(t)then t=string.gsub(t,"\n","\\n")if string.match(string.gsub(t,"[^'\"]",""),'^"+$')then return"'"..t.."'"end;return'"'..string.gsub(t,'"','\\"')..'"'else return"table"==type(t)and table.tostring(t)or tostring(t)end end;function table.key_to_str(u)if"string"==type(u)and string.match(u,"^[_%a][_%a%d]*$")then return u else return"["..table.val_to_str(u).."]"end end;function table.tostring(v)local w,x={},{}for u,t in ipairs(v)do table.insert(w,table.val_to_str(t))x[u]=true end;for u,t in pairs(v)do if not x[u]then table.insert(w,table.key_to_str(u).."="..table.val_to_str(t))end end;return"{"..table.concat(w,",").."}"end;function addFrame(y)guis.frames[y]={}addButton('close',function(r,z)z.parent.parent.parent.destroy()end)end;function addTab(y,A,B,C)guis.frames[y][A]={A,B,C}addButton(A,function(r,z)openTab(r,z.parent.parent.parent.name,z.parent.parent.parent.tab,z.name)end)end;function addButton(D,E)guis.buttons[D]={D,E}end;function drawButton(y,D,F,B)y.add{name=D,type="button",caption=F,tooltip=B}end;function openTab(r,G,H,A)local I=r.gui.center[G].tabBarScroll.tabBar;for d,J in pairs(guis.frames[G])do if J[1]==A then I[J[1]].style.font_color={r=255,g=255,b=255,a=255}clearElement(H)J[3](r,H)else I[J[1]].style.font_color={r=100,g=100,b=100,a=255}end end end;function drawFrame(r,G,A)if r.gui.center[G]then r.gui.center[G].destroy()end;local y=r.gui.center.add{name=G,type='frame',caption=G,direction='vertical'}local K=y.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local I=K.add{type='flow',direction='horizontal',name='tabBar'}local H=y.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for d,J in pairs(guis.frames[G])do drawButton(I,J[1],J[1],J[2])end;openTab(r,G,H,A)drawButton(I,'close','Close','Close this window')H.style.minimal_height=300;H.style.maximal_height=300;H.style.minimal_width=500;H.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(y)if y then if y.style.visible==nil then y.style.visible=false else y.style.visible=not y.style.visible end end end;function clearElement(L)if L~=nil then for M,z in pairs(L.children_names)do L[z].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)initVar()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.destrLine 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
|
||||
+35
-11
@@ -1,14 +1,40 @@
|
||||
|
||||
itemRotated = {}
|
||||
entityRemoved = {}
|
||||
entityCache = {}
|
||||
guis = {frames={},buttons={}}
|
||||
defaults = {test={1,2,3},test2='test',test3=5}
|
||||
--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-------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
@@ -59,14 +85,6 @@ function callAdmin(msg)
|
||||
end
|
||||
end
|
||||
|
||||
function initVar()
|
||||
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 end
|
||||
gTable = loadstring('return '..g)()
|
||||
game.print(g)
|
||||
game.print(gTable.test[1])
|
||||
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')
|
||||
@@ -207,7 +225,10 @@ script.on_event(defines.events.on_player_respawned, function(event)
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_joined_game, function(event)
|
||||
initVar()
|
||||
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
|
||||
@@ -243,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)
|
||||
|
||||
Reference in new issue
Block a user