mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Merge branch 'WIP' into Testing
This commit is contained in:
956
control.lua
956
control.lua
@@ -1,926 +1,42 @@
|
||||
require("silo-script") --do not remove part of factorio default control
|
||||
require "mod-gui"
|
||||
local version = 1 --do not remove part of factorio default control
|
||||
entityRemoved = {}
|
||||
entityCache = {}
|
||||
guis = {frames={},buttons={}}
|
||||
--this is a list of what will be put into the default list
|
||||
defaults = {
|
||||
--for disallow add to the list the end part of the input action
|
||||
--example: defines.input_action.drop_item -> 'drop_item'
|
||||
--http://lua-api.factorio.com/latest/defines.html#defines.input_action
|
||||
ranks={
|
||||
{name='Owner',shortHand='Owner',tag='[Owner]',power=0,colour={r=170,g=0,b=0},disallow={}},
|
||||
{name='Community Manager',shortHand='Com Mngr',tag='[Com Mngr]',power=1,colour={r=150,g=68,b=161},disallow={}},
|
||||
{name='Developer',shortHand='Dev',tag='[Dev]',power=1,colour={r=179,g=125,b=46},disallow={}},
|
||||
{name='Admin',shortHand='Admin',tag='[Admin]',power=2,colour={r=233,g=63,b=233},disallow={'set_allow_commands','edit_permission_group','delete_permission_group','add_permission_group'}},
|
||||
{name='Mod',shortHand='Mod',tag='[Mod]',power=3,colour={r=0,g=170,b=0},disallow={'set_allow_commands','server_command','edit_permission_group','delete_permission_group','add_permission_group'}},
|
||||
{name='Donator',shortHand='P2W',tag='[P2W]',power=4,colour={r=233,g=63,b=233},disallow={'set_allow_commands','server_command','edit_permission_group','delete_permission_group','add_permission_group'}},
|
||||
{name='Veteran',shortHand='Vet',tag='[Veteran]',power=4,colour={r=140,g=120,b=200},disallow={'set_allow_commands','server_command','edit_permission_group','delete_permission_group','add_permission_group'}},
|
||||
{name='Member',shortHand='Mem',tag='[Member]',power=5,colour={r=24,g=172,b=188},disallow={'set_allow_commands','server_command','edit_permission_group','delete_permission_group','add_permission_group'}},
|
||||
{name='Regular',shortHand='Reg',tag='[Regular]',power=5,colour={r=24,g=172,b=188},disallow={'set_auto_launch_rocket','change_programmable_speaker_alert_parameters','reset_assembling_machine','drop_item','set_allow_commands','server_command','edit_permission_group','delete_permission_group','add_permission_group'}},
|
||||
{name='Guest',shortHand='',tag='[Guest]',power=6,colour={r=255,g=159,b=27},disallow={'build_terrain','remove_cables','launch_rocket','cancel_research','set_auto_launch_rocket','change_programmable_speaker_alert_parameters','reset_assembling_machine','drop_item','set_allow_commands','server_command','edit_permission_group','delete_permission_group','add_permission_group'}},
|
||||
{name='Jail',shortHand='Jail',tag='[Jail]',power=7,colour={r=50,g=50,b=50},disallow={'open_character_gui','begin_mining','start_walking','player_leave_game','build_terrain','remove_cables','launch_rocket','cancel_research','set_auto_launch_rocket','change_programmable_speaker_alert_parameters','reset_assembling_machine','drop_item','set_allow_commands','server_command','edit_permission_group','delete_permission_group','add_permission_group'}}
|
||||
},
|
||||
autoRanks={
|
||||
Owner={'badgamernl'},
|
||||
['Community Manager']={'arty714'},
|
||||
Developer={'Cooldude2606'},
|
||||
Admin={'eissturm','PropangasEddy','Smou'},
|
||||
Mod={'Alanore','Aquaday','cafeslacker','CrashKonijn','Drahc_pro','FlipHalfling90','freek16','Hobbitkicker','hud','Koroto','mark9064','Matthias60','MeDDish','Mindxt20','MottledPetrel','Mr_Happy_212','NextIdea','Phoenix27833','samy115','Sand3r205','scarbvis','steentje77','tophatgaming123','VR29'},
|
||||
Donator={'M74132','Splicer'},
|
||||
Member={},
|
||||
Regular={},
|
||||
Guest={},
|
||||
Jail={}
|
||||
},
|
||||
selected={},
|
||||
oldRanks={},
|
||||
queue={}
|
||||
}
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
warningAllowed = nil
|
||||
timeForRegular = 180
|
||||
timeForVeteran = 600
|
||||
CHUNK_SIZE = 32
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Factorio Code Do Not Remove----------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
script.on_init(function()
|
||||
global.version = version
|
||||
silo_script.init()
|
||||
end)
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
script.on_event(defines.events.on_rocket_launched, function(event)
|
||||
silo_script.on_rocket_launched(event)
|
||||
end)
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='Control',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Core Factorio File',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
require("mod-gui")
|
||||
credit_loop(require("locale/StdLib/event"))
|
||||
credit_loop(require("locale/file-header"))
|
||||
|
||||
script.on_configuration_changed(function(event)
|
||||
if global.version ~= version then
|
||||
global.version = version
|
||||
end
|
||||
silo_script.on_configuration_changed(event)
|
||||
end)
|
||||
Event.register(-1,function() global.credits = credits end)
|
||||
|
||||
silo_script.add_remote_interface()
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Rank functions-----------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
function getRank(player)
|
||||
if player then
|
||||
for _,rank in pairs(global.ranks) do
|
||||
if player.permission_group == game.permissions.get_group(rank.name) then return rank end
|
||||
end
|
||||
return stringToRank('Guest')
|
||||
end
|
||||
end
|
||||
|
||||
function stringToRank(string)
|
||||
if type(string) == 'string' then
|
||||
local Foundranks={}
|
||||
for _,rank in pairs(global.ranks) do
|
||||
if rank.name:lower() == string:lower() then return rank end
|
||||
if rank.name:lower():find(string:lower()) then table.insert(Foundranks,rank) end
|
||||
end
|
||||
if #Foundranks == 1 then return Foundranks[1] end
|
||||
end
|
||||
end
|
||||
|
||||
function callRank(msg, rank, inv)
|
||||
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(('[Everyone]: '..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
|
||||
end
|
||||
|
||||
function giveRank(player,rank,byPlayer)
|
||||
local byPlayer = byPlayer or 'system'
|
||||
local rank = stringToRank(rank) or rank or stringToRank('Guest')
|
||||
local oldRank = getRank(player)
|
||||
local message = 'demoted'
|
||||
if rank.power <= oldRank.power then message = 'promoted' end
|
||||
if byPlayer.name then
|
||||
callRank(player.name..' was '..message..' to '..rank.name..' by '..byPlayer.name,'Guest')
|
||||
else
|
||||
callRank(player.name..' was '..message..' to '..rank.name..' by <system>','Guest')
|
||||
end
|
||||
player.permission_group = game.permissions.get_group(rank.name)
|
||||
if player.tag:find('-') then player.print('Your Custom Tag Was Reset Due To A Rank Change') end
|
||||
player.tag = getRank(player).tag
|
||||
drawToolbar(player)
|
||||
drawPlayerList()
|
||||
if oldRank.name ~= 'Jail' then global.oldRanks[player.index]=oldRank.name end
|
||||
end
|
||||
|
||||
function revertRank(player,byPlayer)
|
||||
local rank = stringToRank(global.oldRanks[player.index])
|
||||
giveRank(player,rank,byPlayer)
|
||||
end
|
||||
|
||||
function autoRank(player)
|
||||
local currentRank = getRank(player)
|
||||
local playerAutoRank = nil
|
||||
local oldRank = getRank(player)
|
||||
for rank,players in pairs(global.autoRanks) do
|
||||
local Break = false
|
||||
for _,p in pairs(players) do
|
||||
if player.name:lower() == p:lower() then playerAutoRank = stringToRank(rank) Break = true break end
|
||||
end
|
||||
if Break then break end
|
||||
end
|
||||
if playerAutoRank == nil then
|
||||
if ticktominutes(player.online_time) >= timeForVeteran then playerAutoRank = stringToRank('Veteran') end
|
||||
if ticktominutes(player.online_time) >= timeForRegular then playerAutoRank = stringToRank('Regular') end
|
||||
playerAutoRank = playerAutoRank or stringToRank('Guest')
|
||||
end
|
||||
if currentRank.name ~='Jail' and currentRank.power > playerAutoRank.power or currentRank.name == 'Guest' then
|
||||
if playerAutoRank.name == 'Guest' then
|
||||
player.permission_group=game.permissions.get_group('Guest')
|
||||
else
|
||||
giveRank(player,playerAutoRank)
|
||||
end
|
||||
end
|
||||
if getRank(player).power <= 3 and not player.admin then callRank(player.name..' needs to be promoted.') end
|
||||
if oldRank.name ~= getRank(player).name then global.oldRanks[player.index]=oldRank.name end
|
||||
end
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Common use functions-----------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
function ticktohour (tick)
|
||||
local hour = tostring(math.floor(tick/(216000*game.speed)))
|
||||
return hour
|
||||
end
|
||||
|
||||
function ticktominutes (tick)
|
||||
local minutes = math.floor(tick/(3600*game.speed))
|
||||
return minutes
|
||||
end
|
||||
|
||||
function clearSelection(player)
|
||||
global.selected[player.index] = {}
|
||||
end
|
||||
|
||||
function sudo(command,args)
|
||||
table.insert(global.queue,{fun=command,var=args})
|
||||
end
|
||||
|
||||
function autoMessage()
|
||||
local lrank = 'Regular'
|
||||
local hrank = '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:',lrank,true)
|
||||
callRank('Discord: https://discord.gg/RPCxzgt',lrank,true)
|
||||
callRank('Forum: explosivegaming.nl',lrank,true)
|
||||
callRank('Steam: http://steamcommunity.com/groups/tntexplosivegaming',lrank,true)
|
||||
callRank('To see these links again goto: Readme > Server Info',lrank,true)
|
||||
for _,player in pairs(game.connected_players) do autoRank(player) end
|
||||
end
|
||||
|
||||
function table.val_to_str ( v )
|
||||
if "string" == type( v ) then
|
||||
v = string.gsub( v, "\n", "\\n" )
|
||||
if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
|
||||
return "'" .. v .. "'"
|
||||
end
|
||||
return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
|
||||
else
|
||||
return "table" == type( v ) and table.tostring( v ) or
|
||||
tostring( v )
|
||||
end
|
||||
end
|
||||
|
||||
function table.key_to_str ( k )
|
||||
if "string" == type( k ) and string.match( k, "^[_%player][_%player%d]*$" ) then
|
||||
return k
|
||||
else
|
||||
return "[" .. table.val_to_str( k ) .. "]"
|
||||
end
|
||||
end
|
||||
|
||||
function table.tostring( tbl )
|
||||
local result, done = {}, {}
|
||||
for k, v in ipairs( tbl ) do
|
||||
table.insert( result, table.val_to_str( v ) )
|
||||
done[ k ] = true
|
||||
end
|
||||
for k, v in pairs( tbl ) do
|
||||
if not done[ k ] then
|
||||
table.insert( result,
|
||||
table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
|
||||
end
|
||||
end
|
||||
return "{" .. table.concat( result, "," ) .. "}"
|
||||
end
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Gui Functions------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
function addFrame(frame,rank,open,caption,tooltip,sprite)
|
||||
guis.frames[frame] = {{require=rank,caption=caption,tooltip=tooltip,sprite=sprite}}
|
||||
addButton('close', function(player,element) element.parent.parent.parent.destroy() end)
|
||||
addButton('btn_'..frame, function(player,element) if player.gui.center[frame] then player.gui.center[frame].destroy() else drawFrame(player,frame,open) end end)
|
||||
end
|
||||
|
||||
function addTab(frame, tabName, describtion, drawTab)
|
||||
guis.frames[frame][tabName] = {tabName, describtion, drawTab}
|
||||
addButton(tabName, function(player, element) openTab(player, element.parent.parent.parent.name, element.parent.parent.parent.tab, element.name) end)
|
||||
end
|
||||
|
||||
function addButton(btnName, onClick)
|
||||
guis.buttons[btnName] = {btnName, onClick}
|
||||
end
|
||||
|
||||
function drawButton(frame, btnName, caption, describtion, sprite)
|
||||
if sprite then
|
||||
frame.add{name=btnName, type = "sprite-button", sprite=sprite, tooltip=describtion, style = mod_gui.button_style}
|
||||
else
|
||||
frame.add{name=btnName, type = "button", caption=caption, tooltip=describtion, style = mod_gui.button_style}
|
||||
end
|
||||
end
|
||||
|
||||
function openTab(player, frameName, tab, tabName)
|
||||
local tabBar = player.gui.center[frameName].tabBarScroll.tabBar
|
||||
for _,t in pairs(guis.frames[frameName]) do
|
||||
if _ ~= 1 then
|
||||
if t[1] == tabName then
|
||||
tabBar[t[1]].style.font_color = {r = 255, g = 255, b = 255, player = 255}
|
||||
tab.clear()
|
||||
t[3](player, tab)
|
||||
else
|
||||
tabBar[t[1]].style.font_color = {r = 100, g = 100, b = 100, player = 255}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function drawFrame(player, frameName, tabName)
|
||||
if getRank(player).power <= guis.frames[frameName][1].require then
|
||||
player.gui.center.clear()
|
||||
local frame = player.gui.center.add{name=frameName,type='frame',caption=frameName,direction='vertical',style=mod_gui.frame_style}
|
||||
local tabBarScroll = frame.add{type = "scroll-pane", name= "tabBarScroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"}
|
||||
local tabBar = tabBarScroll.add{type='flow',direction='horizontal',name='tabBar'}
|
||||
local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"}
|
||||
for _,t in pairs(guis.frames[frameName]) do
|
||||
if _ ~= 1 then drawButton(tabBar, t[1], t[1], t[2]) end
|
||||
end
|
||||
openTab(player, frameName, tab, tabName)
|
||||
drawButton(tabBar, 'close', 'Close', 'Close this window')
|
||||
tab.style.minimal_height = 300
|
||||
tab.style.maximal_height = 300
|
||||
tab.style.minimal_width = 500
|
||||
tab.style.maximal_width = 500
|
||||
tabBarScroll.style.minimal_height = 60
|
||||
tabBarScroll.style.maximal_height = 60
|
||||
tabBarScroll.style.minimal_width = 500
|
||||
tabBarScroll.style.maximal_width = 500
|
||||
player.gui.center.add{type='frame',name='temp'}.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function toggleVisable(frame)
|
||||
if frame then
|
||||
if frame.style.visible == nil then
|
||||
frame.style.visible = false
|
||||
else
|
||||
frame.style.visible = not frame.style.visible
|
||||
end
|
||||
end
|
||||
end
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Player Events------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
script.on_event(defines.events.on_player_created, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
player.force.friendly_fire = false
|
||||
player.insert{name="iron-plate", count=8}
|
||||
player.insert{name="pistol", count=1}
|
||||
player.insert{name="firearm-magazine", count=10}
|
||||
player.insert{name="burner-mining-drill", count = 1}
|
||||
player.insert{name="stone-furnace", count = 1}
|
||||
player.force.chart(player.surface, {{player.position.x - 200, player.position.y - 200}, {player.position.x + 200, player.position.y + 200}})
|
||||
silo_script.gui_init(player) -- do not remove part of factorio default
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_respawned, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
drawPlayerList()
|
||||
player.insert{name="pistol", count=1}
|
||||
player.insert{name="firearm-magazine", count=10}
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_joined_game, function(event)
|
||||
--runs when the first player joins to make the permission groups
|
||||
if global.ranks == nil then scriptInit() end
|
||||
if commands.commands['server-interface'] == nil then commandInit() end
|
||||
--Standard start up
|
||||
local player = game.players[event.player_index]
|
||||
autoRank(player)
|
||||
player.print({"", "Welcome"})
|
||||
drawPlayerList()
|
||||
drawToolbar(player)
|
||||
if not player.admin and ticktominutes(player.online_time) < 1 then drawFrame(player,'Readme','Rules') end
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_left_game, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
drawPlayerList()
|
||||
end)
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Gui Events---------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
script.on_event(defines.events.on_gui_click, function(event)
|
||||
silo_script.on_gui_click(event) -- do not remove part of factorio default
|
||||
local player = game.players[event.player_index]
|
||||
if event.element.type == 'button' or event.element.type == 'sprite-button' then
|
||||
for _,btn in pairs(guis.buttons) do
|
||||
if btn[1] == event.element.name then
|
||||
if btn[2] then btn[2](player,event.element) else callRank('Invaid Button'..btn[1],'Mod') end
|
||||
break
|
||||
end
|
||||
end
|
||||
elseif event.element.type == 'checkbox' then
|
||||
if event.element.name == 'select' then
|
||||
global.selected[event.player_index] = global.selected[event.player_index] or {}
|
||||
selected = global.selected[event.player_index]
|
||||
if event.element.state then
|
||||
table.insert(selected,event.element.parent.name)
|
||||
else
|
||||
for _,name in pairs(selected) do
|
||||
if name == event.element.parent.name then table.remove(selected,_) break end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_gui_text_changed, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
if event.element.parent.name == 'filterTable' then
|
||||
local frame = event.element
|
||||
filters = getPlayerTableFilters(frame)
|
||||
local select = false
|
||||
if frame.parent.parent.parent.name == 'Admin' then select = true filters.powerOver = true end
|
||||
drawPlayerTable(player, frame.parent.parent, select, filters)
|
||||
end
|
||||
end)
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Grefer Events------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
script.on_event(defines.events.on_marked_for_deconstruction, function(event)
|
||||
local eplayer = game.players[event.player_index]
|
||||
if getRank(eplayer).power > 5 then
|
||||
if event.entity.type ~= "tree" and event.entity.type ~= "simple-entity" then
|
||||
event.entity.cancel_deconstruction("player")
|
||||
eplayer.print("You are not allowed to do this yet, play for player bit longer. Try again in about: " .. math.floor((timeForRegular - ticktominutes(eplayer.online_time))) .. " minutes")
|
||||
callRank(eplayer.name .. " tryed to deconstruced something")
|
||||
end
|
||||
elseif event.entity.type == "tree" or event.entity.type == "simple-entity" and getRank(eplayer).power < 5 then
|
||||
event.entity.destroy()
|
||||
end
|
||||
end)
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Other Events-------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
script.on_event(defines.events.on_tick, function(event)
|
||||
if game.tick % 60 == 0 and game.tick > 300 then
|
||||
if global.queue ~= nil then command=table.remove(global.queue) end
|
||||
if command and command.fun and type(command.fun) == 'function' then
|
||||
local args = command.var or {}
|
||||
command.fun(args[1],args[2],args[3],args[4],args[5],args[6])
|
||||
end
|
||||
end
|
||||
if (game.tick/(3600*game.speed)) % 15 == 0 then autoMessage() end
|
||||
end)
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Tool Bar-----------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
addButton("btn_toolbar_playerList", function(player) toggleVisable(mod_gui.get_frame_flow(player).PlayerList) end)
|
||||
function drawToolbar(player)
|
||||
local frame = mod_gui.get_button_flow(player)
|
||||
if not frame.btn_toolbar_playerList then drawButton(frame,"btn_toolbar_playerList", "Playerlist", "Adds/removes the player list to/from your game.",'entity/player') end
|
||||
for _,f in pairs(guis.frames) do
|
||||
if frame["btn_".._] then frame["btn_".._].destroy() end
|
||||
if getRank(player).power <= f[1].require then drawButton(frame,"btn_".._, f[1].caption, f[1].tooltip, f[1].sprite) end
|
||||
end
|
||||
end
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Player List--------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
function drawPlayerList()
|
||||
for i, player in pairs(game.connected_players) do
|
||||
local flow = mod_gui.get_frame_flow(player)
|
||||
if flow.PlayerList == nil then
|
||||
flow.add{type = "frame", name= "PlayerList", direction = "vertical",style=mod_gui.frame_style}
|
||||
.add{type = "scroll-pane", name= "PlayerListScroll", direction = "vertical", vertical_scroll_policy="always", horizontal_scroll_policy="never"}
|
||||
end
|
||||
local Plist= flow.PlayerList.PlayerListScroll
|
||||
Plist.clear()
|
||||
Plist.style.maximal_height = 200
|
||||
for i, player in pairs(game.connected_players) do
|
||||
playerRank = getRank(player)
|
||||
if playerRank.power <= 3 or playerRank.name == 'Jail' then
|
||||
if playerRank.shortHand ~= '' then Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}}
|
||||
else Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name}} end
|
||||
Plist[player.name].style.font_color = playerRank.colour
|
||||
if player.tag:find('-') then else player.tag = playerRank.tag end
|
||||
end
|
||||
end
|
||||
for i, player in pairs(game.connected_players) do
|
||||
playerRank = getRank(player)
|
||||
if playerRank.power > 3 and playerRank.name ~= 'Jail' then
|
||||
if playerRank.shortHand ~= '' then Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name , ' - '..playerRank.shortHand}}
|
||||
else Plist.add{type = "label", name=player.name, style="caption_label_style", caption={"", ticktohour(player.online_time), " H - " , player.name}} end
|
||||
Plist[player.name].style.font_color = playerRank.colour
|
||||
if player.tag:find('-') then else player.tag = playerRank.tag end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function getPlayerTableFilters(frame)
|
||||
local filters = {online=nil,time=0,name=nil,selected=nil,powerOver=nil,admin=nil}
|
||||
local filterTable = frame.parent.parent.filterTable
|
||||
if filterTable.status_input then
|
||||
local status_input = filterTable.status_input.text
|
||||
if status_input == 'yes' or status_input == 'online' or status_input == 'true' or status_input == 'y' then filters.online = true
|
||||
elseif status_input ~= '' then filters.online = false end
|
||||
end if filterTable.hours_input then
|
||||
local hours_input = filterTable.hours_input.text
|
||||
if tonumber(hours_input) and tonumber(hours_input) > 0 then filters.time = tonumber(hours_input) end
|
||||
end if filterTable.name_input then
|
||||
local name_input = filterTable.name_input.text
|
||||
if name_input then filters.name = name_input end
|
||||
end
|
||||
return filters
|
||||
end
|
||||
|
||||
function drawPlayerTable(player, frame, select,filters)
|
||||
--setup the table
|
||||
if frame.playerTable then frame.playerTable.destroy() end
|
||||
pTable = frame.add{name='playerTable', type="table", colspan=5}
|
||||
pTable.style.minimal_width = 500
|
||||
pTable.style.maximal_width = 500
|
||||
pTable.style.horizontal_spacing = 10
|
||||
pTable.add{name="id", type="label", caption="Id"}
|
||||
pTable.add{name="Pname", type="label", caption="Name"}
|
||||
pTable.add{name="online_time", type="label", caption="Online Time"}
|
||||
pTable.add{name="rank", type="label", caption="Rank"}
|
||||
if select then pTable.add{name="select_label", type="label", caption="Selection"} end
|
||||
--filter checking
|
||||
for i, p in pairs(game.players) do
|
||||
local addPlayer = nil
|
||||
if addPlayer ~= false and filters.admin then if p.admin ~= filters.admin then addPlayer = false end end
|
||||
if addPlayer ~= false and filters.online == true then if p.connected == false then addPlayer = false end end
|
||||
if addPlayer ~= false and filters.online == false then if p.connected == true then addPlayer = false end end
|
||||
if addPlayer ~= false and filters.powerOver then if getRank(p).power <= getRank(player).power then addPlayer = false end end
|
||||
if addPlayer ~= false and filters.time then if filters.time > ticktominutes(p.online_time) then addPlayer = false end end
|
||||
if addPlayer ~= false and filters.name then if p.name:lower():find(filters.name:lower()) == nil then addPlayer = false end end
|
||||
--addes the player to the list
|
||||
if addPlayer == nil then addPlayer = true end
|
||||
if addPlayer == true and player.name ~= p.name then
|
||||
if pTable[p.name] == nil then
|
||||
pTable.add{name=i .. "id", type="label", caption=i}
|
||||
pTable.add{name=p.name..'_name', type="label", caption=p.name}
|
||||
--status
|
||||
if not select then
|
||||
if p.connected == true
|
||||
then pTable.add{name=p.name .. "Status", type="label", caption="ONLINE"}
|
||||
else pTable.add{name=p.name .. "Status", type="label", caption="OFFLINE"} end end
|
||||
--time and rank
|
||||
pTable.add{name=p.name .. "Online_Time", type="label", caption=(ticktohour(p.online_time)..'H '..(ticktominutes(p.online_time)-60*ticktohour(p.online_time))..'M')}
|
||||
pTable.add{name=p.name .. "Rank", type="label", caption=getRank(p).shortHand}
|
||||
--player slecction
|
||||
if select then
|
||||
pTable.add{name=p.name, type="flow"}
|
||||
local state = false
|
||||
for _,name in pairs(global.selected[player.index]) do if name == p.name then state = true break end end
|
||||
pTable[p.name].add{name='select', type="checkbox",state=state}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Init---------------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
function scriptInit()
|
||||
--global
|
||||
for name,value in pairs(defaults) do global[name] = value end
|
||||
--ranks
|
||||
for _,rank in pairs(global.ranks) do
|
||||
game.permissions.create_group(rank.name)
|
||||
for _,toRemove in pairs(rank.disallow) do
|
||||
game.permissions.get_group(rank.name).set_allows_action(defines.input_action[toRemove],false)
|
||||
end
|
||||
end
|
||||
--end
|
||||
game.print('Script Init Complete')
|
||||
end
|
||||
|
||||
function commandInit()
|
||||
commands.add_command('server-interface','<command> #2#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if getRank(byPlayer).power > 2 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
if event.parameter then else byPlayer.print('Invaid Input, /server-interface <command>') return end
|
||||
local returned,value = pcall(loadstring(event.parameter))
|
||||
if type(value) == 'table' then game.write_file('log.txt', '\n Ran by: '..byPlayer.name..'\n Code: '..event.parameter..'\n $£$ '..table.tostring(value), true, 0) byPlayer.print(table.tostring(value))
|
||||
else game.write_file('log.txt', '\n Ran by: '..byPlayer.name..'\n Code: '..event.parameter..'\n $£$ '..tostring(value), true, 0) byPlayer.print(value) end
|
||||
else
|
||||
if event.parameter then else print('Invaid Input, /server-interface <command>') return end
|
||||
local returned,value = pcall(loadstring(event.parameter))
|
||||
if type(value) == 'table' then game.write_file('log.txt', '\n Ran by: <server> \n Code: '..event.parameter..'\n $£$ '..table.tostring(value), true, 0) print(table.tostring(value))
|
||||
else game.write_file('log.txt', '\n Ran by: <server> \n Code: '..event.parameter..'\n $£$ '..tostring(value), true, 0) print(value) end
|
||||
end
|
||||
end)
|
||||
commands.add_command('auto-message','Sends the auto message to all players #6#',function(event) autoMessage() end)
|
||||
--base layout for all commands
|
||||
commands.add_command('online-time','<player_name> Get a players online time #6#',function(event)
|
||||
if event.player_index then --is it a player or the server
|
||||
local byPlayer = game.players[event.player_index] -- it's a player so gets them
|
||||
if event.parameter then else byPlayer.print('Invaild Input, /online-time <player>') return end -- are there any arguments
|
||||
if getRank(byPlayer).power > 4 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end -- is the user have vaild rank to use command
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end -- gets all the arguments passed
|
||||
if #args == 1 then else byPlayer.print('Invaild Input, /online-time <player> ') return end -- is enouth arguments passed to aloow the command to work
|
||||
local player = game.players[args[1]] if player then else byPlayer.print('Invaild Player Name,'..args[1]..', try using tab key to auto-coomplet the name') return end -- arguments vaildtion
|
||||
byPlayer.print(ticktohour(player.online_time)..'H '..(ticktominutes(player.online_time)-60*ticktohour(player.online_time))..'M') -- finally the command is done
|
||||
else -- when the server runs commands no output is given to any user, also server has no rank validation
|
||||
if event.parameter then else print('Invaild Input, /online-time <player>') return end -- are there any arguments
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end -- gets all the arguments passed
|
||||
if #args == 1 then else print('Invaild Input, /online-time <player>') return end -- is enouth arguments passed to aloow the command to work
|
||||
local player = game.players[args[1]] if player then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-coomplet the name') return end -- arguments vaildtion
|
||||
print(ticktohour(player.online_time)..'H '..(ticktominutes(player.online_time)-60*ticktohour(player.online_time))..'M') -- finally the command is done
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
--revive-entities
|
||||
commands.add_command('revive-entities','<range/all> Reives all entitys in this range. Admins can use all as range #4#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if event.parameter then else byPlayer.print('Invaild Input, /revive-entities <range/all>') return end
|
||||
local pos = byPlayer.position
|
||||
if getRank(byPlayer).power > 4 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else byPlayer.print('Invaild Input, /revive-entities <range/all>') return end
|
||||
local range = tonumber(args[1]) if range or args[1] == 'all' then else byPlayer.print('Invaild Range, must be number below 50') return end
|
||||
if args[1] == 'all' then
|
||||
if getRank(byPlayer).power > 2 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
for key, entity in pairs(game.surfaces[1].find_entities_filtered({type = "entity-ghost"})) do entity.revive() end return
|
||||
elseif range < 50 and range > 0 then else byPlayer.print('Invaild Range, must be number below 50') return end
|
||||
for key, entity in pairs(game.surfaces[1].find_entities_filtered({area={{pos.x-range,pos.y-range},{pos.x+range,pos.y+range}},type = "entity-ghost"})) do entity.revive()
|
||||
end
|
||||
else
|
||||
for key, entity in pairs(game.surfaces[1].find_entities_filtered({type = "entity-ghost"})) do entity.revive() end print('Command Complete')
|
||||
end
|
||||
end)
|
||||
-- tp
|
||||
commands.add_command('tp','<player> <to_player> teleports one player to another #4#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if event.parameter then else byPlayer.print('Invaild Input, /tp <player> <to_player>') return end
|
||||
if getRank(byPlayer).power > 4 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 2 then else byPlayer.print('Invaild Input, /tp <player> <to_player>') return end
|
||||
local p1 = game.players[args[1]] if p1 then else byPlayer.print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
local p2 = game.players[args[2]] if p2 then else byPlayer.print('Invaild Player Name,'..args[2]..', try using tab key to auto-complete the name') return end
|
||||
if p1 == p2 then byPlayer.print('Invaild Players, must be two diffrent players') return end
|
||||
if p1.connected and p2.connected then else byPlayer.print('Invaild Player, player is not online') return end
|
||||
if getRank(byPlayer).power > getRank(p1).power then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
p1.teleport(game.surfaces[p2.surface.name].find_non_colliding_position("player", p2.position, 32, 1))
|
||||
else
|
||||
if event.parameter then else print('Invaild Input, /tp <player> <to_player>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 2 then else print('Invaild Input, /tp <player> <to_player>') return end
|
||||
local p1 = game.players[args[1]] if p1 then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
local p2 = game.players[args[2]] if p2 then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if p1 == p2 then print('Invaild Players, must be two diffrent players') return end
|
||||
if p1.connected and p2.connected then else print('Invaild Players, one/both of players is not online') return end
|
||||
p1.teleport(game.surfaces[p2.surface.name].find_non_colliding_position("player", p2.position, 32, 1))
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
-- kill
|
||||
commands.add_command('kill','<player> if no player stated then you kill your self #6#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if event.parameter then
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else byPlayer.print('Invaild Input, /kill <player> ') return end
|
||||
local player = game.players[args[1]] if player then else byPlayer.print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if getRank(byPlayer).power > getRank(player).power or getRank(byPlayer).power > 4 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
if player.connected then else byPlayer.print('Invaild Player, player is not online') return end
|
||||
if player.character then player.character.die() else byPlayer.print('Invaild Player, their are already dead') return end
|
||||
else
|
||||
if byPlayer.character then byPlayer.character.die() else byPlayer.print('Invaild Player, you are already dead') return end
|
||||
end
|
||||
else
|
||||
if event.parameter then else print('Invaild Input, /kill <player> ') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else print('Invaild Input, /kill <player> ') return end
|
||||
local player = game.players[args[1]] if player then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if player.connected then else print('Invaild Player, player is not online') return end
|
||||
if player.character then player.character.die() else print('Invaild Player, their are already dead') return end
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
-- jail/unjail
|
||||
commands.add_command('jail','<player> jail the player disallowing them to move #3#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if event.parameter then else byPlayer.print('Invaild Input, /jail <player>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else byPlayer.print('Invaild Input, /jail <player> ') return end
|
||||
local player = game.players[args[1]] if player then else byPlayer.print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if getRank(byPlayer).power > getRank(player).power or getRank(byPlayer).power > 4 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
if player.connected then else byPlayer.print('Invaild Player, player is not online') return end
|
||||
if player == byPlayer then byPlayer.print('Invaild Player, you can\'t jail yourself') return end
|
||||
if player.permission_group.name ~= 'Jail' then sudo(giveRank,{player,'Jail',byPlayer}) end
|
||||
else
|
||||
if event.parameter then else print('Invaild Input, /jail <player>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else print('Invaild Input, /jail <player>') return end
|
||||
local player = game.players[args[1]] if player then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if player.permission_group.name ~= 'Jail' then giveRank(player,'Jail') end
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
commands.add_command('unjail','<player> jail the player disallowing them to move #3#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if event.parameter then else byPlayer.print('Invaild Input, /unjail <player>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else byPlayer.print('Invaild Input, /unjail <player> ') return end
|
||||
local player = game.players[args[1]] if player then else byPlayer.print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if getRank(byPlayer).power > getRank(player).power or getRank(byPlayer).power > 4 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
if player.permission_group.name == 'Jail' then sudo(revertRank,{player,byPlayer}) end
|
||||
else
|
||||
if event.parameter then else print('Invaild Input, /unjail <player>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else print('Invaild Input, /unjail <player>') return end
|
||||
local player = game.players[args[1]] if player then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if player.permission_group.name == 'Jail' then revertRank(player) end
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
-- tag
|
||||
commands.add_command('tag','<tag> Gives you your own tag #6#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
local tag = nil
|
||||
if event.parameter then tag = event.parameter end
|
||||
if tag and tag:len() > 20 then byPlayer.print('Invaild Tag, must be less then 20 characters') return end
|
||||
if tag then byPlayer.tag = getRank(byPlayer).tag..' - '..tag..' ' else byPlayer.tag = getRank(byPlayer).tag end
|
||||
else
|
||||
if event.parameter then else print('Invaild Input, /tag <player> <tag/nil>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args > 0 then else print('Invaild Input, /tag <player> <tag/nil>') return end
|
||||
local player = game.players[args[1]] if player then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
if args[2] then player.tag = getRank(player).tag..' - '..table.concat(args,' ',2)..' ' else player.tag = getRank(player).tag end
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
-- tp-all
|
||||
commands.add_command('tp-all','<player> Sends everyone to this one person #2#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if getRank(byPlayer).power > 2 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
if event.parameter then else byPlayer.print('Invaild Input, /tp-all <player>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else byPlayer.print('Invaild Input, /tp-all <player>') return end
|
||||
local player = game.players[args[1]] if player then else byPlayer.print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
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
|
||||
else
|
||||
if event.parameter then else print('Invaild Input, /tp-all <player>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args == 1 then else print('Invaild Input, /tp-all <player>') return end
|
||||
local player = game.players[args[1]] if player then else print('Invaild Player Name,'..args[1]..', try using tab key to auto-complete the name') return end
|
||||
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
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
-- call-rank
|
||||
commands.add_command('call-rank','<rank> <message> sends a message to this rank and above #5#',function(event)
|
||||
if event.player_index then
|
||||
local byPlayer = game.players[event.player_index]
|
||||
if getRank(byPlayer).power > 5 then byPlayer.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
if event.parameter then else byPlayer.print('Invaild Input, /call-rank <rank> <message>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args > 1 then else byPlayer.print('Invaild Input, /call-rank <rank> <message>') return end
|
||||
local rank = stringToRank(args[1]) if rank then else byPlayer.print('Invaild Rank, ther is no rank by that name') return end
|
||||
if rank.name ~= 'Mod' and getRank(byPlayer).power > rank.power then byPlayer.print('Invaild Rank, rank must not be a higher rank then your (mod is the only exception)') return end
|
||||
callRank(table.concat(args,' ',2),rank.name)
|
||||
else
|
||||
if event.parameter then else print('Invaild Input, /call-rank <rank> <message>') return end
|
||||
local args = {} for word in event.parameter:gmatch('%S+') do table.insert(args,word) end
|
||||
if #args > 1 then else print('Invaild Input, /call-rank <rank> <message>') return end
|
||||
local rank = stringToRank(args[1]) if rank then callRank(table.concat(args,' ',2),rank.name)
|
||||
else print('Invaild Rank, try asking for help from an admin') return end
|
||||
print('Command Complete')
|
||||
end
|
||||
end)
|
||||
end
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Read Me Gui--------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
addFrame('Readme',6, 'Rules','Readme', 'Rules, Server info, How to chat, Playerlist, Adminlist.')
|
||||
|
||||
addTab('Readme','Rules','The rules of the server',
|
||||
--temp
|
||||
ExpGui.add_frame.center('Test','Test','A Simple Gui',5)
|
||||
ExpGui.add_frame.tab('testing','Long Tab','Just Like any other',5,'Test',function(player,tab) for i=0,100 do tab.add{type='label',name=i,caption=player.name} end end)
|
||||
ExpGui.add_frame.tab('just_a_tab','A Tab','Just Like any other',5,'Test',function(player,tab) tab.add{type='label',name='temp',caption=player.name} end)
|
||||
ExpGui.add_frame.left('left_test','Player Name','Just Like any other',5,true,function(player,frame) for i=0,10 do frame.add{type='label',name=i,caption=player.name..'\n'} end end)
|
||||
ExpGui.add_input.button('make_message','Messgaes','Lots of messages',function() for i = 1,10 do ExpGui.draw_frame.popup('Message',{'Just A Message',i}) end end)
|
||||
ExpGui.add_frame.popup('Message','Message','Just A ToolTip',5,
|
||||
function(player,frame)
|
||||
local rules = {
|
||||
"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 use speakers on global 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. Or any loops of any kind",
|
||||
"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 i, rule in pairs(rules) do
|
||||
frame.add{name=i, type="label", caption={"", i ,". ", rule}}
|
||||
end
|
||||
end)
|
||||
addTab('Readme','Server Info','Info about the server',
|
||||
function(player,frame)
|
||||
frame.add{name=1, type="label", caption={"", "Discord voice and chat server:"}}
|
||||
frame.add{name=2, type='textfield', text='https://discord.gg/RPCxzgt'}.style.minimal_width=400
|
||||
frame.add{name=3, type="label", caption={"", "Our forum:"}}
|
||||
frame.add{name=4, type='textfield', text='https://explosivegaming.nl'}.style.minimal_width=400
|
||||
frame.add{name=5, type="label", caption={"", "Steam:"}}
|
||||
frame.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(player,frame)
|
||||
local chat = "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."
|
||||
frame.add{name=i, type="label", caption={"", chat}, single_line=false}.style.maximal_width=480
|
||||
end)
|
||||
addTab('Readme', 'Commands', 'Random useful commands',
|
||||
function(player, frame)
|
||||
frame.add{name='commandTable',type='table',colspan=2}
|
||||
for command,help in pairs(commands.commands) do
|
||||
local power = tonumber(help:sub(-2,-2))
|
||||
if power then else callRank(command..'has a help error') power = 0 end
|
||||
if getRank(player).power > power then else
|
||||
frame.commandTable.add{name='command_'..command,type='label',caption='/'..command}
|
||||
frame.commandTable.add{name='help_'..command,type='label',caption=help:sub(1,-4),single_line=false}.style.maximal_width=480
|
||||
end
|
||||
end
|
||||
end)
|
||||
addTab('Readme','Players','List of all the people who have been on the server',
|
||||
function(player,frame)
|
||||
local players = {
|
||||
"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 i, line in pairs(players) do
|
||||
frame.add{name=i, type="label", caption={"", line}}
|
||||
end
|
||||
frame.add{name='filterTable',type='table',colspan=3}
|
||||
frame.filterTable.add{name='name_label',type='label',caption='Name'}
|
||||
frame.filterTable.add{name='status_label',type='label',caption='Online?'}
|
||||
frame.filterTable.add{name='hours_label',type='label',caption='Online Time (minutes)'}
|
||||
frame.filterTable.add{name='name_input',type='textfield'}
|
||||
frame.filterTable.add{name='status_input',type='textfield'}
|
||||
frame.filterTable.add{name='hours_input',type='textfield'}
|
||||
drawPlayerTable(player, frame, false, {})
|
||||
end)
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Admin Gui----------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
addFrame('Admin',3,'Edit Ranks','Admin',"All admin fuctions are here")
|
||||
|
||||
addButton('setRanks',
|
||||
function(player,frame)
|
||||
rank = stringToRank(frame.parent.rank_input.items[frame.parent.rank_input.selected_index])
|
||||
if rank then
|
||||
for _,playerName in pairs(global.selected[player.index]) do
|
||||
p=game.players[playerName]
|
||||
if getRank(player).power < getRank(p).power and rank.power > getRank(player).power then
|
||||
giveRank(p,rank,player)
|
||||
clearSelection(player)
|
||||
drawPlayerTable(player, frame.parent.parent, true, {})
|
||||
else
|
||||
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
|
||||
end)
|
||||
addButton('clearSelection',function(player,frame) clearSelection(player) drawPlayerTable(player, frame.parent.parent, true, {}) end)
|
||||
|
||||
addTab('Admin', 'Commands', 'Random useful commands',
|
||||
function(player, frame)
|
||||
frame.add{name='commandTable',type='table',colspan=2}
|
||||
for command,help in pairs(commands.commands) do
|
||||
local power = tonumber(help:sub(-2,-2))
|
||||
if power then else callRank(command..'has a help error') power = 0 end
|
||||
if getRank(player).power > power then else
|
||||
frame.commandTable.add{name='command_'..command,type='label',caption='/'..command}
|
||||
frame.commandTable.add{name='help_'..command,type='label',caption=help:sub(1,-4),single_line=false}.style.maximal_width=480
|
||||
end
|
||||
end
|
||||
end)
|
||||
addTab('Admin','Edit Ranks', 'Edit the ranks of players below you',
|
||||
function(player,frame)
|
||||
clearSelection(player)
|
||||
frame.add{name='filterTable',type='table',colspan=1}
|
||||
frame.filterTable.add{name='name_label',type='label',caption='Name'}
|
||||
frame.filterTable.add{name='name_input',type='textfield'}
|
||||
frame.add{type='flow',name='rank',direction='horizontal'}
|
||||
frame.rank.add{name='rank_label',type='label',caption='Rank'}
|
||||
frame.rank.add{name='rank_input',type='drop-down'}
|
||||
for _,rank in pairs(global.ranks) do if rank.power > getRank(player).power then frame.rank.rank_input.add_item(rank.name) end end
|
||||
frame.rank.rank_input.selected_index = 1
|
||||
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, true, {powerOver=true})
|
||||
end)
|
||||
----------------------------------------------------------------------------------------
|
||||
---------------------------Admin+ Gui---------------------------------------------------
|
||||
----------------------------------------------------------------------------------------
|
||||
addFrame('Admin+',2,'Modifiers','Admin+',"Because we are better")
|
||||
|
||||
addButton('remove_biters',function(player,frame) for key, entity in pairs(game.surfaces[1].find_entities_filtered({force='enemy'})) do entity.destroy() end end)
|
||||
addButton('toggle_cheat',function(player,frame) player.cheat_mode = not player.cheat_mode end)
|
||||
addButton("btn_Modifier_apply",
|
||||
function(player,frame)
|
||||
local forceModifiers = {
|
||||
"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 i, modifier in pairs(forceModifiers) do
|
||||
local number = tonumber(( frame.parent.parent.modifierTable[modifier .. "_input"].text):match("[%d]+[.%d+]"))
|
||||
if number ~= nil then
|
||||
if number >= 0 and number < 50 and number ~= player.force[modifier] then
|
||||
player.force[modifier] = number
|
||||
player.print(modifier .. " changed to number: " .. tostring(number))
|
||||
elseif number == player.force[modifier] then
|
||||
player.print(modifier .. " Did not change")
|
||||
else
|
||||
player.print(modifier .. " needs to be player higher number or it contains an letter")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
addTab('Admin+', 'Commands', 'Random useful commands',
|
||||
function(player, frame)
|
||||
drawButton(frame,'remove_biters','Kill Biters','Removes all biters in map')
|
||||
drawButton(frame,'toggle_cheat','Toggle Cheat Mode','Toggle your cheat mode')
|
||||
end)
|
||||
|
||||
addTab('Admin+', 'Modifiers', 'Edit in game modifiers',
|
||||
function(player,frame)
|
||||
local forceModifiers = {
|
||||
"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"
|
||||
}
|
||||
frame.add{type = "flow", name= "flowNavigation",direction = "horizontal"}
|
||||
frame.add{name="modifierTable", type="table", colspan=3}
|
||||
frame.modifierTable.add{name="Mname", type="label", caption="name"}
|
||||
frame.modifierTable.add{name="input", type="label", caption="input"}
|
||||
frame.modifierTable.add{name="current", type="label", caption="current"}
|
||||
for i, modifier in pairs(forceModifiers) do
|
||||
frame.modifierTable.add{name=modifier, type="label", caption=modifier}
|
||||
frame.modifierTable.add{name=modifier .. "_input", type="textfield", caption="inputTextField"}
|
||||
frame.modifierTable.add{name=modifier .. "_current", type="label", caption=tostring(player.force[modifier])}
|
||||
end
|
||||
drawButton(frame.flowNavigation,"btn_Modifier_apply","Apply","Apply the new values to the game")
|
||||
ExpGui.add_input.draw_button(frame,'make_message') end,
|
||||
function(player,frame,args)
|
||||
frame.add{name='Message',type='label',caption=args[1]..' '..args[2]}
|
||||
end)
|
||||
ExpGui.add_frame.tab('player_table','Player Table','Just Like any other',5,'Test',function(player,tab)
|
||||
ExpGui.player_table.draw_filters(player,tab,{'player_name','online_time','rank'})
|
||||
ExpGui.player_table.draw(player,tab,{{'online',true}},tab)
|
||||
end)
|
||||
23
locale/ExpGaming-Addons/file-header.lua
Normal file
23
locale/ExpGaming-Addons/file-header.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='File Header - ExpGaming-Addons',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Just A File Header To Organise Code',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
68
locale/ExpGaming-Core/ExpGaming - Lib.lua
Normal file
68
locale/ExpGaming-Core/ExpGaming - Lib.lua
Normal file
@@ -0,0 +1,68 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='ExpGaming - Lib',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='A few basic functions used by scripts',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
--this will convert ticks into hours based on game speed
|
||||
function tick_to_hour (tick)
|
||||
local hour = tostring(math.floor(tick/(216000*game.speed)))
|
||||
return hour
|
||||
end
|
||||
--this will convert ticks into minutes based on game speed
|
||||
function tick_to_min (tick)
|
||||
local minutes = math.floor(tick/(3600*game.speed))
|
||||
return minutes
|
||||
end
|
||||
--i stole this from somewhere a long time ago but this and the other two functions convert a table into a string
|
||||
function table.val_to_str ( v )
|
||||
if "string" == type( v ) then
|
||||
v = string.gsub( v, "\n", "\\n" )
|
||||
if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
|
||||
return "'" .. v .. "'"
|
||||
end
|
||||
return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
|
||||
else
|
||||
return "table" == type( v ) and table.to_string( v ) or
|
||||
tostring( v )
|
||||
end
|
||||
end
|
||||
|
||||
function table.key_to_str ( k )
|
||||
if "string" == type( k ) and string.match( k, "^[_%player][_%player%d]*$" ) then
|
||||
return k
|
||||
else
|
||||
return "[" .. table.val_to_str( k ) .. "]"
|
||||
end
|
||||
end
|
||||
|
||||
function table.to_string( tbl )
|
||||
local result, done = {}, {}
|
||||
for k, v in ipairs( tbl ) do
|
||||
table.insert( result, table.val_to_str( v ) )
|
||||
done[ k ] = true
|
||||
end
|
||||
for k, v in pairs( tbl ) do
|
||||
if not done[ k ] then
|
||||
table.insert( result,
|
||||
table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
|
||||
end
|
||||
end
|
||||
return "{" .. table.concat( result, "," ) .. "}"
|
||||
end
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
136
locale/ExpGaming-Core/ExpGaming - Rank Control.lua
Normal file
136
locale/ExpGaming-Core/ExpGaming - Rank Control.lua
Normal file
@@ -0,0 +1,136 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='Explosive Gaming Rank System',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='The very core that all of the others are based on',
|
||||
factorio_version='0.15.23',
|
||||
show=true
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
--this will return the rank of the player given
|
||||
function get_rank(player)
|
||||
if player then
|
||||
for _,rank in pairs(global.ranks) do
|
||||
if player.permission_group == game.permissions.get_group(rank.name) then return rank end
|
||||
end
|
||||
return string_to_rank('Guest')
|
||||
end
|
||||
end
|
||||
--this will convert the name of a rank into the rank object
|
||||
function string_to_rank(string)
|
||||
if type(string) == 'string' then
|
||||
local Foundranks={}
|
||||
for _,rank in pairs(global.ranks) do
|
||||
if rank.name:lower() == string:lower() then return rank end
|
||||
if rank.name:lower():find(string:lower()) then table.insert(Foundranks,rank) end
|
||||
end
|
||||
if #Foundranks == 1 then return Foundranks[1] end
|
||||
end
|
||||
end
|
||||
--this will send a message to all members if this rank and above default is mod rank
|
||||
function rank_print(msg, rank, inv)
|
||||
local rank = string_to_rank(rank) or string_to_rank('Mod') -- default mod or higher
|
||||
local inv = inv or false
|
||||
for _, player in pairs(game.players) do
|
||||
rankPower = get_rank(player).power
|
||||
if inv then
|
||||
if rankPower >= rank.power then
|
||||
player.print(('[Everyone]: '..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
|
||||
end
|
||||
--this will give the user their new rank and raise the Event.rank_change event
|
||||
function give_rank(player,rank,by_player)
|
||||
local by_player = by_player or 'system'
|
||||
local rank = string_to_rank(rank) or rank or string_to_rank('Guest')
|
||||
local old_rank = get_rank(player)
|
||||
--messaging
|
||||
local message = 'demoted'
|
||||
if rank.power <= old_rank.power then message = 'promoted' end
|
||||
if by_player.name then
|
||||
rank_print(player.name..' was '..message..' to '..rank.name..' by '..by_player.name,'Guest')
|
||||
else
|
||||
rank_print(player.name..' was '..message..' to '..rank.name..' by <system>','Guest')
|
||||
end
|
||||
player.print('You Have Been Given The '..rank.name..' Rank!')
|
||||
--if for some reason the tag is diffrent to the deafult
|
||||
if player.tag ~= old_rank.tag then player.print('Your Tag Was Reset Due To A Rank Change') end
|
||||
--rank change
|
||||
player.permission_group = game.permissions.get_group(rank.name)
|
||||
player.tag = get_rank(player).tag
|
||||
if old_rank.name ~= 'Jail' then global.old_ranks[player.index]=old_rank.name end
|
||||
script.raise_event(Event.rank_change, {player=player, by_player=by_player, new_rank=rank, old_rank=old_rank})
|
||||
end
|
||||
--the user's rank is reverted to what it was before the lastest change
|
||||
function revert_rank(player,by_player)
|
||||
local rank = string_to_rank(global.old_ranks[player.index])
|
||||
give_rank(player,rank,by_player)
|
||||
end
|
||||
--the player is given a new rank based on playtime and/or preset ranks
|
||||
function find_new_rank(player)
|
||||
local function loop_preset_rank(players,rank)
|
||||
for _,p in pairs(players) do
|
||||
if player.name:lower() == p:lower() then return rank end
|
||||
end
|
||||
end
|
||||
local current_rank = get_rank(player)
|
||||
local old_rank = get_rank(player)
|
||||
local possible_ranks = {current_rank}
|
||||
--loops though preset ranks only if playtime is less than 5 minutes
|
||||
if tick_to_min(player.online_time) < 5 then
|
||||
for rank,players in pairs(global.preset_ranks) do
|
||||
local found_rank = loop_preset_rank(players, rank)
|
||||
if found_rank then table.insert(possible_ranks,string_to_rank(found_rank)) break end
|
||||
end
|
||||
end
|
||||
--loops though rank times
|
||||
for _,rank in pairs(global.ranks) do
|
||||
if rank.time and tick_to_min(player.online_time) >= rank.time then table.insert(possible_ranks,string_to_rank(rank)) end
|
||||
end
|
||||
--loops though possible ranks
|
||||
if current_rank.name ~='Jail' then
|
||||
local highest_rank = possible_ranks[1]
|
||||
for _,rank in pairs(possible_ranks) do
|
||||
if rank.power < highest_rank.power then highest_rank = rank end
|
||||
end
|
||||
--gives player new rank if availble
|
||||
if highest_rank.name == 'Guest' then
|
||||
player.permission_group=game.permissions.get_group('Guest')
|
||||
else
|
||||
give_rank(player,highest_rank)
|
||||
end
|
||||
end
|
||||
--lose ends
|
||||
if get_rank(player).power <= 3 and not player.admin then rank_print(player.name..' needs to be promoted.') end
|
||||
if old_rank.name ~= get_rank(player).name then global.old_ranks[player.index]=old_rank.name end
|
||||
end
|
||||
--event handlers
|
||||
Event.rank_change = script.generate_event_name()
|
||||
Event.register(-1,function()
|
||||
global.old_ranks = {}
|
||||
for _,rank in pairs(global.ranks) do
|
||||
game.permissions.create_group(rank.name)
|
||||
for _,toRemove in pairs(rank.disallow) do
|
||||
game.permissions.get_group(rank.name).set_allows_action(defines.input_action[toRemove],false)
|
||||
end
|
||||
end
|
||||
end)
|
||||
Event.register(defines.events.on_player_joined_game,function(event) find_new_rank(game.players[event.player_index]) end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
78
locale/ExpGaming-Core/ExpGaming - Rank Presets.lua
Normal file
78
locale/ExpGaming-Core/ExpGaming - Rank Presets.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='ExpGaming - Rank Preset Table',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='The Ranks that players are given apon joining',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
local preset_ranks = {
|
||||
Owner={'badgamernl'},
|
||||
|
||||
['Community Manager']={'arty714'},
|
||||
|
||||
Developer={'Cooldude2606'},
|
||||
|
||||
Admin={
|
||||
'eissturm',
|
||||
'PropangasEddy',
|
||||
'Smou'},
|
||||
|
||||
Mod={
|
||||
'AcThPaU',
|
||||
'Alanore',
|
||||
'Aquaday',
|
||||
'cafeslacker',
|
||||
'CrashKonijn',
|
||||
'Drahc_pro',
|
||||
'FlipHalfling90',
|
||||
'freek16',
|
||||
'Hobbitkicker',
|
||||
'hud',
|
||||
'Koroto',
|
||||
'mark9064',
|
||||
'Matthias60',
|
||||
'MeDDish',
|
||||
'Mindxt20',
|
||||
'MottledPetrel',
|
||||
'Mr_Happy_212',
|
||||
'NextIdea',
|
||||
'Phoenix27833',
|
||||
'samy115',
|
||||
'Sand3r205',
|
||||
'scarbvis',
|
||||
'steentje77',
|
||||
'tophatgaming123',
|
||||
'VR29',
|
||||
'xenocyber'},
|
||||
|
||||
Donator={
|
||||
'M74132',
|
||||
'Splicer'},
|
||||
|
||||
Veteran={},
|
||||
|
||||
Member={},
|
||||
|
||||
Regular={},
|
||||
|
||||
Guest={},
|
||||
|
||||
Jail={}
|
||||
}
|
||||
|
||||
Event.register(-1,function() global.preset_ranks = preset_ranks end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
158
locale/ExpGaming-Core/ExpGaming - Rank Table.lua
Normal file
158
locale/ExpGaming-Core/ExpGaming - Rank Table.lua
Normal file
@@ -0,0 +1,158 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='ExpGaming - Ranks Table',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Table holding the ranks used',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
--[[
|
||||
Rank Powers:
|
||||
0: root
|
||||
1: no restrictions - management ranks
|
||||
2: unable to use scripting commands - must be with sudo()
|
||||
3: able to jail people - must use /promote to be able to ban
|
||||
4: highest user power
|
||||
5: people who are trusted
|
||||
6: default power level
|
||||
7: full restrictions
|
||||
|
||||
For disallow add to the list the end part of the input action
|
||||
Example: defines.input_action.drop_item -> 'drop_item'
|
||||
http://lua-api.factorio.com/latest/defines.html#defines.input_action
|
||||
--]]
|
||||
local ranks = {
|
||||
{name='Owner',
|
||||
shortHand='Owner',
|
||||
tag='[Owner]',
|
||||
power=0,
|
||||
time=nil,
|
||||
colour={r=170,g=0,b=0},
|
||||
disallow={}},
|
||||
|
||||
{name='Community Manager',
|
||||
shortHand='Com Mngr',
|
||||
tag='[Com Mngr]',
|
||||
power=1,
|
||||
time=nil,
|
||||
colour={r=150,g=68,b=161},
|
||||
disallow={}},
|
||||
|
||||
{name='Developer',
|
||||
shortHand='Dev',
|
||||
tag='[Dev]',
|
||||
power=1,
|
||||
time=nil,
|
||||
colour={r=179,g=125,b=46},
|
||||
disallow={}},
|
||||
|
||||
{name='Admin',
|
||||
shortHand='Admin',
|
||||
tag='[Admin]',
|
||||
power=2,
|
||||
time=nil,
|
||||
colour={r=233,g=63,b=233},
|
||||
disallow={
|
||||
'set_allow_commands',
|
||||
'edit_permission_group',
|
||||
'delete_permission_group',
|
||||
'add_permission_group'}
|
||||
},
|
||||
|
||||
{name='Mod',
|
||||
shortHand='Mod',
|
||||
tag='[Mod]',
|
||||
power=3,
|
||||
time=nil,
|
||||
colour={r=0,g=170,b=0},
|
||||
disallow={
|
||||
'server_command'}
|
||||
},
|
||||
|
||||
{name='Donator',
|
||||
shortHand='P2W',
|
||||
tag='[P2W]',
|
||||
power=4,
|
||||
time=nil,
|
||||
colour={r=233,g=63,b=233},
|
||||
disallow={}},
|
||||
|
||||
{name='Veteran',
|
||||
shortHand='Vet',
|
||||
tag='[Veteran]',
|
||||
power=4,
|
||||
time=600,
|
||||
colour={r=140,g=120,b=200},
|
||||
disallow={}},
|
||||
|
||||
{name='Member',
|
||||
shortHand='Mem',
|
||||
tag='[Member]',
|
||||
power=5,
|
||||
time=nil,
|
||||
colour={r=24,g=172,b=188},
|
||||
disallow={}},
|
||||
|
||||
{name='Regular',
|
||||
shortHand='Reg',
|
||||
tag='[Regular]',
|
||||
power=5,
|
||||
time=180,
|
||||
colour={r=24,g=172,b=188},
|
||||
disallow={
|
||||
'set_auto_launch_rocket',
|
||||
'change_programmable_speaker_alert_parameters',
|
||||
'reset_assembling_machine',
|
||||
'drop_item'}
|
||||
},
|
||||
|
||||
{name='Guest',
|
||||
shortHand='',
|
||||
tag='[Guest]',
|
||||
power=6,
|
||||
time=nil,
|
||||
colour={r=255,g=159,b=27},
|
||||
disallow={
|
||||
'build_terrain',
|
||||
'remove_cables',
|
||||
'launch_rocket',
|
||||
'cancel_research'}
|
||||
},
|
||||
|
||||
{name='Jail',
|
||||
shortHand='Jail',
|
||||
tag='[Jail]',
|
||||
power=7,
|
||||
time=nil,
|
||||
colour={r=50,g=50,b=50},
|
||||
disallow={
|
||||
'open_character_gui',
|
||||
'begin_mining',
|
||||
'start_walking',
|
||||
'player_leave_game'}
|
||||
}
|
||||
}
|
||||
-- This For Loop cauess the disallows of each rank to be feed into the one below its self
|
||||
for n,rank in pairs(ranks) do
|
||||
if ranks[n-1] then
|
||||
for _,disallow in pairs(ranks[n-1].disallow) do
|
||||
table.insert(rank.disallow,disallow)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Moves The Ranks to the global array
|
||||
Event.register(-1,function() global.ranks = ranks end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
54
locale/ExpGaming-Core/ExpGaming - Server Interface.lua
Normal file
54
locale/ExpGaming-Core/ExpGaming - Server Interface.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='Explosive Gaming Server Interface',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='A way of talking with the server with out breaking achevements',
|
||||
factorio_version='0.15.23',
|
||||
show=true
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
--this command is just a way or using loadstring from in game while keeping achevements
|
||||
Event.register(defines.events.on_player_joined_game,function()
|
||||
if commands.commands['server-interface'] then return end
|
||||
commands.add_command('server-interface','<command> #2#',function(event)
|
||||
if event.player_index then
|
||||
local by_player = game.players[event.player_index]
|
||||
if get_rank(by_player).power > 2 then by_player.print('401 - Unauthorized: Access is denied due to invalid credentials') return end
|
||||
if event.parameter then else by_player.print('Invaid Input, /server-interface <command>') return end
|
||||
local returned,value = pcall(loadstring(event.parameter))
|
||||
if type(value) == 'table' then game.write_file('log.txt', '\n Ran by: '..by_player.name..'\n Code: '..event.parameter..'\n $£$ '..table.to_string(value), true, 0) by_player.print(table.to_string(value))
|
||||
else game.write_file('log.txt', '\n Ran by: '..by_player.name..'\n Code: '..event.parameter..'\n $£$ '..tostring(value), true, 0) by_player.print(value) end
|
||||
else
|
||||
if event.parameter then else print('Invaid Input, /server-interface <command>') return end
|
||||
local returned,value = pcall(loadstring(event.parameter))
|
||||
if type(value) == 'table' then game.write_file('log.txt', '\n Ran by: <server> \n Code: '..event.parameter..'\n $£$ '..table.to_string(value), true, 0) print(table.to_string(value))
|
||||
else game.write_file('log.txt', '\n Ran by: <server> \n Code: '..event.parameter..'\n $£$ '..tostring(value), true, 0) print(value) end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
--this is used when changing permsion groups when the person does not have permsion to
|
||||
function sudo(command,args) table.insert(global.sudo,{fun=command,var=args}) end
|
||||
--runs one sudo command every second if one is present
|
||||
Event.register(defines.events.on_tick, function(event)
|
||||
if game.tick % 60 == 0 and global.sudo and #global.sudo > 0 then
|
||||
command=table.remove(global.sudo)
|
||||
if command and command.fun and type(command.fun) == 'function' then
|
||||
local args = command.var or {}
|
||||
command.fun(unpack(args))
|
||||
end
|
||||
end
|
||||
end)
|
||||
Event.register(-1,function() global.sudo = {} end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
75
locale/ExpGaming-Core/GUI/ExpGaming - Center Gui.lua
Normal file
75
locale/ExpGaming-Core/GUI/ExpGaming - Center Gui.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='ExpGaming - Center Gui',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='The main gui in the center',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
local add_frame = ExpGui.add_frame
|
||||
local frames = ExpGui.frames
|
||||
local draw_frame = ExpGui.draw_frame
|
||||
--adds a frame in the center; tabs {{name,restriction},{...}} is a list that can contain already defined tabs; event(player,element) is a option to have a custom gui in the center
|
||||
function add_frame.center(name,default_display,default_tooltip,restriction,tabs,event)
|
||||
if not name then error('Frame requires a name') end
|
||||
local tabs = tabs or {}
|
||||
table.insert(frames.center,{name,default_display,tabs,event})
|
||||
ExpGui.toolbar.add_button(name,default_display,default_tooltip,restriction,draw_frame.center)
|
||||
end
|
||||
--defines a tab; frame is need as every tab must be used once; event(player,tab) is the draw function
|
||||
function add_frame.tab(name,default_display,default_tooltip,restriction,frame,event)
|
||||
if not name then error('Tab requires a name') end
|
||||
if not frame then error('Tab requires a frame') end
|
||||
table.insert(frames.tabs,{name,default_display,frame,event})
|
||||
for _,f in pairs(frames.center) do if f[1] == frame then table.insert(f[3],{name,restriction}) end end
|
||||
ExpGui.add_input.button(name,default_display,default_tooltip,draw_frame.tab)
|
||||
end
|
||||
--draw the center gui for the player; do not call manuley must use other functions to call
|
||||
ExpGui.add_input.button('close_center','Close','Close This Gui',function(player,element) element.parent.parent.parent.destroy() end)
|
||||
function draw_frame.center(player,element)
|
||||
local frame_data = nil
|
||||
for _,frame in pairs(frames.center) do if element.name == frame[1] then frame_data = frame break end end
|
||||
if player.gui.is_valid_sprite_path(frame_data[2]) then frame_data[2] = frame_data[1] end
|
||||
if player.gui.center[frame_data[1]] then player.gui.center.clear() return else player.gui.center.clear() end
|
||||
if frame_data[4] and type(frame_data[4]) == 'function' then frame_data[4](player,element) return end
|
||||
local frame = player.gui.center.add{name=frame_data[1],type='frame',caption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
local tab_bar_scroll = frame.add{type = "scroll-pane", name= "tab_bar_scroll", vertical_scroll_policy="never", horizontal_scroll_policy="always"}
|
||||
local tab_bar = tab_bar_scroll.add{type='flow',direction='horizontal',name='tab_bar'}
|
||||
local tab = frame.add{type = "scroll-pane", name= "tab", vertical_scroll_policy="auto", horizontal_scroll_policy="never"}
|
||||
for n,t in pairs(frame_data[3]) do if t[2] >= get_rank(player).power then ExpGui.add_input.draw_button(tab_bar,t[1]) end end
|
||||
draw_frame.tab(player,tab_bar[frame_data[3][1][1]])
|
||||
ExpGui.add_input.draw_button(tab_bar,'close_center')
|
||||
tab.style.minimal_height = 300
|
||||
tab.style.maximal_height = 300
|
||||
tab.style.minimal_width = 500
|
||||
tab.style.maximal_width = 500
|
||||
tab_bar_scroll.style.minimal_height = 60
|
||||
tab_bar_scroll.style.maximal_height = 60
|
||||
tab_bar_scroll.style.minimal_width = 500
|
||||
tab_bar_scroll.style.maximal_width = 500
|
||||
player.gui.center.add{type='frame',name='temp'}.destroy()--recenter the gui
|
||||
end
|
||||
--draw the tab into the center gui for the player; do not call manuley must use other functions to call
|
||||
function draw_frame.tab(player,element)
|
||||
for _,btn in pairs(element.parent.children) do if btn.name == 'close_center' or btn.name == element.name then
|
||||
btn.style.font_color = {r = 255, g = 255, b = 255,a=255}
|
||||
else
|
||||
btn.style.font_color = {r = 100, g = 100, b = 100,a=255}
|
||||
end end
|
||||
element.parent.parent.parent.tab.clear()
|
||||
for _,tab in pairs(frames.tabs) do if element.name == tab[1] then tab[4](player,element.parent.parent.parent.tab) break end end
|
||||
end
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
83
locale/ExpGaming-Core/GUI/ExpGaming - Inputs.lua
Normal file
83
locale/ExpGaming-Core/GUI/ExpGaming - Inputs.lua
Normal file
@@ -0,0 +1,83 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='Gui Input Handler',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Handles all gui inputs',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
local add_input = ExpGui.add_input
|
||||
local inputs = ExpGui.inputs
|
||||
--allows defining of new buttons;;name how to call button;;default_display what is showen on the button;;default_tooltip the tooltip display;;event function(player,element) that runs on click
|
||||
function add_input.button(name,default_display,default_tooltip,event)
|
||||
if not name then error('Button requires a name') end
|
||||
table.insert(inputs.buttons,{name,default_display,default_tooltip,event})
|
||||
end
|
||||
--allows defining of text box inputs;;name how to call button;;default_display what is showen on the button;;event function(player,element) that runs on text change
|
||||
function add_input.text(name,default_display,event)
|
||||
if not name then error('Text Filed requires a name') end
|
||||
table.insert(inputs.text,{name,default_display,event})
|
||||
end
|
||||
--draws the button into a gui;;frame the frame to draw to;;name name of button to draw;;display(opptinal) overides the default;;tooltip(opptinal) overides the default
|
||||
function add_input.draw_button(frame,name,display,tooltip)
|
||||
if not frame or not frame.valid then error('No frame to draw to') end
|
||||
if not name then error('No button to draw') end
|
||||
for _,btn in pairs(inputs.buttons) do
|
||||
if btn[1] == name then
|
||||
local display = display or btn[2] or btn[1]
|
||||
local tooltip = tooltip or btn[3]
|
||||
if frame.gui.is_valid_sprite_path(display) then
|
||||
frame.add{name=name, type = "sprite-button", sprite=display, tooltip=tooltip, style = mod_gui.button_style}
|
||||
else
|
||||
frame.add{name=name, type = "button", caption=display, tooltip=tooltip, style = mod_gui.button_style}
|
||||
end return
|
||||
end
|
||||
end
|
||||
error('No Button By The Name Of '..name)
|
||||
end
|
||||
--draws the text into a gui;;frame the frame to draw to;;name name of button to draw;;display(opptinal) overides the default;;tooltip(opptinal) overides the default
|
||||
function add_input.draw_text(frame,name,display)
|
||||
if not frame or not frame.valid then error('No frame to draw to') end
|
||||
if not name then error('No text filed to draw') end
|
||||
for _,text in pairs(inputs.text) do
|
||||
if text[1] == name then
|
||||
local display = display or text[2] or text[1]
|
||||
frame.add{name=name, type='textfield', text=display}
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
--the magic behind the buttons
|
||||
Event.register(defines.events.on_gui_click, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
if event.element.type == 'button' or event.element.type == 'sprite-button' then
|
||||
for _,btn in pairs(inputs.buttons) do
|
||||
if btn[1] == event.element.name then
|
||||
if btn[4] then btn[4](player,event.element) else rank_print('Button Without Function '..btn[1],'Mod') end break
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
--the magic behind the text inputs
|
||||
Event.register(defines.events.on_gui_text_changed, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
for _,text in pairs(inputs.text) do
|
||||
if text[1] == event.element.name then
|
||||
if text[3] then text[3](player,event.element) end break
|
||||
end
|
||||
end
|
||||
end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
61
locale/ExpGaming-Core/GUI/ExpGaming - Left Gui.lua
Normal file
61
locale/ExpGaming-Core/GUI/ExpGaming - Left Gui.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='ExpGaming - Left Gui',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='A simple way to add toggle menus to the left',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
local add_frame = ExpGui.add_frame
|
||||
local frames = ExpGui.frames
|
||||
local draw_frame = ExpGui.draw_frame
|
||||
--left guis are always present and only have their visabilty toggled
|
||||
--adds a frame to the left bar; event(player,frame) must be present for left guis as there is no default
|
||||
--vis must be true must be true or false based on the default stae of the gui
|
||||
function add_frame.left(name,default_display,default_tooltip,restriction,vis,event)
|
||||
if not name then error('Frame requires a name') end
|
||||
if not event or type(event) ~= 'function' then error('Frame requires a draw function') end
|
||||
local vis = vis or false
|
||||
table.insert(frames.left,{name,default_display,event,vis})
|
||||
ExpGui.toolbar.add_button(name,default_display,default_tooltip,restriction,draw_frame.left)
|
||||
end
|
||||
--draw the left gui for the player; called via script, only call manuley when update is true and element is the name of the gui
|
||||
function draw_frame.left(player,element,update)
|
||||
local frame = nil
|
||||
local frame_data = nil
|
||||
local left = mod_gui.get_frame_flow(player)
|
||||
if not update then
|
||||
for _,frame in pairs(frames.left) do if element.name == frame[1] then frame_data = frame break end end
|
||||
if left[frame_data[1]] then ExpGui.toggleVisable(left[frame_data[1]]) return end
|
||||
local frame = left.add{name=frame_data[1],type='frame',capption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
else
|
||||
for _,frame in pairs(frames.left) do if element == frame[1] then frame_data = frame break end end
|
||||
local frame = left[frame_data[1]] frame.clear()
|
||||
end
|
||||
frame_data[3](player,frame)
|
||||
end
|
||||
--used to load all left guis
|
||||
Event.register(defines.events.on_player_joined_game,function(event)
|
||||
local player = game.players[event.player_index]
|
||||
for _,frame_data in pairs(frames.left) do
|
||||
local left = mod_gui.get_frame_flow(player)
|
||||
if left[frame_data[1]] then ExpGui.toggleVisable(left[frame_data[1]]) return end
|
||||
local frame = left.add{name=frame_data[1],type='frame',capption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
frame_data[3](player,frame)
|
||||
frame.style.visible = frame_data[4]
|
||||
end
|
||||
end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
74
locale/ExpGaming-Core/GUI/ExpGaming - Modlue Setup.lua
Normal file
74
locale/ExpGaming-Core/GUI/ExpGaming - Modlue Setup.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='Explosive Gaming Gui System',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Without this it would not be the same',
|
||||
factorio_version='0.15.23',
|
||||
show=true
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
ExpGui = {
|
||||
add_frame={
|
||||
--center
|
||||
--tab
|
||||
--left
|
||||
--popup
|
||||
},
|
||||
draw_frame={
|
||||
--center
|
||||
--tab
|
||||
--left
|
||||
--popup
|
||||
},
|
||||
add_input={
|
||||
--button
|
||||
--text
|
||||
--draw_button
|
||||
--draw_text
|
||||
},
|
||||
toolbar={
|
||||
buttons={}
|
||||
--draw
|
||||
--add_button
|
||||
},
|
||||
player_table={
|
||||
filters={}
|
||||
--draw
|
||||
--draw_filters
|
||||
--get_filters
|
||||
--player_match
|
||||
},
|
||||
inputs={
|
||||
buttons={},
|
||||
text={}
|
||||
},
|
||||
frames={
|
||||
center={},
|
||||
tabs={},
|
||||
left={},
|
||||
popup={}
|
||||
}
|
||||
}
|
||||
--simple function to toggle the visiblly of a frame
|
||||
function ExpGui.toggleVisable(frame)
|
||||
if frame then
|
||||
if frame.style.visible == nil then
|
||||
frame.style.visible = false
|
||||
else
|
||||
frame.style.visible = not frame.style.visible
|
||||
end
|
||||
end
|
||||
end
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
121
locale/ExpGaming-Core/GUI/ExpGaming - Player Table.lua
Normal file
121
locale/ExpGaming-Core/GUI/ExpGaming - Player Table.lua
Normal file
@@ -0,0 +1,121 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='ExpGaming - Player Table',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Allows addition of a player table with filters',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
local player_table_functions = ExpGui.player_table
|
||||
local yes = {'yes','y','true','ye'}
|
||||
local no = {'no','false','nay'}
|
||||
--filters that are used fell free to add more
|
||||
player_table_functions.filters = {
|
||||
--{name,is_text,function(player,input) return true end}
|
||||
{'is_admin',false,function(player) return player.admin end},
|
||||
{'player_name',true,function(player,input) if input and player.name:lower():find(input:lower()) then return true end end},
|
||||
{'online',false,function(player) return player.connected end},
|
||||
{'offline',false,function(player) return not player.connected end},
|
||||
{'online_time',true,function(player,input) if input and tonumber(input) and tonumber(input) < tick_to_min(player.online_time) then return true elseif not input or not tonumber(input) then return true end end},
|
||||
{'rank',true,function(player,input) if input and string_to_rank(input) and get_rank(player).power <= string_to_rank(input).power then return true end end}
|
||||
}
|
||||
--set up all the text inputs
|
||||
for _,filter in pairs(player_table_functions.filters) do
|
||||
if filter[2] then
|
||||
ExpGui.add_input.text(filter[1],'Enter '..filter[1]:gsub('_',' '),function(player,element) ExpGui.player_table.redraw(player,element) end)
|
||||
end
|
||||
end
|
||||
--used to draw filters from the list above
|
||||
function player_table_functions.draw_filters(player,frame,filters)
|
||||
local input_bar = frame.add{type='flow',name='input_bar',direction='horizontal'}
|
||||
for _,name in pairs(filters) do
|
||||
local filter_data = nil
|
||||
for _,filter in pairs(player_table_functions.filters) do if filter[1] == name then filter_data = filter break end end
|
||||
if filter_data and filter_data[2] then
|
||||
ExpGui.add_input.draw_text(input_bar,name)
|
||||
end
|
||||
end
|
||||
end
|
||||
--used by script to get the values for the any inputs given by the user
|
||||
function player_table_functions.get_filters(frame)
|
||||
local filters = {}
|
||||
for _,filter in pairs(player_table_functions.filters) do
|
||||
if frame.input_bar[filter[1]] then
|
||||
if frame.input_bar[filter[1]].text ~= 'Enter '..filter[1]:gsub('_',' ') or not frame.input_bar[filter[1]].text:find('%S') then
|
||||
table.insert(filters,{filter[1],frame.input_bar[filter[1]].text})
|
||||
end
|
||||
end
|
||||
end
|
||||
return filters
|
||||
end
|
||||
--used to test if a player matches filter critria
|
||||
function player_table_functions.player_match(player,filter,input)
|
||||
for _,f in pairs(player_table_functions.filters) do
|
||||
if filter == f or filter == f[1] then if filter == f[1] then filter = f break end end
|
||||
end
|
||||
if filter[3] and type(filter[3]) == 'function' then return filter[3](player,input) end
|
||||
end
|
||||
--used by script on filter texts
|
||||
function player_table_functions.redraw(player,element)
|
||||
local frame = global.current_filters[player.index][2]
|
||||
local filters = global.current_filters[player.index][1]
|
||||
player_table_functions.draw(player,frame,filters,element.parent.parent)
|
||||
end
|
||||
--used to draw the player table with filter that you want
|
||||
--filter = {{'is_admin',true},{'offline',true},{'player_name'}} ; if the leanth is 2 then it will not atemp to get a user input
|
||||
function player_table_functions.draw(player,frame,filters,input_location)
|
||||
global.current_filters[player.index] = {filters,frame}
|
||||
--setup the table
|
||||
if frame.player_table then frame.player_table.destroy() end
|
||||
player_table = frame.add{name='player_table', type="table", colspan=5}
|
||||
player_table.style.minimal_width = 500
|
||||
player_table.style.maximal_width = 500
|
||||
player_table.style.horizontal_spacing = 10
|
||||
player_table.add{name="id", type="label", caption="Id"}
|
||||
player_table.add{name="player_name", type="label", caption="Name"}
|
||||
player_table.add{name="status", type="label", caption="Status"}
|
||||
player_table.add{name="online_time", type="label", caption="Online Time"}
|
||||
player_table.add{name="rank", type="label", caption="Rank"}
|
||||
for i,p in pairs(game.players) do
|
||||
--filter cheaking
|
||||
local add=true
|
||||
for _,filter in pairs(filters) do
|
||||
if #filter == 2 and add then
|
||||
local result = player_table_functions.player_match(p,filter[1],filter[2])
|
||||
if not result and filter[2] == true then result = filter[2] end
|
||||
add = result or false
|
||||
end
|
||||
end
|
||||
for _,filter in pairs(player_table_functions.get_filters(input_location)) do
|
||||
if add then
|
||||
add = player_table_functions.player_match(p,filter[1],filter[2]) or false
|
||||
end
|
||||
end
|
||||
--add the player
|
||||
if add then--and player.name ~= p.name then
|
||||
player_table.add{name=p.name.."_id", type="label", caption=i}
|
||||
player_table.add{name=p.name..'_name', type="label", caption=p.name}
|
||||
if p.connected == true
|
||||
then player_table.add{name=p.name.."status", type="label", caption="Online"}
|
||||
else player_table.add{name=p.name.."s", type="label", caption="Offline"} end
|
||||
player_table.add{name=p.name.."online_time", type="label", caption=(tick_to_hour(p.online_time)..'H '..(tick_to_min(p.online_time)-60*tick_to_hour(p.online_time))..'M')}
|
||||
player_table.add{name=p.name.."rank", type="label", caption=get_rank(p).shortHand}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.register(-1,function() global.current_filters = {} end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
74
locale/ExpGaming-Core/GUI/ExpGaming - Popup.lua
Normal file
74
locale/ExpGaming-Core/GUI/ExpGaming - Popup.lua
Normal file
@@ -0,0 +1,74 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='ExpGaming - Popup Gui',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Small popups in the top left',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
local add_frame = ExpGui.add_frame
|
||||
local frames = ExpGui.frames
|
||||
local draw_frame = ExpGui.draw_frame
|
||||
--used to draw the next popup frame
|
||||
ExpGui.add_input.button('close_popup','X','Close This Popup',function(player,element) element.parent.destroy() end)
|
||||
local function get_next_popup(popups,name)
|
||||
if name then
|
||||
local flow = popups.add{type='frame',name=name..'_on_click',direction='horizontal',style=mod_gui.frame_style}
|
||||
local frame = flow.add{name='popup_frame',type='flow',direction='vertical'}
|
||||
ExpGui.add_input.draw_button(flow,'close_popup') return frame
|
||||
end
|
||||
local current = 0
|
||||
while true do if popups['popup'..current] then current = current+1 else break end end
|
||||
local flow = popups.add{type='frame',name='popup'..current,direction='horizontal',style=mod_gui.frame_style}
|
||||
local frame = flow.add{name='popup_frame',type='flow',direction='vertical'}
|
||||
ExpGui.add_input.draw_button(flow,'close_popup')
|
||||
return frame
|
||||
end
|
||||
--adds a frame to the popup flow;restriction is the power need to use the on_click function
|
||||
--on_click(player,element) is what is called when button is clicked if nil no button is made
|
||||
--event(player,frame,args) frame is where it will be drawen to; args is any infor you want to pass in
|
||||
function add_frame.popup(style,default_display,default_tooltip,restriction,on_click,event)
|
||||
if not style then error('Popup style requires a name') end
|
||||
if not event or type(event) ~= 'function' then error('Popup style requires a draw function') end
|
||||
local restriction = restriction or 0
|
||||
table.insert(frames.popup,{style,default_display,on_click,event})
|
||||
if on_click and type(on_click) == 'function' then
|
||||
ExpGui.toolbar.add_button(style,default_display,default_tooltip,restriction,draw_frame.popup_button)
|
||||
end
|
||||
end
|
||||
--draw the popup on_click gui for the player; do not call manuley must use other functions to call
|
||||
function draw_frame.popup_button(player,element)
|
||||
local frame_data = nil
|
||||
for _,frame in pairs(frames.popup) do if element.name == frame[1] then frame_data = frame break end end
|
||||
local popups = mod_gui.get_frame_flow(player).popups
|
||||
if popups[frame_data[1]..'_on_click'] then popups[frame_data[1]..'_on_click'].destroy() return end
|
||||
local frame = get_next_popup(popups,frame_data[1])
|
||||
frame_data[3](player,frame)
|
||||
end
|
||||
--used to draw a popup style can be called at any time; can not be called from a button directly
|
||||
function draw_frame.popup(style,args)
|
||||
local args = args or {}
|
||||
local frame_data = nil
|
||||
for _,frame in pairs(frames.popup) do if style == frame[1] then frame_data = frame break end end
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local popups = mod_gui.get_frame_flow(player).popups
|
||||
local frame = get_next_popup(popups)
|
||||
frame_data[4](player,frame,args)
|
||||
end
|
||||
end
|
||||
--used to make the popup area
|
||||
Event.register(defines.events.on_player_joined_game,function(event) mod_gui.get_frame_flow(game.players[event.player_index]).add{name='popups',type='flow',direction='vertical'} end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
44
locale/ExpGaming-Core/GUI/ExpGaming - Toolbar.lua
Normal file
44
locale/ExpGaming-Core/GUI/ExpGaming - Toolbar.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='A Very Useful Toolbar',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Some simple functions that help to control the toolbar',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
local toolbar = ExpGui.toolbar
|
||||
--similar to ExpGui.add_input.button but it also accepts a restriction and button is drawn to the toolbar
|
||||
function toolbar.add_button(name,default_display,default_tooltip,restriction,event)
|
||||
local restriction = restriction or 0
|
||||
if not name then error('Button requires a name') end
|
||||
table.insert(toolbar.buttons,{name,restriction})
|
||||
ExpGui.add_input.button(name,default_display,default_tooltip,event)
|
||||
end
|
||||
--draw the toolbar to the player only showing buttons within their restriction
|
||||
function toolbar.draw(player)
|
||||
if not player then error('Need a player to draw to') end
|
||||
local toolbar_frame = mod_gui.get_button_flow(player)
|
||||
toolbar_frame.clear()
|
||||
for _,btn in pairs(toolbar.buttons) do
|
||||
local rank = get_rank(player)
|
||||
if btn[2] >= rank.power then
|
||||
ExpGui.add_input.draw_button(toolbar_frame,btn[1])
|
||||
end
|
||||
end
|
||||
end
|
||||
--auto redraw toolbar after new rank is given
|
||||
Event.register(Event.rank_change,function(event) toolbar.draw(event.player) end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
29
locale/ExpGaming-Core/GUI/file-header.lua
Normal file
29
locale/ExpGaming-Core/GUI/file-header.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='File Header - ExpGaming-Core-GUI',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Just A File Header To Organise Code',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
credit_loop(require("ExpGaming - Modlue Setup"))
|
||||
credit_loop(require("ExpGaming - Inputs"))
|
||||
credit_loop(require("ExpGaming - Toolbar"))
|
||||
credit_loop(require("ExpGaming - Center Gui"))
|
||||
credit_loop(require("ExpGaming - Left Gui"))
|
||||
credit_loop(require("ExpGaming - Popup"))
|
||||
credit_loop(require("ExpGaming - Player Table"))
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
29
locale/ExpGaming-Core/file-header.lua
Normal file
29
locale/ExpGaming-Core/file-header.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='File Header - Stand-Alone',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Just A File Header To Organise Code',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
--as this is the core file the order in which the files are loaded does matter do not change
|
||||
credit_loop(require("ExpGaming - Lib"))
|
||||
credit_loop(require("ExpGaming - Rank Table"))
|
||||
credit_loop(require("ExpGaming - Rank Presets"))
|
||||
credit_loop(require("ExpGaming - Rank Control"))
|
||||
credit_loop(require("GUI/file-header"))
|
||||
credit_loop(require("ExpGaming - Server Interface"))
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
23
locale/Stand-Alone/file-header.lua
Normal file
23
locale/Stand-Alone/file-header.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='File Header - Scripts',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Just A File Header To Organise Code',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
16
locale/StdLib/core.lua
Normal file
16
locale/StdLib/core.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
--- Core module
|
||||
-- @module Core
|
||||
|
||||
Core = {} --luacheck: allow defined top
|
||||
|
||||
--- Errors if the variable evaluates to false, with an optional msg
|
||||
-- @param var variable to evaluate
|
||||
-- @tparam[opt='missing value'] string msg message
|
||||
function Core.fail_if_missing(var, msg)
|
||||
if not var then
|
||||
error(msg or "Missing value", 3)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
return Core
|
||||
171
locale/StdLib/event.lua
Normal file
171
locale/StdLib/event.lua
Normal file
@@ -0,0 +1,171 @@
|
||||
--- Makes working with events in factorio a lot more simple.
|
||||
-- <p>Factorio can only have one handler registered per event. This module
|
||||
-- allows you to easily register multiple handlers for each event.
|
||||
-- Using this module is as simple as replacing script.on_event(...) with Event.register(...)</p>
|
||||
-- @module Event
|
||||
-- @usage require('stdlib/event/event')
|
||||
|
||||
local credits = {{
|
||||
name='Factorio StdLib',
|
||||
owner='Afforess',
|
||||
dev='Afforess',
|
||||
description='The Factorio StdLib used here for the event handler',
|
||||
factorio_version='0.15.23',
|
||||
show=true
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
|
||||
local fail_if_missing = require 'core'['fail_if_missing']
|
||||
local Game = require 'game'
|
||||
|
||||
Event = { --luacheck: allow defined top
|
||||
_registry = {},
|
||||
core_events = {
|
||||
init = -1,
|
||||
load = -2,
|
||||
configuration_changed = -3,
|
||||
_register = function(id)
|
||||
if id == Event.core_events.init then
|
||||
script.on_init(
|
||||
function()
|
||||
Event.dispatch({name = Event.core_events.init, tick = game.tick})
|
||||
end
|
||||
)
|
||||
elseif id == Event.core_events.load then
|
||||
script.on_load(
|
||||
function()
|
||||
Event.dispatch({name = Event.core_events.load, tick = -1})
|
||||
end
|
||||
)
|
||||
elseif id == Event.core_events.configuration_changed then
|
||||
script.on_configuration_changed(
|
||||
function(event)
|
||||
event.name = Event.core_events.configuration_changed
|
||||
event.data = event -- for backwards compatibilty
|
||||
Event.dispatch(event)
|
||||
end
|
||||
)
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
--- Registers a function for a given event. If a nil handler is passed remove all events and stop listening for that event.
|
||||
-- Events are dispatched in the order they are registered.
|
||||
-- @usage Event.register(defines.events.on_tick, function(event) print event.tick end)
|
||||
-- -- creates an event that prints the current tick every tick.
|
||||
-- @tparam defines.events|{defines.events,...} event events to register
|
||||
-- @tparam function handler Function to call when event is triggered
|
||||
-- @treturn Event
|
||||
function Event.register(event, handler)
|
||||
fail_if_missing(event, "missing event argument")
|
||||
|
||||
event = (type(event) == "table" and event) or {event}
|
||||
|
||||
for _, event_id in pairs(event) do
|
||||
if not (type(event_id) == "number" or type(event_id) == "string") then
|
||||
error("Invalid Event Id, Must be string or int, or array of strings and/or ints", 2)
|
||||
end
|
||||
if handler == nil then
|
||||
Event._registry[event_id] = nil
|
||||
script.on_event(event_id, nil)
|
||||
else
|
||||
if not Event._registry[event_id] then
|
||||
Event._registry[event_id] = {}
|
||||
|
||||
if type(event_id) == "string" or event_id >= 0 then
|
||||
script.on_event(event_id, Event.dispatch)
|
||||
elseif event_id < 0 then
|
||||
Event.core_events._register(event_id)
|
||||
end
|
||||
end
|
||||
table.insert(Event._registry[event_id], handler)
|
||||
end
|
||||
end
|
||||
return Event
|
||||
end
|
||||
|
||||
--- Calls the registerd handlers
|
||||
-- Will stop dispatching remaning handlers if any handler passes invalid event userdata.
|
||||
-- Handlers are dispatched in the order they were created
|
||||
-- @tparam table event LuaEvent as created by script.raise_event
|
||||
-- @see https://forums.factorio.com/viewtopic.php?t=32039#p202158 Invalid Event Objects
|
||||
function Event.dispatch(event)
|
||||
if event then
|
||||
local _registry = event.name and Event._registry[event.name] or event.input_name and Event._registry[event.input_name]
|
||||
if _registry then
|
||||
local force_crc = Event.force_crc
|
||||
for idx, handler in ipairs(_registry) do
|
||||
|
||||
-- Check for userdata and stop processing further handlers if not valid
|
||||
for _, val in pairs(event) do
|
||||
if type(val) == "table" and val.__self == "userdata" and not val.valid then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
setmetatable(event, { __index = { _handler = handler } })
|
||||
|
||||
-- Call the handler
|
||||
local success, err = pcall(handler, event)
|
||||
|
||||
-- If the handler errors lets make sure someone notices
|
||||
if not success then
|
||||
if _G.game then -- may be nil in on_load
|
||||
if Game.print_all(err) == 0 then
|
||||
error(err) -- no players received the message, force a real error so someone notices
|
||||
end
|
||||
else
|
||||
error(err) -- no way to handle errors cleanly when the game is not up
|
||||
end
|
||||
-- continue processing the remaning handlers. In most cases they won't be related to the failed code.
|
||||
end
|
||||
|
||||
-- force a crc check if option is enabled. This is a debug option and will hamper perfomance if enabled
|
||||
if (force_crc or event.force_crc) and _G.game then
|
||||
local msg = 'CRC check called for event '..event.name..' handler #'..idx
|
||||
log(msg) -- log the message to factorio-current.log
|
||||
game.force_crc()
|
||||
end
|
||||
|
||||
-- if present stop further handlers for this event
|
||||
if event.stop_processing then
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
error('missing event argument')
|
||||
end
|
||||
end
|
||||
|
||||
--- Removes the handler from the event. If it removes the last handler for an event stop listening for that event.
|
||||
-- @tparam defines.events|{defines.events,...} event events to remove the handler for
|
||||
-- @tparam function handler to remove
|
||||
-- @return Event
|
||||
function Event.remove(event, handler)
|
||||
fail_if_missing(event, "missing event argument")
|
||||
fail_if_missing(handler, "missing handler argument")
|
||||
|
||||
event = (type(event) == "table" and event) or {event}
|
||||
|
||||
for _, event_id in pairs(event) do
|
||||
if not (type(event_id) == "number" or type(event_id) == "string") then
|
||||
error("Invalid Event Id, Must be string or int, or array of strings and/or ints", 2)
|
||||
end
|
||||
if Event._registry[event_id] then
|
||||
for i=#Event._registry[event_id], 1, -1 do
|
||||
if Event._registry[event_id][i] == handler then
|
||||
table.remove(Event._registry[event_id], i)
|
||||
end
|
||||
end
|
||||
if #Event._registry[event_id] == 0 then
|
||||
Event._registry[event_id] = nil
|
||||
script.on_event(event_id, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
return Event
|
||||
end
|
||||
|
||||
return credits, Event
|
||||
26
locale/StdLib/game.lua
Normal file
26
locale/StdLib/game.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
--- Game module
|
||||
-- @module Game
|
||||
-- @usage local Game = require('stdlib/game')
|
||||
|
||||
Game = {} --luacheck: allow defined top
|
||||
|
||||
Game.VALID_FILTER = function(v)
|
||||
return v.valid
|
||||
end
|
||||
|
||||
--- Messages all players currently connected to the game
|
||||
-- @tparam string msg message to send to players
|
||||
-- @param[opt] condition condition to be true for the player to be messaged
|
||||
-- @treturn int the number of players who received the message. Offline players are not counted as having received the message.
|
||||
function Game.print_all(msg, condition)
|
||||
local num = 0
|
||||
for _, player in pairs(game.connected_players) do
|
||||
if condition == nil or select(2, pcall(condition, player)) then
|
||||
player.print(msg)
|
||||
num = num + 1
|
||||
end
|
||||
end
|
||||
return num
|
||||
end
|
||||
|
||||
return Game
|
||||
25
locale/file-header.lua
Normal file
25
locale/file-header.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
--[[
|
||||
Explosive Gaming
|
||||
|
||||
This file can be used with permission but this and the credit below must remain in the file.
|
||||
Contact a member of management on our discord to seek permission to use our code.
|
||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||
Discord: https://discord.gg/XSsBV6b
|
||||
|
||||
The credit below may be used by another script do not remove.
|
||||
]]
|
||||
local credits = {{
|
||||
name='File Header - Stand-Alone',
|
||||
owner='Explosive Gaming',
|
||||
dev='Cooldude2606',
|
||||
description='Just A File Header To Organise Code',
|
||||
factorio_version='0.15.23',
|
||||
show=false
|
||||
}}
|
||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
credit_loop(require("ExpGaming-Addons/file-header"))
|
||||
credit_loop(require("Stand-Alone/file-header"))
|
||||
credit_loop(require("ExpGaming-Core/file-header"))
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
Reference in New Issue
Block a user