From 89fd43c05c692a1e4fc1e87cbe887dcb9ad43a7a Mon Sep 17 00:00:00 2001 From: Cooldude2606 Date: Fri, 7 Apr 2017 20:07:00 +0100 Subject: [PATCH] Many Many Bug Fixes Later --- control.lua | 2 +- source.lua | 66 +++++++++++++++++++++++++++++------------------------ 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/control.lua b/control.lua index ac4661f4..139cc1bd 100644 --- a/control.lua +++ b/control.lua @@ -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='Donator',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={Owner={'badgamernl'},['Community Manager']={'arty714'},Developer={'Cooldude2606'},Admin={'eissturm','PropangasEddy'},Mod={'Alanore','Aquaday','cafeslacker','CrashKonijn','Drahc_pro','Flip','freek18','Hobbitkicker','hud','Matthias','MeDDish','Mindxt20','MottledPetrel','Mr_Happy_212','Phoenix27833','Sand3r205','ScarbVis','Smou','steentje77','TopHatGaming123'},Donator={},Member={},Regular={},Guest={},Jail={}},selected={}}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;selected=gTable.selected end;function saveVar()gTable.itemRotated=itemRotated;gTable.ranks=ranks;gTable.autoRanks=autoRanks;selected=gTable.selected;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(q)if q then for f,rank in pairs(ranks)do if q.tag==rank.tag then return rank end end;return stringToRank('Guest')end end;function stringToRank(string)if type(string)=='string'then for f,rank in pairs(ranks)do if rank.name==string then return rank end end end end;function callRank(r,rank,s)if rank==nil then rank=stringToRank('Mod')else rank=stringToRank(rank)end;for f,q in pairs(game.players)do rankPower=getRank(q).power;if s then if rankPower>=rank.power then q.print('['..rank.shortHand..']: '..r)end else if rankPower<=rank.power then q.print('['..rank.shortHand..']: '..r)end end end end;function giveRank(q,rank,t)local t=t or'system'oldRank=getRank(q)local u='demoted'if rank.power<=oldRank.power then u='promoted'end;callRank(q.name..' was '..u..' to '..rank.name..' by '..byplayer,oldRank)q.tag=rank.tag;drawToolbar(q)drawPlayerList()end;function autoRank(q)local v=getRank(q)local w=nil;for rank,x in pairs(autoRanks)do local y=false;for f,p in pairs(x)do if q.name==p then w=stringToRank(rank)y=true;break end end;if y then break end end;if w then if v.power>w.power then q.tag=w.tag end elseif ticktominutes(q.online_time)>=timeForRegular then q.tag=stringToRank('Regular').tag end;if getRank(q).power<=3 and not q.admin then callRank(q.name..' needs to be promoted.')end end;function ticktohour(z)local A=tostring(math.floor(z/(216000*game.speed)))return A end;function ticktominutes(z)local B=math.floor(z/(3600*game.speed))return B end;function callRank(r)for f,q in pairs(game.connected_players)do if q.admin then q.print(r)end end end;function clearSelection(q)selected[q.index]={}end;function autoMessage()rank=stringToRank('Regular')hrank=stringToRank('Mod')callRank('There are '..#game.connected_players..' players online',hrank,true)callRank('This map has been on for '..ticktohour(game.tick)..' Hours and '..ticktominutes(game.tick)-60*ticktohour(game.tick)..' Minutes',hrank,true)callRank('Please join us on:',rank,true)callRank('Discord: https://discord.gg/RPCxzgt',rank,true)callRank('Forum: explosivegaming.nl',rank,true)callRank('Steam: http://steamcommunity.com/groups/tntexplosivegaming',rank,true)callRank('To see these links again goto: Readme > Server Info',rank,true)end;function table.val_to_str(C)if"string"==type(C)then C=string.gsub(C,"\n","\\n")if string.match(string.gsub(C,"[^'\"]",""),'^"+$')then return"'"..C.."'"end;return'"'..string.gsub(C,'"','\\"')..'"'else return"table"==type(C)and table.tostring(C)or tostring(C)end end;function table.key_to_str(D)if"string"==type(D)and string.match(D,"^[_%player][_%player%d]*$")then return D else return"["..table.val_to_str(D).."]"end end;function table.tostring(E)local F,G={},{}for D,C in ipairs(E)do table.insert(F,table.val_to_str(C))G[D]=true end;for D,C in pairs(E)do if not G[D]then table.insert(F,table.key_to_str(D).."="..table.val_to_str(C))end end;return"{"..table.concat(F,",").."}"end;function addFrame(H,rank,I,J,K)guis.frames[H]={{require=rank,caption=J,tooltip=K}}addButton('close',function(q,L)L.parent.parent.parent.destroy()end)addButton('btn_'..H,function(q,L)if q.gui.center[H]then q.gui.center[H].destroy()else drawFrame(q,H,I)end end)end;function addTab(H,M,N,O)guis.frames[H][M]={M,N,O}addButton(M,function(q,L)openTab(q,L.parent.parent.parent.name,L.parent.parent.parent.tab,L.name)end)end;function addButton(P,Q)guis.buttons[P]={P,Q}end;function drawButton(H,P,J,N)H.add{name=P,type="button",caption=J,tooltip=N}end;function openTab(q,R,S,M)local T=q.gui.center[R].tabBarScroll.tabBar;for f,a in pairs(guis.frames[R])do if f~=1 then if a[1]==M then T[a[1]].style.font_color={r=255,g=255,b=255,player=255}clearElement(S)a[3](q,S)else T[a[1]].style.font_color={r=100,g=100,b=100,player=255}end end end end;function drawFrame(q,R,M)if getRank(q).power<=guis.frames[R][1].require then if q.gui.center[R]then q.gui.center[R].destroy()end;local H=q.gui.center.add{name=R,type='frame',caption=R,direction='vertical'}local U=H.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local T=U.add{type='flow',direction='horizontal',name='tabBar'}local S=H.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for f,a in pairs(guis.frames[R])do if f~=1 then drawButton(T,a[1],a[1],a[2])end end;openTab(q,R,S,M)drawButton(T,'close','Close','Close this window')S.style.minimal_height=300;S.style.maximal_height=300;S.style.minimal_width=500;S.style.maximal_width=500;U.style.minimal_height=60;U.style.maximal_height=60;U.style.minimal_width=500;U.style.maximal_width=500 end end;function toggleVisable(H)if H then if H.style.visible==nil then H.style.visible=false else H.style.visible=not H.style.visible end end end;function clearElement(V)if V~=nil then for W,L in pairs(V.children_names)do V[L].destroy()end end end;script.on_event(defines.events.on_player_created,function(o)local q=game.players[o.player_index]q.insert{name="iron-plate",count=8}q.insert{name="pistol",count=1}q.insert{name="firearm-magazine",count=10}q.insert{name="burner-mining-drill",count=1}q.insert{name="stone-furnace",count=1}q.force.chart(q.surface,{{q.position.x-200,q.position.y-200},{q.position.x+200,q.position.y+200}})end)script.on_event(defines.events.on_player_respawned,function(o)local q=game.players[o.player_index]drawPlayerList()q.insert{name="pistol",count=1}q.insert{name="firearm-magazine",count=10}end)script.on_event(defines.events.on_player_joined_game,function(o)loadVar()local q=game.players[o.player_index]autoRank(q)q.print({"","Welcome"})if q.gui.left.PlayerList~=nil then q.gui.left.PlayerList.destroy()end;if q.gui.center.README~=nil then q.gui.center.README.destroy()end;if q.gui.top.PlayerList~=nil then q.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar(q)local X=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",X,false,0)if not q.admin and ticktominutes(q.online_time)<1 then drawFrame(q,'Readme','Rules')end end)script.on_event(defines.events.on_player_left_game,function(o)local q=game.players[o.player_index]drawPlayerList()end)script.on_event(defines.events.on_gui_click,function(o)local q=game.players[o.player_index]if o.element.type=='button'then for f,Y in pairs(guis.buttons)do if Y[1]==o.element.name then if Y[2]then Y[2](q,o.element)else game.print('Invaid Button'..Y[1])end;break end end elseif o.element.type=='checkbox'then if o.element.name=='select'then if not selected[o.player_index]then selected[o.player_index]={}end;if o.element.state then table.insert(selected[o.player_index],o.element.parent.name)else for f,Z in pairs(selected[o.player_index])do if Z==o.element.parent.name then table.remove(selected[o.player_index],f)break end end end end end end)script.on_event(defines.events.on_gui_text_changed,function(o)local q=game.players[o.player_index]if o.element.parent.parent.filterTable then local H=o.element;local _={}local a0=false;local a1=false;if H.parent.parent.parent.name=='Admin'then a0=true;_[#_+1]='online'end;if H.parent.parent.parent.name=='Admin+'then a1=true;_[#_+1]='lower'end;if H.parent.parent.filterTable.status_input and not a0 then local a2=H.parent.parent.filterTable.status_input.text;if a2=='yes'or a2=='online'or a2=='true'or a2=='y'then _[#_+1]='online'elseif a2~=''then _[#_+1]='offline'end end;if H.parent.parent.filterTable.hours_input then local a3=H.parent.parent.filterTable.hours_input.text;if tonumber(a3)and tonumber(a3)>0 then _[#_+1]=tonumber(a3)end end;if H.parent.parent.filterTable.name_input then local a4=H.parent.parent.filterTable.name_input.text;if a4 then _[#_+1]=a4 end end;if H.parent.parent.filterTable.sel_input then local a5=H.parent.parent.filterTable.name_input.text;if a5=='yes'or a5=='online'or a5=='true'or a5=='y'then _[#_+1]='selected'end end;if H.parent.parent.playerTable then H.parent.parent.playerTable.destroy()end;drawPlayerTable(q,H.parent.parent,a0,a1,_)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(o)local a6=game.players[o.player_index]if not a6.admin and ticktominutes(a6.online_time)3 then if playerRank.shortHand~=''then Plist.add{type="label",name=q.name,style="caption_label_style",caption={"",ticktohour(q.online_time)," H - ",q.name,' - '..playerRank.shortHand}}else Plist.add{type="label",name=q.name,style="caption_label_style",caption={"",ticktohour(q.online_time)," H - ",q.name}}end;Plist[q.name].style.font_color=playerRank.colour;q.tag=playerRank.tag end end end end;addButton('goto',function(q,H)local p=game.players[H.parent.name]q.teleport(game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1))end)addButton('bring',function(q,H)local p=game.players[H.parent.name]p.teleport(game.surfaces[q.surface.name].find_non_colliding_position("player",q.position,32,1))end)addButton('jail',function(q,H)local p=game.players[H.parent.name]if p.character then if p.character.active then p.character.active=false;p.tag='[Jail]'drawPlayerList()else p.character.active=true;p.tag='[Guest]'drawPlayerList()end end end)addButton('kill',function(q,H)local p=game.players[H.parent.name]if p.character then p.character.die()end end)function drawPlayerTable(q,H,a0,a1,_)H.add{name='playerTable',type="table",colspan=5}H.playerTable.style.minimal_width=500;H.playerTable.style.maximal_width=500;H.playerTable.style.horizontal_spacing=10;H.playerTable.add{name="id",type="label",caption="Id "}H.playerTable.add{name="name",type="label",caption="Name "}if a0==false and a1==false then H.playerTable.add{name="status",type="label",caption="Status "}end;H.playerTable.add{name="online_time",type="label",caption="Online Time "}H.playerTable.add{name="rank",type="label",caption="Rank "}if a0 then H.playerTable.add{name="commands",type="label",caption="Commands"}end;if a1 then H.playerTable.add{name="select",type="label",caption="Selection"}end;for W,p in pairs(game.players)do local ag=true;for f,ah in pairs(_)do if ah=='admin'then if p.admin==false then ag=false;break end elseif ah=='online'then if p.connected==false then ag=false;break end elseif ah=='offline'then if p.connected==true then ag=false;break end elseif ah=='lower'then if getRank(p).power<=getRank(q.power)then ag=false;break end elseif ah=='selected'then if H.playerTable[p.name].state==false then ag=false;break end elseif type(ah)=='number'then if ah>ticktominutes(p.online_time)then ag=false;break end elseif type(ah)=='string'then if p.name:lower():find(ah:lower())==nil then ag=false;break end end end;if ag==true and q.name~=p.name then if H.playerTable[p.name]==nil then H.playerTable.add{name=W.."id",type="label",caption=W}H.playerTable.add{name=p.name..'_name',type="label",caption=p.name}if not a0 then if p.connected==true then H.playerTable.add{name=p.name.."Status",type="label",caption="ONLINE"}else H.playerTable.add{name=p.name.."Status",type="label",caption="OFFLINE"}end end;H.playerTable.add{name=p.name.."Online_Time",type="label",caption=ticktohour(p.online_time)..'H '..ticktominutes(p.online_time)-60*ticktohour(p.online_time)..'M'}H.playerTable.add{name=p.name.."Rank",type="label",caption=p.tag}if a0 then H.playerTable.add{name=p.name,type="flow"}drawButton(H.playerTable[p.name],'goto','Tp','Goto to the players location')drawButton(H.playerTable[p.name],'bring','Br','Bring player player to your location')if getRank(p).power>=getRank(q).power then else drawButton(H.playerTable[p.name],'jail','Ja','Jail/Unjail player player')drawButton(H.playerTable[p.name],'kill','Ki','Kill this player')end elseif a1 then H.playerTable.add{name=p.name,type="flow"}local ai=false;for f,Z in pairs(selected[q.index])do if Z==p.name then ai=true;break end end;H.playerTable.add{name='select',type="checkbox",state=ai}end end end end end;addFrame('Readme',6,'Rules','Readme','Rules, Server info, How to chat, Playerlist, Adminlist.')addTab('Readme','Rules','The rules of the server',function(q,H)local aj={"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 player 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 W,ak in pairs(aj)do H.add{name=W,type="label",caption={"",W,". ",ak}}end end)addTab('Readme','Server Info','Info about the server',function(q,H)H.add{name=1,type="label",caption={"","Discord voice and chat server:"}}H.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;H.add{name=3,type="label",caption={"","Our forum:"}}H.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;H.add{name=5,type="label",caption={"","Steam:"}}H.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(q,H)local al={"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 W,am in pairs(al)do H.add{name=W,type="label",caption={"",am}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(q,H)local an={"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 W,am in pairs(an)do H.add{name=W,type="label",caption={"",am}}end;drawPlayerTable(q,H,false,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(q,H)local x={"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 W,am in pairs(x)do H.add{name=W,type="label",caption={"",am}}end;H.add{name='filterTable',type='table',colspan=3}H.filterTable.add{name='name_label',type='label',caption='Name'}H.filterTable.add{name='status_label',type='label',caption='Online?'}H.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}H.filterTable.add{name='name_input',type='textfield'}H.filterTable.add{name='status_input',type='textfield'}H.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(q,H,false,false,{})end)addFrame('Admin',2,'Player List','Admin',"All admin fuctions are here")addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('tp_all',function(q,H)for W,p in pairs(game.connected_players)do local ao=game.surfaces[q.surface.name].find_non_colliding_position("player",q.position,32,1)if p~=q then p.teleport(ao)end end end)addButton('revive_dead_entitys_range',function(q,H)if tonumber(H.parent.range.text)then local ap=tonumber(H.parent.range.text)for aq,g in pairs(game.surfaces[1].find_entities_filtered({area={{q.position.x-ap,q.position.y-ap},{q.position.x+ap,q.position.y+ap}},type="entity-ghost"}))do g.revive()end end end)addButton('add_dev_items',function(q,H)q.insert{name="deconstruction-planner",count=1}q.insert{name="blueprint-book",count=1}q.insert{name="blueprint",count=20}end)addButton('setRanks',function(q,H)rank=stringToRank(H.parent.rank.rank_input.text)if rank then for f,ar in pairs(selected[q.index])do p=game.players[ar]if getRank(q).powergetRank(p)then giveRank(p,rank,q)else q.print('You can not edit '..p.name..' rank there rank or the rank you have slected is too high')end end end end)addButton('clearSelection',function(q,as)clearSelection(q)end)addTab('Admin','Commands','Random useful commands',function(q,H)drawButton(H,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(H,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(H,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range')H.add{type='textfield',name='range',text='Range'}drawButton(H,'tp_all','TP All Here','Brings all players to you')end)addTab('Admin','Edit Ranks','Edit the ranks of players below you',function(q,H)clearSelection(q)H.add{name='filterTable',type='table',colspan=2}H.filterTable.add{name='name_label',type='label',caption='Name'}H.filterTable.add{name='sel_label',type='label',caption='Selected?'}H.filterTable.add{name='name_input',type='textfield'}H.filterTable.add{name='sel_input',type='textfield'}H.add{type='flow',name='rank',direction='horizontal'}H.rank.add{name='rank_label',type='label',caption='Rank'}H.rank.add{name='rank_input',type='textfield'}drawButton(H.rank,'setRanks','Set Ranks','Sets the rank of all selected players')drawButton(H.rank,'clearSelection','Clear Selection','Clears all currently selected players')drawPlayerTable(q,H,false,true,{})end)addTab('Admin','Player List','Send player message to all players',function(q,H)H.add{name='filterTable',type='table',colspan=2}H.filterTable.add{name='name_label',type='label',caption='Name'}H.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}H.filterTable.add{name='name_input',type='textfield'}H.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(q,H,true,false,{'online'})end)addFrame('Admin+',1,'Modifiers','Admin+',"Because we are better")addButton('remove_biters',function(q,H)for aq,g in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do g.destroy()end end)addButton('toggle_cheat',function(q,H)q.cheat_mode=not q.cheat_mode end)addButton('revive_dead_entitys',function(q,H)for aq,g in pairs(game.surfaces[1].find_entities_filtered({type="entity-ghost"}))do g.revive()end end)addButton("btn_Modifier_apply",function(q,H)local at={"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 W,au in pairs(at)do local av=tonumber(H.parent.parent.modifierTable[au.."_input"].text:match("[%d]+[.%d+]"))if av~=nil then if av>=0 and av<50 and av~=q.force[au]then q.force[au]=av;q.print(au.." changed to number: "..tostring(av))elseif av==q.force[au]then q.print(au.." Did not change")else q.print(au.." needs to be player higher number or it contains an letter")end end end end)addTab('Admin+','Commands','Random useful commands',function(q,H)drawButton(H,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(H,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(H,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(H,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range')H.add{type='textfield',name='range',text='Range'}drawButton(H,'remove_biters','Kill Biters','Removes all biters in map')drawButton(H,'tp_all','TP All Here','Brings all players to you')drawButton(H,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin+','Modifiers','Edit in game modifiers',function(q,H)local at={"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"}H.add{type="flow",name="flowNavigation",direction="horizontal"}H.add{name="modifierTable",type="table",colspan=3}H.modifierTable.add{name="name",type="label",caption="name"}H.modifierTable.add{name="input",type="label",caption="input"}H.modifierTable.add{name="current",type="label",caption="current"}for W,au in pairs(at)do H.modifierTable.add{name=au,type="label",caption=au}H.modifierTable.add{name=au.."_input",type="textfield",caption="inputTextField"}H.modifierTable.add{name=au.."_current",type="label",caption=tostring(q.force[au])}end;drawButton(H.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")end) \ No newline at end of file +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='Donator',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='Jail',tag='[Jail]',power=7,colour={r=170,g=0,b=0}}},autoRanks={Owner={'badgamernl'},['Community Manager']={'arty714'},Developer={'Cooldude2606'},Admin={'eissturm','PropangasEddy'},Mod={'Alanore','Aquaday','cafeslacker','CrashKonijn','Drahc_pro','Flip','freek18','Hobbitkicker','hud','Matthias','MeDDish','Mindxt20','MottledPetrel','Mr_Happy_212','Phoenix27833','Sand3r205','ScarbVis','Smou','steentje77','TopHatGaming123'},Donator={},Member={},Regular={},Guest={},Jail={}},selected={}}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;selected=gTable.selected end;function saveVar()gTable.itemRotated=itemRotated;gTable.ranks=ranks;gTable.autoRanks=autoRanks;selected=gTable.selected;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(q)if q then for f,rank in pairs(ranks)do if q.tag==rank.tag then return rank end end;return stringToRank('Guest')end end;function stringToRank(string)if type(string)=='string'then for f,rank in pairs(ranks)do if rank.name==string then return rank end end end end;function callRank(r,rank,s)local rank=stringToRank(rank)or stringToRank('Mod')local s=s or false;for f,q in pairs(game.players)do rankPower=getRank(q).power;if s then if rankPower>=rank.power then q.print(r)end else if rankPower<=rank.power then q.print('['..rank.shortHand..']: '..r)end end end end;function giveRank(q,rank,t)local t=t or'system'oldRank=getRank(q)local u='demoted'if rank.power<=oldRank.power then u='promoted'end;callRank(q.name..' was '..u..' to '..rank.name..' by '..t.name,oldRank.name)q.tag=rank.tag;drawToolbar(q)drawPlayerList()end;function autoRank(q)local v=getRank(q)local w=nil;for rank,x in pairs(autoRanks)do local y=false;for f,p in pairs(x)do if q.name==p then w=stringToRank(rank)y=true;break end end;if y then break end end;if w then if v.power>w.power then q.tag=w.tag end elseif ticktominutes(q.online_time)>=timeForRegular then q.tag=stringToRank('Regular').tag end;if getRank(q).power<=3 and not q.admin then callRank(q.name..' needs to be promoted.')end end;function ticktohour(z)local A=tostring(math.floor(z/(216000*game.speed)))return A end;function ticktominutes(z)local B=math.floor(z/(3600*game.speed))return B end;function clearSelection(q)selected[q.index]={}end;function autoMessage()rank=stringToRank('Regular')hrank=stringToRank('Mod')callRank('There are '..#game.connected_players..' players online',hrank,true)callRank('This map has been on for '..ticktohour(game.tick)..' Hours and '..ticktominutes(game.tick)-60*ticktohour(game.tick)..' Minutes',hrank,true)callRank('Please join us on:',rank,true)callRank('Discord: https://discord.gg/RPCxzgt',rank,true)callRank('Forum: explosivegaming.nl',rank,true)callRank('Steam: http://steamcommunity.com/groups/tntexplosivegaming',rank,true)callRank('To see these links again goto: Readme > Server Info',rank,true)end;function table.val_to_str(C)if"string"==type(C)then C=string.gsub(C,"\n","\\n")if string.match(string.gsub(C,"[^'\"]",""),'^"+$')then return"'"..C.."'"end;return'"'..string.gsub(C,'"','\\"')..'"'else return"table"==type(C)and table.tostring(C)or tostring(C)end end;function table.key_to_str(D)if"string"==type(D)and string.match(D,"^[_%player][_%player%d]*$")then return D else return"["..table.val_to_str(D).."]"end end;function table.tostring(E)local F,G={},{}for D,C in ipairs(E)do table.insert(F,table.val_to_str(C))G[D]=true end;for D,C in pairs(E)do if not G[D]then table.insert(F,table.key_to_str(D).."="..table.val_to_str(C))end end;return"{"..table.concat(F,",").."}"end;function addFrame(H,rank,I,J,K)guis.frames[H]={{require=rank,caption=J,tooltip=K}}addButton('close',function(q,L)L.parent.parent.parent.destroy()end)addButton('btn_'..H,function(q,L)if q.gui.center[H]then q.gui.center[H].destroy()else drawFrame(q,H,I)end end)end;function addTab(H,M,N,O)guis.frames[H][M]={M,N,O}addButton(M,function(q,L)openTab(q,L.parent.parent.parent.name,L.parent.parent.parent.tab,L.name)end)end;function addButton(P,Q)guis.buttons[P]={P,Q}end;function drawButton(H,P,J,N)H.add{name=P,type="button",caption=J,tooltip=N}end;function openTab(q,R,S,M)local T=q.gui.center[R].tabBarScroll.tabBar;for f,a in pairs(guis.frames[R])do if f~=1 then if a[1]==M then T[a[1]].style.font_color={r=255,g=255,b=255,player=255}clearElement(S)a[3](q,S)else T[a[1]].style.font_color={r=100,g=100,b=100,player=255}end end end end;function drawFrame(q,R,M)if getRank(q).power<=guis.frames[R][1].require then if q.gui.center[R]then q.gui.center[R].destroy()end;local H=q.gui.center.add{name=R,type='frame',caption=R,direction='vertical'}local U=H.add{type="scroll-pane",name="tabBarScroll",vertical_scroll_policy="never",horizontal_scroll_policy="always"}local T=U.add{type='flow',direction='horizontal',name='tabBar'}local S=H.add{type="scroll-pane",name="tab",vertical_scroll_policy="auto",horizontal_scroll_policy="never"}for f,a in pairs(guis.frames[R])do if f~=1 then drawButton(T,a[1],a[1],a[2])end end;openTab(q,R,S,M)drawButton(T,'close','Close','Close this window')S.style.minimal_height=300;S.style.maximal_height=300;S.style.minimal_width=500;S.style.maximal_width=500;U.style.minimal_height=60;U.style.maximal_height=60;U.style.minimal_width=500;U.style.maximal_width=500 end end;function toggleVisable(H)if H then if H.style.visible==nil then H.style.visible=false else H.style.visible=not H.style.visible end end end;function clearElement(V)if V~=nil then for W,L in pairs(V.children_names)do V[L].destroy()end end end;script.on_event(defines.events.on_player_created,function(o)local q=game.players[o.player_index]q.insert{name="iron-plate",count=8}q.insert{name="pistol",count=1}q.insert{name="firearm-magazine",count=10}q.insert{name="burner-mining-drill",count=1}q.insert{name="stone-furnace",count=1}q.force.chart(q.surface,{{q.position.x-200,q.position.y-200},{q.position.x+200,q.position.y+200}})end)script.on_event(defines.events.on_player_respawned,function(o)local q=game.players[o.player_index]drawPlayerList()q.insert{name="pistol",count=1}q.insert{name="firearm-magazine",count=10}end)script.on_event(defines.events.on_player_joined_game,function(o)loadVar()local q=game.players[o.player_index]autoRank(q)q.print({"","Welcome"})if q.gui.left.PlayerList~=nil then q.gui.left.PlayerList.destroy()end;if q.gui.center.README~=nil then q.gui.center.README.destroy()end;if q.gui.top.PlayerList~=nil then q.gui.top.PlayerList.destroy()end;drawPlayerList()drawToolbar(q)local X=encode(game.players,"players",{"name","admin","online_time","connected","index"})game.write_file("players.json",X,false,0)if not q.admin and ticktominutes(q.online_time)<1 then drawFrame(q,'Readme','Rules')end end)script.on_event(defines.events.on_player_left_game,function(o)local q=game.players[o.player_index]drawPlayerList()end)script.on_event(defines.events.on_gui_click,function(o)local q=game.players[o.player_index]if o.element.type=='button'then for f,Y in pairs(guis.buttons)do if Y[1]==o.element.name then if Y[2]then Y[2](q,o.element)else game.print('Invaid Button'..Y[1])end;break end end elseif o.element.type=='checkbox'then if o.element.name=='select'then if not selected[o.player_index]then selected[o.player_index]={}end;if o.element.state then table.insert(selected[o.player_index],o.element.parent.name)else for f,Z in pairs(selected[o.player_index])do if Z==o.element.parent.name then table.remove(selected[o.player_index],f)break end end end end end end)script.on_event(defines.events.on_gui_text_changed,function(o)local q=game.players[o.player_index]if o.element.parent.name=='filterTable'then local H=o.element;local _={}local a0=false;local a1=false;if H.parent.parent.parent.name=='Admin'and not H.parent.sel_input then a0=true;_[#_+1]='online'end;if H.parent.parent.parent.name=='Admin'and H.parent.sel_input then a1=true;_[#_+1]='lower'end;if H.parent.parent.filterTable.status_input and not a0 then local a2=H.parent.parent.filterTable.status_input.text;if a2=='yes'or a2=='online'or a2=='true'or a2=='y'then _[#_+1]='online'elseif a2~=''then _[#_+1]='offline'end end;if H.parent.parent.filterTable.hours_input then local a3=H.parent.parent.filterTable.hours_input.text;if tonumber(a3)and tonumber(a3)>0 then _[#_+1]=tonumber(a3)end end;if H.parent.parent.filterTable.name_input then local a4=H.parent.parent.filterTable.name_input.text;if a4 then _[#_+1]=a4 end end;if H.parent.parent.filterTable.sel_input then local a5=H.parent.parent.filterTable.sel_input.text;if a5=='yes'or a5=='online'or a5=='true'or a5=='y'then _[#_+1]='selected'end end;if H.parent.parent.playerTable then H.parent.parent.playerTable.destroy()end;drawPlayerTable(q,H.parent.parent,a0,a1,_)end end)script.on_event(defines.events.on_marked_for_deconstruction,function(o)local a6=game.players[o.player_index]if not a6.admin and ticktominutes(a6.online_time)3 then if playerRank.shortHand~=''then Plist.add{type="label",name=q.name,style="caption_label_style",caption={"",ticktohour(q.online_time)," H - ",q.name,' - '..playerRank.shortHand}}else Plist.add{type="label",name=q.name,style="caption_label_style",caption={"",ticktohour(q.online_time)," H - ",q.name}}end;Plist[q.name].style.font_color=playerRank.colour;q.tag=playerRank.tag end end end end;addButton('goto',function(q,H)local p=game.players[H.parent.name]q.teleport(game.surfaces[p.surface.name].find_non_colliding_position("player",p.position,32,1))end)addButton('bring',function(q,H)local p=game.players[H.parent.name]p.teleport(game.surfaces[q.surface.name].find_non_colliding_position("player",q.position,32,1))end)addButton('jail',function(q,H)local p=game.players[H.parent.name]if p.character then if p.character.active then p.character.active=false;p.tag='[Jail]'drawPlayerList()else p.character.active=true;p.tag='[Guest]'drawPlayerList()end end end)addButton('kill',function(q,H)local p=game.players[H.parent.name]if p.character then p.character.die()end end)function drawPlayerTable(q,H,a0,a1,_)if H.playerTable then H.playerTable.destroy()end;H.add{name='playerTable',type="table",colspan=5}H.playerTable.style.minimal_width=500;H.playerTable.style.maximal_width=500;H.playerTable.style.horizontal_spacing=10;H.playerTable.add{name="id",type="label",caption="Id "}H.playerTable.add{name="name",type="label",caption="Name "}if a0==false and a1==false then H.playerTable.add{name="status",type="label",caption="Status "}end;H.playerTable.add{name="online_time",type="label",caption="Online Time "}H.playerTable.add{name="rank",type="label",caption="Rank "}if a0 then H.playerTable.add{name="commands",type="label",caption="Commands"}end;if a1 then H.playerTable.add{name="select_label",type="label",caption="Selection"}end;for W,p in pairs(game.players)do local ag=true;for f,ah in pairs(_)do if ah=='admin'then if p.admin==false then ag=false;break end elseif ah=='online'then if p.connected==false then ag=false;break end elseif ah=='offline'then if p.connected==true then ag=false;break end elseif ah=='lower'then if getRank(p).power<=getRank(q).power then ag=false;break end elseif ah=='selected'then local y=nil;for f,Z in pairs(selected[q.index])do if Z==p.name then y=true;break end end;if not y then ag=false;break end elseif type(ah)=='number'then if ah>ticktominutes(p.online_time)then ag=false;break end elseif type(ah)=='string'then if p.name:lower():find(ah:lower())==nil then ag=false;break end end end;if ag==true and q.name~=p.name then if H.playerTable[p.name]==nil then H.playerTable.add{name=W.."id",type="label",caption=W}H.playerTable.add{name=p.name..'_name',type="label",caption=p.name}if not a0 and not a1 then if p.connected==true then H.playerTable.add{name=p.name.."Status",type="label",caption="ONLINE"}else H.playerTable.add{name=p.name.."Status",type="label",caption="OFFLINE"}end end;H.playerTable.add{name=p.name.."Online_Time",type="label",caption=ticktohour(p.online_time)..'H '..ticktominutes(p.online_time)-60*ticktohour(p.online_time)..'M'}H.playerTable.add{name=p.name.."Rank",type="label",caption=p.tag}if a0 then H.playerTable.add{name=p.name,type="flow"}drawButton(H.playerTable[p.name],'goto','Tp','Goto to the players location')drawButton(H.playerTable[p.name],'bring','Br','Bring player player to your location')if getRank(p).power>=getRank(q).power then drawButton(H.playerTable[p.name],'jail','Ja','Jail/Unjail player player')drawButton(H.playerTable[p.name],'kill','Ki','Kill this player')end elseif a1 then H.playerTable.add{name=p.name,type="flow"}local ai=false;for f,Z in pairs(selected[q.index])do if Z==p.name then ai=true;break end end;H.playerTable[p.name].add{name='select',type="checkbox",state=ai}end end end end end;addFrame('Readme',6,'Rules','Readme','Rules, Server info, How to chat, Playerlist, Adminlist.')addTab('Readme','Rules','The rules of the server',function(q,H)local aj={"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 player 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 W,ak in pairs(aj)do H.add{name=W,type="label",caption={"",W,". ",ak}}end end)addTab('Readme','Server Info','Info about the server',function(q,H)H.add{name=1,type="label",caption={"","Discord voice and chat server:"}}H.add{name=2,type='textfield',text='https://discord.gg/RPCxzgt'}.style.minimal_width=400;H.add{name=3,type="label",caption={"","Our forum:"}}H.add{name=4,type='textfield',text='https://explosivegaming.nl'}.style.minimal_width=400;H.add{name=5,type="label",caption={"","Steam:"}}H.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(q,H)local al={"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 W,am in pairs(al)do H.add{name=W,type="label",caption={"",am}}end end)addTab('Readme','Admins','List of all the people who can ban you :P',function(q,H)local an={"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 W,am in pairs(an)do H.add{name=W,type="label",caption={"",am}}end;drawPlayerTable(q,H,false,false,{'admin'})end)addTab('Readme','Players','List of all the people who have been on the server',function(q,H)local x={"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 W,am in pairs(x)do H.add{name=W,type="label",caption={"",am}}end;H.add{name='filterTable',type='table',colspan=3}H.filterTable.add{name='name_label',type='label',caption='Name'}H.filterTable.add{name='status_label',type='label',caption='Online?'}H.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}H.filterTable.add{name='name_input',type='textfield'}H.filterTable.add{name='status_input',type='textfield'}H.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(q,H,false,false,{})end)addFrame('Admin',2,'Player List','Admin',"All admin fuctions are here")addButton('btn_toolbar_automessage',function()autoMessage()end)addButton('tp_all',function(q,H)for W,p in pairs(game.connected_players)do local ao=game.surfaces[q.surface.name].find_non_colliding_position("player",q.position,32,1)if p~=q then p.teleport(ao)end end end)addButton('revive_dead_entitys_range',function(q,H)if tonumber(H.parent.range.text)then local ap=tonumber(H.parent.range.text)for aq,g in pairs(game.surfaces[1].find_entities_filtered({area={{q.position.x-ap,q.position.y-ap},{q.position.x+ap,q.position.y+ap}},type="entity-ghost"}))do g.revive()end end end)addButton('add_dev_items',function(q,H)q.insert{name="deconstruction-planner",count=1}q.insert{name="blueprint-book",count=1}q.insert{name="blueprint",count=20}end)addButton('sendMessage',function(q,H)callRank(H.parent.message.message.text,H.parent.message.rank.text)end)addButton('setRanks',function(q,H)rank=stringToRank(H.parent.rank_input.text)if rank then for f,ar in pairs(selected[q.index])do p=game.players[ar]if getRank(q).powergetRank(q).power then giveRank(p,rank,q)else q.print('You can not edit '..p.name.."'s rank there rank is too high (or the rank you have slected is above you)")end end else q.print(H.parent.rank_input.text..' is not a Rank, Ranks are:')for f,rank in pairs(ranks)do if rank.power>getRank(q).power then q.print(rank.name)end end end end)addButton('clearSelection',function(q,H)clearSelection(q)drawPlayerTable(q,H.parent.parent,false,true,{})end)addTab('Admin','Commands','Random useful commands',function(q,H)drawButton(H,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(H,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(H,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range')H.add{type='textfield',name='range',text='Range'}H.add{type='flow',name='message'}H.message.add{type='textfield',name='message',text='Enter message'}H.message.add{type='textfield',name='rank',text='Endter rank'}drawButton(H,'sendMessage','Send Message','Send a message to all ranks higher than the slected')drawButton(H,'tp_all','TP All Here','Brings all players to you')end)addTab('Admin','Edit Ranks','Edit the ranks of players below you',function(q,H)clearSelection(q)H.add{name='filterTable',type='table',colspan=2}H.filterTable.add{name='name_label',type='label',caption='Name'}H.filterTable.add{name='sel_label',type='label',caption='Selected?'}H.filterTable.add{name='name_input',type='textfield'}H.filterTable.add{name='sel_input',type='textfield'}H.add{type='flow',name='rank',direction='horizontal'}H.rank.add{name='rank_label',type='label',caption='Rank'}H.rank.add{name='rank_input',type='textfield'}drawButton(H.rank,'setRanks','Set Ranks','Sets the rank of all selected players')drawButton(H.rank,'clearSelection','Clear Selection','Clears all currently selected players')drawPlayerTable(q,H,false,true,{'lower'})end)addTab('Admin','Player List','Send player message to all players',function(q,H)H.add{name='filterTable',type='table',colspan=2}H.filterTable.add{name='name_label',type='label',caption='Name'}H.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}H.filterTable.add{name='name_input',type='textfield'}H.filterTable.add{name='hours_input',type='textfield'}drawPlayerTable(q,H,true,false,{'online'})end)addFrame('Admin+',1,'Modifiers','Admin+',"Because we are better")addButton('remove_biters',function(q,H)for aq,g in pairs(game.surfaces[1].find_entities_filtered({force='enemy'}))do g.destroy()end end)addButton('toggle_cheat',function(q,H)q.cheat_mode=not q.cheat_mode end)addButton('revive_dead_entitys',function(q,H)for aq,g in pairs(game.surfaces[1].find_entities_filtered({type="entity-ghost"}))do g.revive()end end)addButton("btn_Modifier_apply",function(q,H)local as={"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 W,at in pairs(as)do local au=tonumber(H.parent.parent.modifierTable[at.."_input"].text:match("[%d]+[.%d+]"))if au~=nil then if au>=0 and au<50 and au~=q.force[at]then q.force[at]=au;q.print(at.." changed to number: "..tostring(au))elseif au==q.force[at]then q.print(at.." Did not change")else q.print(at.." needs to be player higher number or it contains an letter")end end end end)addTab('Admin+','Commands','Random useful commands',function(q,H)drawButton(H,'btn_toolbar_automessage','Auto Message','Send the auto message to all online players')drawButton(H,'add_dev_items','Get Blueprints','Get all the blueprints')drawButton(H,'revive_dead_entitys','Revive All Entitys','Brings all dead machines back to life')drawButton(H,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range')H.add{type='textfield',name='range',text='Range'}drawButton(H,'remove_biters','Kill Biters','Removes all biters in map')drawButton(H,'tp_all','TP All Here','Brings all players to you')drawButton(H,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')end)addTab('Admin+','Modifiers','Edit in game modifiers',function(q,H)local as={"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"}H.add{type="flow",name="flowNavigation",direction="horizontal"}H.add{name="modifierTable",type="table",colspan=3}H.modifierTable.add{name="name",type="label",caption="name"}H.modifierTable.add{name="input",type="label",caption="input"}H.modifierTable.add{name="current",type="label",caption="current"}for W,at in pairs(as)do H.modifierTable.add{name=at,type="label",caption=at}H.modifierTable.add{name=at.."_input",type="textfield",caption="inputTextField"}H.modifierTable.add{name=at.."_current",type="label",caption=tostring(q.force[at])}end;drawButton(H.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")end) \ No newline at end of file diff --git a/source.lua b/source.lua index 69a780d9..b643a112 100644 --- a/source.lua +++ b/source.lua @@ -15,7 +15,7 @@ defaults = { {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}} + {name='Jail',shortHand='Jail',tag='[Jail]',power=7,colour={r=170,g=0,b=0}} }, autoRanks={ Owner={'badgamernl'}, @@ -109,11 +109,17 @@ function stringToRank(string) end function callRank(msg, rank, inv) - if rank == nil then rank = stringToRank('Mod') else rank = stringToRank(rank) end -- default mod or higher + local rank = stringToRank(rank) or stringToRank('Mod') -- default mod or higher + local inv = inv or false for _, player in pairs(game.players) do rankPower = getRank(player).power - if inv then if rankPower >= rank.power then player.print('['..rank.shortHand..']: '..msg) end else - if rankPower <= rank.power then player.print('['..rank.shortHand..']: '..msg) end + if inv then if rankPower >= rank.power then player.print(msg) end else + if rankPower <= rank.power then + if rank.shortHand then + player.print(('['..(rank.shortHand)..']: '..msg)) + else + player.print(('[Everyone]: '..msg)) + end end end end @@ -123,7 +129,7 @@ function giveRank(player,rank,byPlayer) oldRank = getRank(player) local message = 'demoted' if rank.power <= oldRank.power then message = 'promoted' end - callRank(player.name..' was '..message..' to '..rank.name..' by '..byplayer,oldRank) + callRank(player.name..' was '..message..' to '..rank.name..' by '..byPlayer.name,oldRank.name) player.tag = rank.tag drawToolbar(player) drawPlayerList() @@ -163,14 +169,6 @@ function ticktominutes (tick) return minutes end -function callRank(msg) - for _, player in pairs(game.connected_players) do - if player.admin then - player.print(msg) - end - end -end - function clearSelection(player) selected[player.index] = {} end @@ -376,13 +374,13 @@ end) script.on_event(defines.events.on_gui_text_changed, function(event) local player = game.players[event.player_index] - if event.element.parent.parent.filterTable then + if event.element.parent.name == 'filterTable' then local frame = event.element local filters = {} local commands = false local select = false - if frame.parent.parent.parent.name == 'Admin' then commands = true filters[#filters+1] = 'online' end - if frame.parent.parent.parent.name == 'Admin+' then select = true filters[#filters+1] = 'lower' end + if frame.parent.parent.parent.name == 'Admin' and not frame.parent.sel_input then commands = true filters[#filters+1] = 'online' end + if frame.parent.parent.parent.name == 'Admin' and frame.parent.sel_input then select = true filters[#filters+1] = 'lower' end if frame.parent.parent.filterTable.status_input and not commands then local status_input = frame.parent.parent.filterTable.status_input.text if status_input == 'yes' or status_input == 'online' or status_input == 'true' or status_input == 'y' then filters[#filters+1] = 'online' @@ -394,7 +392,7 @@ script.on_event(defines.events.on_gui_text_changed, function(event) local name_input = frame.parent.parent.filterTable.name_input.text if name_input then filters[#filters+1] = name_input end end if frame.parent.parent.filterTable.sel_input then - local sel_input = frame.parent.parent.filterTable.name_input.text + local sel_input = frame.parent.parent.filterTable.sel_input.text if sel_input == 'yes' or sel_input == 'online' or sel_input == 'true' or sel_input == 'y' then filters[#filters+1] = 'selected' end end if frame.parent.parent.playerTable then frame.parent.parent.playerTable.destroy() end @@ -587,6 +585,7 @@ addButton('kill', if p.character then p.character.die() end end) function drawPlayerTable(player, frame, commands, select,filters) + if frame.playerTable then frame.playerTable.destroy() end frame.add{name='playerTable', type="table", colspan=5} frame.playerTable.style.minimal_width = 500 frame.playerTable.style.maximal_width = 500 @@ -597,15 +596,15 @@ function drawPlayerTable(player, frame, commands, select,filters) frame.playerTable.add{name="online_time", type="label", caption="Online Time "} frame.playerTable.add{name="rank", type="label", caption="Rank "} if commands then frame.playerTable.add{name="commands", type="label", caption="Commands"} end - if select then frame.playerTable.add{name="select", type="label", caption="Selection"} end + if select then frame.playerTable.add{name="select_label", type="label", caption="Selection"} end for i, p in pairs(game.players) do local addPlayer = true for _,filter in pairs(filters) do if filter == 'admin' then if p.admin == false then addPlayer = false break end elseif filter == 'online' then if p.connected == false then addPlayer = false break end elseif filter == 'offline' then if p.connected == true then addPlayer = false break end - elseif filter == 'lower' then if getRank(p).power <= getRank(player.power) then addPlayer = false break end - elseif filter == 'selected' then if frame.playerTable[p.name].state == false then addPlayer = false break end + elseif filter == 'lower' then if getRank(p).power <= getRank(player).power then addPlayer = false break end + elseif filter == 'selected' then local Break = nil for _,name in pairs(selected[player.index]) do if name == p.name then Break = true break end end if not Break then addPlayer = false break end elseif type(filter)=='number' then if filter > ticktominutes(p.online_time) then addPlayer = false break end elseif type(filter)=='string' then if p.name:lower():find(filter:lower()) == nil then addPlayer = false break end end @@ -614,7 +613,7 @@ function drawPlayerTable(player, frame, commands, select,filters) if frame.playerTable[p.name] == nil then frame.playerTable.add{name=i .. "id", type="label", caption=i} frame.playerTable.add{name=p.name..'_name', type="label", caption=p.name} - if not commands then + if not commands and not select then if p.connected == true then frame.playerTable.add{name=p.name .. "Status", type="label", caption="ONLINE"} else @@ -627,7 +626,7 @@ function drawPlayerTable(player, frame, commands, select,filters) frame.playerTable.add{name=p.name, type="flow"} drawButton(frame.playerTable[p.name],'goto','Tp','Goto to the players location') drawButton(frame.playerTable[p.name],'bring','Br','Bring player player to your location') - if getRank(p).power >= getRank(player).power then else + if getRank(p).power >= getRank(player).power then drawButton(frame.playerTable[p.name],'jail','Ja','Jail/Unjail player player') drawButton(frame.playerTable[p.name],'kill','Ki','Kill this player') end @@ -635,7 +634,7 @@ function drawPlayerTable(player, frame, commands, select,filters) frame.playerTable.add{name=p.name, type="flow"} local state = false for _,name in pairs(selected[player.index]) do if name == p.name then state = true break end end - frame.playerTable.add{name='select', type="checkbox",state=state} + frame.playerTable[p.name].add{name='select', type="checkbox",state=state} end end end @@ -724,21 +723,24 @@ addButton('btn_toolbar_automessage',function() autoMessage() end) addButton('tp_all',function(player,frame) for i,p in pairs(game.connected_players) do local pos = game.surfaces[player.surface.name].find_non_colliding_position("player", player.position, 32, 1) if p ~= player then p.teleport(pos) end end end) addButton('revive_dead_entitys_range',function(player,frame) if tonumber(frame.parent.range.text) then local range = tonumber(frame.parent.range.text) for key, entity in pairs(game.surfaces[1].find_entities_filtered({area={{player.position.x-range,player.position.y-range},{player.position.x+range,player.position.y+range}},type = "entity-ghost"})) do entity.revive() end end end) addButton('add_dev_items',function(player,frame) player.insert{name="deconstruction-planner", count = 1} player.insert{name="blueprint-book", count = 1} player.insert{name="blueprint", count = 20} end) -addButton('setRanks', +addButton('sendMessage',function(player,frame) local rank = stringToRank(frame.parent.message.rank.text) if rank then callRank(frame.parent.message.message.text,rank.name) else for _,rank in pairs(ranks) do player.print(rank.name) end end) +addButton('setRanks',player.print(frame.parent.rank_input.text..' is not a Rank, Ranks are:') function(player,frame) - rank = stringToRank(frame.parent.rank.rank_input.text) + rank = stringToRank(frame.parent.rank_input.text) if rank then for _,playerName in pairs(selected[player.index]) do p=game.players[playerName] - if getRank(player).power < getRank(p).power and rank.power > getRank(p) then + if getRank(player).power < getRank(p).power and rank.power > getRank(player).power then giveRank(p,rank,player) else - player.print('You can not edit '..p.name..' rank there rank or the rank you have slected is too high') + player.print('You can not edit '..p.name.."'s rank there rank is too high (or the rank you have slected is above you)") end end - end + else + player.print(frame.parent.rank_input.text..' is not a Rank, Ranks are:') for _,rank in pairs(ranks) do if rank.power > getRank(player).power then player.print(rank.name) end end + end end) -addButton('clearSelection',function(player,fram) clearSelection(player) end) +addButton('clearSelection',function(player,frame) clearSelection(player) drawPlayerTable(player, frame.parent.parent, false, true, {}) end) addTab('Admin', 'Commands', 'Random useful commands', function(player, frame) @@ -746,6 +748,10 @@ addTab('Admin', 'Commands', 'Random useful commands', drawButton(frame,'add_dev_items','Get Blueprints','Get all the blueprints') drawButton(frame,'revive_dead_entitys_range','Revive Entitys','Brings all dead machines back to life in player range') frame.add{type='textfield',name='range',text='Range'} + frame.add{type='flow',name='message'} + frame.message.add{type='textfield',name='message',text='Enter message'} + frame.message.add{type='textfield',name='rank',text='Endter rank'} + drawButton(frame,'sendMessage','Send Message','Send a message to all ranks higher than the slected') drawButton(frame,'tp_all','TP All Here','Brings all players to you') end) addTab('Admin','Edit Ranks', 'Edit the ranks of players below you', @@ -761,7 +767,7 @@ addTab('Admin','Edit Ranks', 'Edit the ranks of players below you', frame.rank.add{name='rank_input',type='textfield'} drawButton(frame.rank,'setRanks','Set Ranks','Sets the rank of all selected players') drawButton(frame.rank,'clearSelection','Clear Selection','Clears all currently selected players') - drawPlayerTable(player, frame, false, true, {}) + drawPlayerTable(player, frame, false, true, {'lower'}) end) addTab('Admin', 'Player List', 'Send player message to all players', function(player, frame)