diff --git a/control.lua b/control.lua index 7ded296f..a236c99d 100644 --- a/control.lua +++ b/control.lua @@ -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)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.destroy()end;if r.gui.top.PlayerList~=nil then r.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar()local N=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",N,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,O in pairs(guis.buttons)do if O[1]==m.element.name then if O[2]then O[2](r,m.element)else game.print('Invaid Button'..O[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 y=m.element;local P={}local Q=false;if y.parent.parent.parent.name=='Admin'then Q=true;P[#P+1]='online'end;if y.parent.parent.filterTable.status_input and not Q then local R=y.parent.parent.filterTable.status_input.text;if R=='yes'or R=='online'or R=='true'or R=='y'then P[#P+1]='online'elseif R~=''then P[#P+1]='offline'end end;if y.parent.parent.filterTable.hours_input then local S=y.parent.parent.filterTable.hours_input.text;if tonumber(S)and tonumber(S)>0 then P[#P+1]=tonumber(S)end end;if y.parent.parent.filterTable.name_input then local T=y.parent.parent.filterTable.name_input.text;if T then P[#P+1]=T end end;if y.parent.parent.playerTable then y.parent.parent.playerTable.destroy()end;drawPlayerTable(r,y.parent.parent,Q,P)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(m)local U=game.players[m.player_index]if not U.admin and ticktominutes(U.online_time)=timeForRegular then a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=r.name,style="caption_label_style",caption={"",ticktohour(r.online_time)," H - ",r.name}}a3.gui.left.PlayerList.PlayerListScroll[r.name].style.font_color={r=24,g=172,b=188}r.tag="[Regular]"elseif r.name=="explosivegaming"then for M=10,1,-1 do a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=r.name..M,style="caption_label_style",caption={"",ticktohour(r.online_time)," H - ",r.name,M}}a3.gui.left.PlayerList.PlayerListScroll[r.name..M].style.font_color={r=24,g=172,b=188}r.tag="[TEST]"end else a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=r.name,style="caption_label_style",caption={"",ticktohour(r.online_time)," H - ",r.name}}a3.gui.left.PlayerList.PlayerListScroll[r.name].style.font_color={r=255,g=159,b=27}r.tag="[Guest]"end end end end end;addButton('goto',function(r,y)local a4=game.players[y.parent.name]r.teleport(game.surfaces[a4.surface.name].find_non_colliding_position("player",a4.position,32,1))end)addButton('bring',function(r,y)local a4=game.players[y.parent.name]a4.teleport(game.surfaces[r.surface.name].find_non_colliding_position("player",r.position,32,1))end)addButton('jail',function(r,y)local a4=game.players[y.parent.name]if a4.character then if a4.character.active then a4.character.active=false;a4.tag='[Jail]'drawPlayerList()else a4.character.active=true;a4.tag='[Guest]'drawPlayerList()end end end)addButton('kill',function(r,y)local a4=game.players[y.parent.name]if a4.character then a4.character.die()end end)function drawPlayerTable(r,y,Q,P)y.add{name='playerTable',type="table",colspan=5}y.playerTable.style.minimal_width=500;y.playerTable.style.maximal_width=500;y.playerTable.style.horizontal_spacing=10;y.playerTable.add{name="id",type="label",caption="Id "}y.playerTable.add{name="name",type="label",caption="Name "}if not Q then y.playerTable.add{name="status",type="label",caption="Status "}end;y.playerTable.add{name="online_time",type="label",caption="Online Time "}y.playerTable.add{name="rank",type="label",caption="Rank "}if Q then y.playerTable.add{name="commands",type="label",caption="Commands"}end;for M,a4 in pairs(game.players)do local a5=true;for d,a6 in pairs(P)do if a6=='admin'then if a4.admin==false then a5=false;break end elseif a6=='online'then if a4.connected==false then a5=false;break end elseif a6=='offline'then if a4.connected==true then a5=false;break end elseif type(a6)=='number'then if a6>ticktominutes(a4.online_time)then a5=false;break end elseif type(a6)=='string'then if a4.name:lower():find(a6:lower())==nil then a5=false;break end end end;if a5==true and r.name~=a4.name then if y.playerTable[a4.name]==nil then y.playerTable.add{name=M.."id",type="label",caption=M}y.playerTable.add{name=a4.name..'_name',type="label",caption=a4.name}if not Q then if a4.connected==true then y.playerTable.add{name=a4.name.."Status",type="label",caption="ONLINE"}else y.playerTable.add{name=a4.name.."Status",type="label",caption="OFFLINE"}end end;y.playerTable.add{name=a4.name.."Online_Time",type="label",caption=ticktohour(a4.online_time)..'H '..ticktominutes(a4.online_time)-60*ticktohour(a4.online_time)..'M'}y.playerTable.add{name=a4.name.."Rank",type="label",caption=a4.tag}if Q then y.playerTable.add{name=a4.name,type="flow"}drawButton(y.playerTable[a4.name],'goto','Tp','Goto to the players location')drawButton(y.playerTable[a4.name],'bring','Br','Bring a player to your location')if a4.tag=='[Owner]'or a4.tag=='[Developer]'or a4.tag=='[Com Mngr]'then else drawButton(y.playerTable[a4.name],'jail','Ja','Jail/Unjail a player')drawButton(y.playerTable[a4.name],'kill','Ki','Kill this player')end end end end end end;addFrame('Readme')addTab('Readme','Rules','The rules of the server',function(r,y)local a7={"Hacking/cheating, exploiting and abusing bugs is not allowed.","Do not disrespect any player in the server (This includes staff).","Do not spam, this includes stuff such as chat spam, item spam, chest spam etc.","Do not laydown concrete with bots without permission.","Do not use active provider chests without permission.","Do not remove/move major parts of the factory without permission.","Do not walk in a random direction for no reason(to save map size).","Do not remove stuff just because you don't like it, tell people first.","Do not make train roundabouts.","Trains are Left Hand Drive (LHD) only.","Do not complain about lag, low fps and low ups or other things like that.","Do not ask for rank.","Use common sense and what an admin says goes."}for M,a8 in pairs(a7)do y.add{name=M,type="label",caption={"",M,". ",a8}}end end)addTab('Readme','Server Info','Info about the server',function(r,y)y.add{name=1,type="label",caption={"","Discord voice and chat server:"}}y.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;y.add{name=3,type="label",caption={"","Our forum:"}}y.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;y.add{name=5,type="label",caption={"","Steam:"}}y.add{name=6,type='textfield',text='http://steamcommunity.com/groups/tntexplosivegaming'}.style.minimal_width=400 end)addTab('Readme','How to chat','Just in case you dont know how to chat',function(r,y)local a9={"Chatting for new players can be difficult because it’s different than other games!","It’s very simple, the button you need to press is the “GRAVE/TILDE key”","it’s located under the “ESC key”. If you would like to change the key go to your","controls tab in options. The key you need to change is “Toggle Lua console”","it’s located in the second column 2nd from bottom."}for M,aa in pairs(a9)do y.add{name=M,type="label",caption={"",aa}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(r,y)local ab={"This list contains all the people that are admin in this world. Do you want to become","an admin dont ask for it! an admin will see what you've made and the time you put","in the server."}for M,aa in pairs(ab)do y.add{name=M,type="label",caption={"",aa}}end;drawPlayerTable(r,y,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(r,y)local ac={"These are the players who have supported us in the making of this factory. Without","you the player we wouldn't have been as far as we are now."}for M,aa in pairs(ac)do y.add{name=M,type="label",caption={"",aa}}end;y.add{name='filterTable',type='table',colspan=3}y.filterTable.add{name='name_label',type='label',caption='Name'}y.filterTable.add{name='status_label',type='label',caption='Online?'}y.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}y.filterTable.add{name='name_input',type='textfield'}y.filterTable.add{name='status_input',type='textfield'}y.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(r,y,false,{})end)addFrame('Admin')addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('revive_dead_entitys',function(r,y)for ad,e in pairs(game.surfaces[1].find_entities_filtered({type="entity-ghost"}))do e.revive()end end)addButton('revive_dead_entitys_range',function(r,y)if tonumber(y.parent.range.text)then local ae=tonumber(y.parent.range.text)for ad,e in pairs(game.surfaces[1].find_entities_filtered({area={{r.position.x-ae,r.position.y-ae},{r.position.x+ae,r.position.y+ae}},type="entity-ghost"}))do e.revive()end end end)addButton('remove_biters',function(r,y)for ad,e in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do e.destroy()end end)addButton('tp_all',function(r,y)for M,a4 in pairs(game.connected_players)do local af=game.surfaces[r.surface.name].find_non_colliding_position("player",r.position,32,1)if a4~=r then a4.teleport(af)end end end)addButton('toggle_cheat',function(r,y)r.cheat_mode=not r.cheat_mode end)addButton('add_dev_items',function(r,y)r.insert{name="deconstruction-planner",count=1}r.insert{name="blueprint-book",count=1}r.insert{name="blueprint",count=20}end)addButton("btn_Modifier_apply",function(r,y)local ag={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}for M,ah in pairs(ag)do local ai=tonumber(y.parent.parent.modifierTable[ah.."_input"].text:match("[%d]+[.%d+]"))if ai~=nil then if ai>=0 and ai<50 and ai~=r.force[ah]then r.force[ah]=ai;r.print(ah.." changed to number: "..tostring(ai))elseif ai==r.force[ah]then r.print(ah.." Did not change")else r.print(ah.." needs to be a higher number or it contains an letter")end end end end)addTab('Admin','Commands','Random useful commands',function(r,y)drawButton(y,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(y,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(y,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(y,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in a range')y.add{type='textfield',name='range',text='Range'}drawButton(y,'remove_biters','Kill Biters','Removes all biters in map')drawButton(y,'tp_all','TP All Here','Brings all players to you')drawButton(y,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin','Modifiers','Edit in game modifiers',function(r,y)local ag={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}y.add{type="flow",name="flowNavigation",direction="horizontal"}y.add{name="modifierTable",type="table",colspan=3}y.modifierTable.add{name="name",type="label",caption="name"}y.modifierTable.add{name="input",type="label",caption="input"}y.modifierTable.add{name="current",type="label",caption="current"}for M,ah in pairs(ag)do y.modifierTable.add{name=ah,type="label",caption=ah}y.modifierTable.add{name=ah.."_input",type="textfield",caption="inputTextField"}y.modifierTable.add{name=ah.."_current",type="label",caption=tostring(r.force[ah])}end;drawButton(y.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")end)addTab('Admin','Player List','Send a message to all players',function(r,y)y.add{name='filterTable',type='table',colspan=2}y.filterTable.add{name='name_label',type='label',caption='Name'}y.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}y.filterTable.add{name='name_input',type='textfield'}y.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(r,y,true,{'online'})end) \ No newline at end of file +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.destroy()end;if r.gui.top.PlayerList~=nil then r.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar()local N=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",N,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,O in pairs(guis.buttons)do if O[1]==m.element.name then if O[2]then O[2](r,m.element)else game.print('Invaid Button'..O[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 y=m.element;local P={}local Q=false;if y.parent.parent.parent.name=='Admin'then Q=true;P[#P+1]='online'end;if y.parent.parent.filterTable.status_input and not Q then local R=y.parent.parent.filterTable.status_input.text;if R=='yes'or R=='online'or R=='true'or R=='y'then P[#P+1]='online'elseif R~=''then P[#P+1]='offline'end end;if y.parent.parent.filterTable.hours_input then local S=y.parent.parent.filterTable.hours_input.text;if tonumber(S)and tonumber(S)>0 then P[#P+1]=tonumber(S)end end;if y.parent.parent.filterTable.name_input then local T=y.parent.parent.filterTable.name_input.text;if T then P[#P+1]=T end end;if y.parent.parent.playerTable then y.parent.parent.playerTable.destroy()end;drawPlayerTable(r,y.parent.parent,Q,P)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(m)local U=game.players[m.player_index]if not U.admin and ticktominutes(U.online_time)=timeForRegular then a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=r.name,style="caption_label_style",caption={"",ticktohour(r.online_time)," H - ",r.name}}a3.gui.left.PlayerList.PlayerListScroll[r.name].style.font_color={r=24,g=172,b=188}r.tag="[Regular]"elseif r.name=="explosivegaming"then for M=10,1,-1 do a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=r.name..M,style="caption_label_style",caption={"",ticktohour(r.online_time)," H - ",r.name,M}}a3.gui.left.PlayerList.PlayerListScroll[r.name..M].style.font_color={r=24,g=172,b=188}r.tag="[TEST]"end else a3.gui.left.PlayerList.PlayerListScroll.add{type="label",name=r.name,style="caption_label_style",caption={"",ticktohour(r.online_time)," H - ",r.name}}a3.gui.left.PlayerList.PlayerListScroll[r.name].style.font_color={r=255,g=159,b=27}r.tag="[Guest]"end end end end end;addButton('goto',function(r,y)local a4=game.players[y.parent.name]r.teleport(game.surfaces[a4.surface.name].find_non_colliding_position("player",a4.position,32,1))end)addButton('bring',function(r,y)local a4=game.players[y.parent.name]a4.teleport(game.surfaces[r.surface.name].find_non_colliding_position("player",r.position,32,1))end)addButton('jail',function(r,y)local a4=game.players[y.parent.name]if a4.character then if a4.character.active then a4.character.active=false;a4.tag='[Jail]'drawPlayerList()else a4.character.active=true;a4.tag='[Guest]'drawPlayerList()end end end)addButton('kill',function(r,y)local a4=game.players[y.parent.name]if a4.character then a4.character.die()end end)function drawPlayerTable(r,y,Q,P)y.add{name='playerTable',type="table",colspan=5}y.playerTable.style.minimal_width=500;y.playerTable.style.maximal_width=500;y.playerTable.style.horizontal_spacing=10;y.playerTable.add{name="id",type="label",caption="Id "}y.playerTable.add{name="name",type="label",caption="Name "}if not Q then y.playerTable.add{name="status",type="label",caption="Status "}end;y.playerTable.add{name="online_time",type="label",caption="Online Time "}y.playerTable.add{name="rank",type="label",caption="Rank "}if Q then y.playerTable.add{name="commands",type="label",caption="Commands"}end;for M,a4 in pairs(game.players)do local a5=true;for d,a6 in pairs(P)do if a6=='admin'then if a4.admin==false then a5=false;break end elseif a6=='online'then if a4.connected==false then a5=false;break end elseif a6=='offline'then if a4.connected==true then a5=false;break end elseif type(a6)=='number'then if a6>ticktominutes(a4.online_time)then a5=false;break end elseif type(a6)=='string'then if a4.name:lower():find(a6:lower())==nil then a5=false;break end end end;if a5==true and r.name~=a4.name then if y.playerTable[a4.name]==nil then y.playerTable.add{name=M.."id",type="label",caption=M}y.playerTable.add{name=a4.name..'_name',type="label",caption=a4.name}if not Q then if a4.connected==true then y.playerTable.add{name=a4.name.."Status",type="label",caption="ONLINE"}else y.playerTable.add{name=a4.name.."Status",type="label",caption="OFFLINE"}end end;y.playerTable.add{name=a4.name.."Online_Time",type="label",caption=ticktohour(a4.online_time)..'H '..ticktominutes(a4.online_time)-60*ticktohour(a4.online_time)..'M'}y.playerTable.add{name=a4.name.."Rank",type="label",caption=a4.tag}if Q then y.playerTable.add{name=a4.name,type="flow"}drawButton(y.playerTable[a4.name],'goto','Tp','Goto to the players location')drawButton(y.playerTable[a4.name],'bring','Br','Bring a player to your location')if a4.tag=='[Owner]'or a4.tag=='[Developer]'or a4.tag=='[Com Mngr]'then else drawButton(y.playerTable[a4.name],'jail','Ja','Jail/Unjail a player')drawButton(y.playerTable[a4.name],'kill','Ki','Kill this player')end end end end end end;addFrame('Readme')addTab('Readme','Rules','The rules of the server',function(r,y)local a7={"Hacking/cheating, exploiting and abusing bugs is not allowed.","Do not disrespect any player in the server (This includes staff).","Do not spam, this includes stuff such as chat spam, item spam, chest spam etc.","Do not laydown concrete with bots without permission.","Do not use active provider chests without permission.","Do not remove/move major parts of the factory without permission.","Do not walk in a random direction for no reason(to save map size).","Do not remove stuff just because you don't like it, tell people first.","Do not make train roundabouts.","Trains are Left Hand Drive (LHD) only.","Do not complain about lag, low fps and low ups or other things like that.","Do not ask for rank.","Use common sense and what an admin says goes."}for M,a8 in pairs(a7)do y.add{name=M,type="label",caption={"",M,". ",a8}}end end)addTab('Readme','Server Info','Info about the server',function(r,y)y.add{name=1,type="label",caption={"","Discord voice and chat server:"}}y.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;y.add{name=3,type="label",caption={"","Our forum:"}}y.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;y.add{name=5,type="label",caption={"","Steam:"}}y.add{name=6,type='textfield',text='http://steamcommunity.com/groups/tntexplosivegaming'}.style.minimal_width=400 end)addTab('Readme','How to chat','Just in case you dont know how to chat',function(r,y)local a9={"Chatting for new players can be difficult because it’s different than other games!","It’s very simple, the button you need to press is the “GRAVE/TILDE key”","it’s located under the “ESC key”. If you would like to change the key go to your","controls tab in options. The key you need to change is “Toggle Lua console”","it’s located in the second column 2nd from bottom."}for M,aa in pairs(a9)do y.add{name=M,type="label",caption={"",aa}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(r,y)local ab={"This list contains all the people that are admin in this world. Do you want to become","an admin dont ask for it! an admin will see what you've made and the time you put","in the server."}for M,aa in pairs(ab)do y.add{name=M,type="label",caption={"",aa}}end;drawPlayerTable(r,y,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(r,y)local ac={"These are the players who have supported us in the making of this factory. Without","you the player we wouldn't have been as far as we are now."}for M,aa in pairs(ac)do y.add{name=M,type="label",caption={"",aa}}end;y.add{name='filterTable',type='table',colspan=3}y.filterTable.add{name='name_label',type='label',caption='Name'}y.filterTable.add{name='status_label',type='label',caption='Online?'}y.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}y.filterTable.add{name='name_input',type='textfield'}y.filterTable.add{name='status_input',type='textfield'}y.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(r,y,false,{})end)addFrame('Admin')addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('revive_dead_entitys',function(r,y)for ad,e in pairs(game.surfaces[1].find_entities_filtered({type="entity-ghost"}))do e.revive()end end)addButton('revive_dead_entitys_range',function(r,y)if tonumber(y.parent.range.text)then local ae=tonumber(y.parent.range.text)for ad,e in pairs(game.surfaces[1].find_entities_filtered({area={{r.position.x-ae,r.position.y-ae},{r.position.x+ae,r.position.y+ae}},type="entity-ghost"}))do e.revive()end end end)addButton('remove_biters',function(r,y)for ad,e in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do e.destroy()end end)addButton('tp_all',function(r,y)for M,a4 in pairs(game.connected_players)do local af=game.surfaces[r.surface.name].find_non_colliding_position("player",r.position,32,1)if a4~=r then a4.teleport(af)end end end)addButton('toggle_cheat',function(r,y)r.cheat_mode=not r.cheat_mode end)addButton('add_dev_items',function(r,y)r.insert{name="deconstruction-planner",count=1}r.insert{name="blueprint-book",count=1}r.insert{name="blueprint",count=20}end)addButton("btn_Modifier_apply",function(r,y)local ag={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}for M,ah in pairs(ag)do local ai=tonumber(y.parent.parent.modifierTable[ah.."_input"].text:match("[%d]+[.%d+]"))if ai~=nil then if ai>=0 and ai<50 and ai~=r.force[ah]then r.force[ah]=ai;r.print(ah.." changed to number: "..tostring(ai))elseif ai==r.force[ah]then r.print(ah.." Did not change")else r.print(ah.." needs to be a higher number or it contains an letter")end end end end)addTab('Admin','Commands','Random useful commands',function(r,y)drawButton(y,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(y,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(y,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(y,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in a range')y.add{type='textfield',name='range',text='Range'}drawButton(y,'remove_biters','Kill Biters','Removes all biters in map')drawButton(y,'tp_all','TP All Here','Brings all players to you')drawButton(y,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin','Modifiers','Edit in game modifiers',function(r,y)local ag={"manual_mining_speed_modifier","manual_crafting_speed_modifier","character_running_speed_modifier","worker_robots_speed_modifier","worker_robots_storage_bonus","character_build_distance_bonus","character_item_drop_distance_bonus","character_reach_distance_bonus","character_resource_reach_distance_bonus","character_item_pickup_distance_bonus","character_loot_pickup_distance_bonus"}y.add{type="flow",name="flowNavigation",direction="horizontal"}y.add{name="modifierTable",type="table",colspan=3}y.modifierTable.add{name="name",type="label",caption="name"}y.modifierTable.add{name="input",type="label",caption="input"}y.modifierTable.add{name="current",type="label",caption="current"}for M,ah in pairs(ag)do y.modifierTable.add{name=ah,type="label",caption=ah}y.modifierTable.add{name=ah.."_input",type="textfield",caption="inputTextField"}y.modifierTable.add{name=ah.."_current",type="label",caption=tostring(r.force[ah])}end;drawButton(y.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")end)addTab('Admin','Player List','Send a message to all players',function(r,y)y.add{name='filterTable',type='table',colspan=2}y.filterTable.add{name='name_label',type='label',caption='Name'}y.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}y.filterTable.add{name='name_input',type='textfield'}y.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(r,y,true,{'online'})end) \ No newline at end of file diff --git a/source.lua b/source.lua index 41be9100..16c373f2 100644 --- a/source.lua +++ b/source.lua @@ -64,6 +64,7 @@ function initVar() 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()