mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 04:21:41 +09:00
Added Modules to be converted
This commit is contained in:
229
to convert/Addons/Admin/admin.lua
Normal file
229
to convert/Addons/Admin/admin.lua
Normal file
@@ -0,0 +1,229 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
Admin = Admin or {}
|
||||
|
||||
local function append_name(reason,name)
|
||||
local reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then return reason..' - '..name
|
||||
else return reason end
|
||||
end
|
||||
|
||||
local function open(player,pre_select_player,pre_select_action)
|
||||
if Admin.center then Gui.center.clear(player) Admin.center.open(player,pre_select_player,pre_select_action) end
|
||||
end
|
||||
|
||||
function Admin.allowed(player)
|
||||
local player = Game.get_player(player)
|
||||
local lowest_admin_power = Ranking.get_group('Admin').lowest.power
|
||||
return lowest_admin_power >= Ranking.get_rank(player).power
|
||||
end
|
||||
|
||||
function Admin.btn_flow(frame,buttons)
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
name='admin'
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption='',
|
||||
name='player'
|
||||
}.style.visible = false
|
||||
local function format(btn)
|
||||
btn.style.height = 30
|
||||
btn.style.width = 30
|
||||
end
|
||||
if not buttons or buttons.ban then format(Admin.ban_btn:draw(frame)) end
|
||||
if not buttons or buttons.kick then format(Admin.kick_btn:draw(frame)) end
|
||||
if not buttons or buttons.jail then format(Admin.jail_btn:draw(frame)) end
|
||||
if not buttons or buttons.go_to then format(Admin.go_to_btn:draw(frame)) end
|
||||
if not buttons or buttons.bring then format(Admin.bring_btn:draw(frame)) end
|
||||
return frame.player
|
||||
end
|
||||
|
||||
function Admin.take_action(action,player,by_player,reason)
|
||||
if action == 'Ban' then Admin.ban(player,by_player,reason)
|
||||
elseif action == 'Temp Ban' and Admin.temp_ban then Admin.temp_ban(player,by_player,reason)
|
||||
elseif action == 'Kick' then Admin.kick(player,by_player,reason)
|
||||
elseif action == 'Jail' then Admin.jail(player,by_player,reason)
|
||||
elseif action == 'GoTo' then Admin.go_to(player,by_player)
|
||||
elseif action == 'Bring' then Admin.bring(player,by_player)
|
||||
end
|
||||
end
|
||||
|
||||
local inventorys = {
|
||||
defines.inventory.player_main,
|
||||
defines.inventory.player_quickbar,
|
||||
defines.inventory.player_trash,
|
||||
defines.inventory.player_guns,
|
||||
defines.inventory.player_ammo,
|
||||
defines.inventory.player_armor,
|
||||
defines.inventory.player_armor
|
||||
}
|
||||
|
||||
function Admin.move_item_to_spawn(item,surface,chests)
|
||||
local chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
|
||||
local chest = nil
|
||||
while not chest or not chest.get_inventory(defines.inventory.chest).can_insert(item) do
|
||||
chest = table.remove(chests,1)
|
||||
if not chest then chest = surface.create_entity{
|
||||
name='iron-chest',
|
||||
position=surface.find_non_colliding_position('iron-chest',{0,0},32,1)
|
||||
} end
|
||||
end
|
||||
chest.get_inventory(defines.inventory.chest).insert(item)
|
||||
table.insert(chests,chest)
|
||||
return chests
|
||||
end
|
||||
|
||||
function Admin.move_inventory(player)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return end
|
||||
local chests = player.surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {}
|
||||
for _,_inventory in pairs(inventorys) do
|
||||
local inventory = player.get_inventory(_inventory)
|
||||
if inventory then
|
||||
for item,count in pairs(inventory.get_contents()) do
|
||||
local item = {name=item,count=count}
|
||||
chests = Admin.move_item_to_spawn(item,player.surface,chests)
|
||||
end
|
||||
inventory.clear()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Admin.ban_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-ban',
|
||||
caption='utility/danger_icon',
|
||||
tooltip={'admin-commands.tooltip-ban'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
open(event.player_index,pre_select_player,'Ban')
|
||||
end)
|
||||
|
||||
function Admin.ban(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
Sync.emit_embeded{
|
||||
title='Player Ban',
|
||||
color=Color.to_hex(defines.text_color.crit),
|
||||
description='There was a player banned.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
Admin.move_inventory(player)
|
||||
Server.interface(game.ban_player,true,player,reason)
|
||||
end
|
||||
|
||||
Admin.kick_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-kick',
|
||||
caption='utility/warning_icon',
|
||||
tooltip={'admin-commands.tooltip-kick'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
open(event.player_index,pre_select_player,'Kick')
|
||||
end)
|
||||
|
||||
function Admin.kick(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
Sync.emit_embeded{
|
||||
title='Player Kick',
|
||||
color=Color.to_hex(defines.text_color.high),
|
||||
description='There was a player kicked.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
Admin.move_inventory(player)
|
||||
Server.interface(game.kick_player,true,player,reason)
|
||||
end
|
||||
|
||||
Admin.jail_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-jail',
|
||||
caption='utility/clock',
|
||||
tooltip={'admin-commands.tooltip-jail'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
open(event.player_index,pre_select_player,'Jail')
|
||||
end)
|
||||
|
||||
function Admin.jail(player,by_player,reason)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local reason = append_name(reason,by_player_name)
|
||||
Sync.emit_embeded{
|
||||
title='Player Jail',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='There was a player jailed.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
Admin.move_inventory(player)
|
||||
Ranking._presets().last_jail = player.name
|
||||
Server.interface(Ranking.give_rank,true,player,'Jail',by_player_name)
|
||||
end
|
||||
|
||||
Admin.go_to_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-go-to',
|
||||
caption='utility/export_slot',
|
||||
tooltip={'admin-commands.tooltip-go-to'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
Admin.go_to(pre_select_player,event.player_index)
|
||||
end)
|
||||
|
||||
function Admin.go_to(player,by_player)
|
||||
local player = Game.get_player(player)
|
||||
local _player = Game.get_player(by_player)
|
||||
_player.teleport(player.surface.find_non_colliding_position('player',player.position,32,1),player.surface)
|
||||
end
|
||||
|
||||
Admin.bring_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-bring',
|
||||
caption='utility/import_slot',
|
||||
tooltip={'admin-commands.tooltip-bring'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
pre_select_player = parent.player and parent.player.caption or nil
|
||||
Admin.bring(pre_select_player,event.player_index)
|
||||
end)
|
||||
|
||||
function Admin.bring(player,by_player)
|
||||
local player = Game.get_player(player)
|
||||
local _player = Game.get_player(by_player)
|
||||
if not player or not _player then return end
|
||||
player.teleport(_player.surface.find_non_colliding_position('player',_player.position,32,1),_player.surface)
|
||||
end
|
||||
|
||||
function Admin.tp(from_playaer, to_player)
|
||||
local _from_player = Game.get_player(from_player)
|
||||
local _to_player = Game.get_player(to_player)
|
||||
|
||||
if not _from_player or not _to_player then return end
|
||||
|
||||
if Game.players[_from_player].health >= 0 then return end
|
||||
if Game.players[_to_player].health >= 0 then return end
|
||||
|
||||
_from_player.teleport(_to_player.surface.find_non_colliding_position('player',_to_player.position,32,1),_to_player.surface)
|
||||
end
|
||||
39
to convert/Addons/Admin/afk-kick.lua
Normal file
39
to convert/Addons/Admin/afk-kick.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
function get_allowed_afk_time(player)
|
||||
local rank = Ranking.get_rank(player)
|
||||
local count = #game.connected_players
|
||||
local base = rank.base_afk_time or false
|
||||
if not base then return false end
|
||||
return (base/5)*count
|
||||
end
|
||||
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='afk-kick',
|
||||
}:on_event('tick',function(self)
|
||||
if (game.tick%3600) ~= 0 then return end
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local afk = #game.connected_players < 3 and 10 or get_allowed_afk_time(player)
|
||||
if afk then
|
||||
if player.afk_time > afk*3600 then game.kick_player(player,'AFK For Too Long ('..math.floor(afk)..' Minutes)') end
|
||||
end
|
||||
end
|
||||
end):on_event('error',function(self,err)
|
||||
Sync.emit_embeded{
|
||||
title='Auto Kick Error',
|
||||
color=Color.to_hex(defines.text_color.bg),
|
||||
description='Auto Kick Error - Closed Thread',
|
||||
Error=err
|
||||
}
|
||||
self:close()
|
||||
end):open()
|
||||
end)
|
||||
134
to convert/Addons/Admin/auto-chat.lua
Normal file
134
to convert/Addons/Admin/auto-chat.lua
Normal file
@@ -0,0 +1,134 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- white spaces removed and made into lower
|
||||
-- these messages are sent only to the player
|
||||
local messages = {
|
||||
['discord']={'chat-bot.discord'},
|
||||
['expgaming']={'chat-bot.website'},
|
||||
['website']={'chat-bot.website'},
|
||||
['command']={'chat-bot.custom-commands'},
|
||||
['commands']={'chat-bot.custom-commands'},
|
||||
['softmod']={'chat-bot.softmod'},
|
||||
['script']={'chat-bot.softmod'},
|
||||
['link']={'chat-bot.links'},
|
||||
['links']={'chat-bot.links'},
|
||||
['loop']={'chat-bot.loops'},
|
||||
['loops']={'chat-bot.loops'},
|
||||
--Thadius suggestion start
|
||||
['rhd']={'chat-bot.lhd'},
|
||||
--Thadius suggestion end
|
||||
['roundabout']={'chat-bot.loops'},
|
||||
['roundabouts']={'chat-bot.loops'},
|
||||
['afk']=function(_player) local max=_player for _,player in pairs(game.connected_players) do if max.afk_time < player.afk_time then max=player end end return {'chat-bot.afk',max.name,tick_to_display_format(max.afk_time)} end
|
||||
}
|
||||
-- white spaces removed and made into lower
|
||||
-- these are global chat commands that can be used
|
||||
-- comands start with ! (all messages are also commands)
|
||||
local command_syntax = '!'
|
||||
local commands = {
|
||||
['online']=function(player) return {'chat-bot.players-online',#game.connected_players} end,
|
||||
['playtime']=function(player) return {'chat-bot.map-time',tick_to_display_format(game.tick)} end,
|
||||
['players']=function(player) return {'chat-bot.players',#game.players} end,
|
||||
['dev']={'chat-bot.not-real-dev'},
|
||||
['blame']=function(player) local names = {'Cooldude2606','arty714','badgamernl',player.name} return {'chat-bot.blame',names[math.random(#names)]} end,
|
||||
['readme']={'chat-bot.read-readme'},
|
||||
['magic']={'chat-bot.magic'},
|
||||
['aids']={'chat-bot.aids'},
|
||||
['riot']={'chat-bot.riot'},
|
||||
['lenny']={'chat-bot.lenny'},
|
||||
['wiki']={'chat-bot.wiki'},
|
||||
['evolution']=function(player) return {'chat-bot.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)} end,
|
||||
--Jokes about food and drink
|
||||
['whattoeat']={'chat-bot.food'},
|
||||
['makepopcorn']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.get-popcorn-2',self.data}} end
|
||||
end):open() return {'chat-bot.get-popcorn-1'} end,
|
||||
['orderpizza']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.order-pizza-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.order-pizza-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'chat-bot.order-pizza-1'} end,
|
||||
['passsomesnaps']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.get-snaps-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.get-snaps-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'chat-bot.get-snaps-1'} end,
|
||||
['makecocktail']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.get-cocktail-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.get-cocktail-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2]+1
|
||||
end):open() return {'chat-bot.get-cocktail-1'} end,
|
||||
['makecoffee']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.make-coffee-2',self.data}} end
|
||||
end):open() return {'chat-bot.make-coffee-1'} end,
|
||||
['orderpizza']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data[2]==0 then game.print{'chat-bot.message',{'chat-bot.order-pizza-2',self.data[1]}}
|
||||
elseif self.data[2]==1 then game.print{'chat-bot.message',{'chat-bot.order-pizza-3',self.data[1]}} self.reopen = false
|
||||
end
|
||||
self.data[2]=self.data[2] + 1
|
||||
end):open() return {'chat-bot.order-pizza-1'} end,
|
||||
['maketea']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.make-tea-2',self.data}} end
|
||||
end):open() return {'chat-bot.make-tea-1'} end,
|
||||
['meadplease']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.get-mead-2',self.data}} end
|
||||
end):open() return {'chat-bot.get-mead-1'} end,
|
||||
['passabeer']=function(player) Server.new_thread{
|
||||
timeout=math.floor(180*(math.random()+0.5)),data=player.name
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data then game.print{'chat-bot.message',{'chat-bot.get-beer-2',self.data}} end
|
||||
end):open() return {'chat-bot.get-beer-1'} end
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_console_chat,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local player_message = event.message:lower():gsub("%s+", "")
|
||||
local allowed = Ranking.get_rank(player):allowed('global-chat')
|
||||
for to_find,message in pairs(messages) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'chat-bot.message',message}
|
||||
else player_return({'chat-bot.rank-error'},nil,player) end
|
||||
elseif player_message:match(to_find) then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
player_return({'chat-bot.message',message},nil,player)
|
||||
end
|
||||
end
|
||||
for to_find,message in pairs(commands) do
|
||||
if player_message:match(command_syntax..to_find) then
|
||||
if allowed then
|
||||
if is_type(message,'function') then message=message(player) end
|
||||
game.print{'chat-bot.message',message}
|
||||
else player_return({'chat-bot.rank-error'},nil,player) end
|
||||
end
|
||||
end
|
||||
end)
|
||||
61
to convert/Addons/Admin/auto-message.lua
Normal file
61
to convert/Addons/Admin/auto-message.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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='auto-message',
|
||||
timeout=54000, -- 3240000 = 15 hours dont make the mistake i did, 54000 is 15 minutes
|
||||
reopen=true,
|
||||
data={
|
||||
high_rank= 'Owner',
|
||||
low_rank= 'Regular',
|
||||
low={
|
||||
{'chat-bot.join-us'},
|
||||
{'chat-bot.discord'},
|
||||
{'chat-bot.website'},
|
||||
{'chat-bot.custom-commands'},
|
||||
{'chat-bot.read-readme'}
|
||||
}
|
||||
}
|
||||
}:on_event('timeout',function(self)
|
||||
local data = self.data
|
||||
if not data.high_rank or not data.low_rank
|
||||
or not data.low then self.reopen = false return end
|
||||
local _high = Ranking.get_rank(data.high_rank)
|
||||
game.print{'chat-bot.message',{'chat-bot.players-online',#game.connected_players}}
|
||||
game.print{'chat-bot.message',{'chat-bot.map-time',tick_to_display_format(game.tick)}}
|
||||
--[[local _low = Ranking.get_rank(data.low_rank)
|
||||
Ranking.print(_high,{'chat-bot.players-online',#game.connected_players},nil,true)
|
||||
Ranking.print(_high,{'chat-bot.map-time',tick_to_display_format(game.tick)},nil,true)
|
||||
for _,line in pairs(data.low) do
|
||||
Ranking.print(_low,line,nil,true)
|
||||
end]]
|
||||
self.reopen = true
|
||||
end):on_event(defines.events.on_player_joined_game,function(self,event)
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local data = self.data
|
||||
if not data.high_rank or not data.low_rank
|
||||
or not data.low then self.reopen = false return end
|
||||
-- idk but this stoped working for no appent reason so i added more checks for nil values
|
||||
if Ranking.get_rank(player).power <= Ranking.get_rank(data.low_rank).power then return end
|
||||
for _,message in pairs(data.low) do
|
||||
player_return({'chat-bot.message',message},nil,player)
|
||||
end
|
||||
end):on_event('error',function(self,err)
|
||||
Sync.emit_embeded{
|
||||
title='Auto Message Error',
|
||||
color=Color.to_hex(defines.text_color.bg),
|
||||
description='Auto Message Error - Closed Thread',
|
||||
Error=err
|
||||
}
|
||||
self.reopen = false
|
||||
self:close()
|
||||
end):open()
|
||||
end)
|
||||
47
to convert/Addons/Admin/base-damage.lua
Normal file
47
to convert/Addons/Admin/base-damage.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- alot of this is copied from redmew - but it has been reworked to use the ExpCore
|
||||
-- https://github.com/Valansch/RedMew/blob/develop/nuke_control.lua
|
||||
|
||||
local function _damage(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.damage = not reset and global.addons.damage or {}
|
||||
return global.addons.damage
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_entity_damaged,function(event)
|
||||
if event.force == nil or event.force ~= event.entity.force then return end
|
||||
if event.cause == nil or event.cause.name ~= 'player' then return end
|
||||
local player = Game.get_player(event.cause.player)
|
||||
if Ranking.get_rank(player):allowed('base-damage') then return end
|
||||
if not _damage()[player.index] then _damage()[player.index] = {0,0} end
|
||||
_damage()[player.index][1] = _damage()[player.index][1]+event.final_damage_amount
|
||||
if _damage()[player.index][2] < event.tick-300 then
|
||||
_damage()[player.index][2] = event.tick
|
||||
player_return({'base-damage.used'},defines.text_color.med,player)
|
||||
Admin.give_warning(player,'<server>','Damaged something inside the base. Total Delt: '.._damage()[player.index][1],4)
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_ammo_inventory_changed,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if Ranking.get_rank(player):allowed('nuke') then return end
|
||||
local found = player.remove_item({name='atomic-bomb',count=1000})
|
||||
if not _damage()[player.index] then _damage()[player.index] = {0,0} end
|
||||
if found > 0 then
|
||||
Admin.move_item_to_spawn({name='atomic-bomb',count=found},player.surface)
|
||||
player_return({'base-damage.nuke'},defines.text_color.med,player)
|
||||
if _damage()[player.index][2] < event.tick-300 then
|
||||
_damage()[player.index][2] = event.tick
|
||||
Admin.give_warning(player,'<server>','Nukes are not allowed for your rank.',4)
|
||||
end
|
||||
end
|
||||
end)
|
||||
54
to convert/Addons/Admin/discord.lua
Normal file
54
to convert/Addons/Admin/discord.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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
Event.register(defines.events.on_console_command,function(event)
|
||||
local command = event.command
|
||||
local args = {}
|
||||
if event.parameters then for word in event.parameters:gmatch('%S+') do table.insert(args,word) end end
|
||||
local data = {}
|
||||
data.title = string.gsub(command,'^%l',string.upper)
|
||||
data.by = event.player_index and game.players[event.player_index].name or '<server>'
|
||||
if data.by == '<server>' then return end
|
||||
if command == 'config' or command == 'banlist' then
|
||||
Sync.emit_embeded{
|
||||
title='Edit To '..data.title,
|
||||
color=Color.to_hex(defines.text_color.bg),
|
||||
description='A player edited the '..command..'.',
|
||||
['By:']=data.by,
|
||||
['Edit:']=table.concat(args,' ',1)
|
||||
}
|
||||
else
|
||||
if command == 'ban' then
|
||||
data.colour = Color.to_hex(defines.text_color.crit)
|
||||
data.reason = table.concat(args,' ',2)
|
||||
elseif command == 'kick' then
|
||||
data.colour = Color.to_hex(defines.text_color.high)
|
||||
data.reason = table.concat(args,' ',2)
|
||||
elseif command == 'unban' then data.colour = Color.to_hex(defines.text_color.low)
|
||||
elseif command == 'mute' then data.colour = Color.to_hex(defines.text_color.med)
|
||||
elseif command == 'unmute' then data.colour = Color.to_hex(defines.text_color.low)
|
||||
elseif command == 'promote' then data.colour = Color.to_hex(defines.text_color.info)
|
||||
elseif command == 'demote' then data.colour = Color.to_hex(defines.text_color.info)
|
||||
elseif command == 'purge' then data.colour = Color.to_hex(defines.text_color.med)
|
||||
else return end
|
||||
data.username = args[1]
|
||||
if not Game.get_player(data.username) then return end
|
||||
if string.sub(command,-1) == 'e' then data.command = command..'d' else data.command = command..'ed' end
|
||||
data.reason = data.reason and data.reason ~= '' and data.reason or 'No Reason Required'
|
||||
Sync.emit_embeded{
|
||||
title='Player '..data.title,
|
||||
color=data.colour,
|
||||
description='There was a player '..data.command..'.',
|
||||
['Player:']='<<inline>>'..data.username,
|
||||
['By:']='<<inline>>'..data.by,
|
||||
['Reason:']=data.reason
|
||||
}
|
||||
end
|
||||
end)
|
||||
79
to convert/Addons/Admin/inventory-search.lua
Normal file
79
to convert/Addons/Admin/inventory-search.lua
Normal file
@@ -0,0 +1,79 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- removed from none admin ranks, no further action
|
||||
local low_items = {
|
||||
'loader',
|
||||
'fast-loader',
|
||||
'express-loader',
|
||||
'small-plane',
|
||||
'player-port',
|
||||
'coin',
|
||||
'programmable-speaker'
|
||||
}
|
||||
|
||||
-- removed for admin and non-admin ranks, gives warnings to non-admins
|
||||
local med_items = {
|
||||
'railgun',
|
||||
'railgun-dart',
|
||||
'belt-immunity-equipment'
|
||||
}
|
||||
|
||||
-- temp-ban for any rank, this is a very hard enforcement, admin ranks lose rank
|
||||
local high_items = {
|
||||
'electric-energy-interface',
|
||||
'infinity-chest'
|
||||
}
|
||||
|
||||
local inventorys = {
|
||||
defines.inventory.player_main,
|
||||
defines.inventory.player_quickbar,
|
||||
defines.inventory.player_trash
|
||||
}
|
||||
|
||||
local _root_tree = {low_items=low_items,med_items=med_items,high_items=high_items}
|
||||
|
||||
local function take_action(player,item_name,category)
|
||||
if category == 'low_items' then player_return({'inventory-search.low',item_name},defines.text_color.med,player)
|
||||
elseif category == 'med_items' then player_return({'inventory-search.med',item_name},defines.text_color.high,player) Admin.give_warning(player,'<server>','Found A Banned Item',5)
|
||||
elseif category == 'high_items' then player_return({'inventory-search.high',item_name},defines.text_color.crit,player) Admin.temp_ban(player,'<server>','Found A Banned Item')
|
||||
else return end
|
||||
end
|
||||
|
||||
function search_player(player)
|
||||
for category,items in pairs(_root_tree) do
|
||||
if category ~= 'low_items' or not Ranking.get_rank(player):allowed('admin-items') then
|
||||
for _,_inventory in pairs(inventorys) do
|
||||
local inventory = player.get_inventory(_inventory)
|
||||
if inventory then
|
||||
for _,item in pairs(items) do
|
||||
local found = inventory.remove(item)
|
||||
if found > 0 then take_action(player,item,category) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.register({defines.events.on_player_main_inventory_changed,defines.events.on_player_quickbar_inventory_changed},function(event)
|
||||
local player = Game.get_player(event)
|
||||
if player and player.name == 'freek18' then search_player(player) end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_tick,function(event)
|
||||
if (game.tick%900) == 0 then
|
||||
local players = game.connected_players
|
||||
if #players == 0 then return end
|
||||
local player = players[math.random(#players)]
|
||||
if Ranking.get_rank(player):allowed('all-items') then return end
|
||||
search_player(player)
|
||||
end
|
||||
end)
|
||||
40
to convert/Addons/Admin/player-info.lua
Normal file
40
to convert/Addons/Admin/player-info.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
function get_player_info(player,frame,add_cam)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return {} end
|
||||
local _player = {}
|
||||
_player.index = player.index
|
||||
_player.name = player.name
|
||||
_player.online = player.connected
|
||||
_player.tag = player.tag
|
||||
_player.color = player.color
|
||||
_player.admin = player.admin
|
||||
_player.online_time = player.online_time
|
||||
_player.rank = Ranking.get_rank(player).name
|
||||
_player.group = Ranking.get_group(player).name
|
||||
if frame then
|
||||
local frame = frame.add{type='frame',direction='vertical',style='image_frame'}
|
||||
frame.style.width = 200
|
||||
frame.style.height = 275
|
||||
frame.add{type='label',caption={'player-info.name',_player.index,_player.name},style='caption_label'}
|
||||
local _online = {'player-info.no'}; if _player.online then _online = {'player-info.yes'} end
|
||||
frame.add{type='label',caption={'player-info.online',_online,tick_to_display_format(_player.online_time)}}
|
||||
local _admin = {'player-info.no'}; if _player.admin then _admin = {'player-info.yes'} end
|
||||
frame.add{type='label',caption={'player-info.admin',_admin}}
|
||||
frame.add{type='label',caption={'player-info.group',_player.group}}
|
||||
frame.add{type='label',caption={'player-info.rank',_player.rank}}
|
||||
if add_cam then
|
||||
Gui.cam_link{entity=player.character,frame=frame,width=200,height=150,zoom=0.5,respawn_open=true}
|
||||
end
|
||||
end
|
||||
return _player
|
||||
end
|
||||
276
to convert/Addons/Admin/reports.lua
Normal file
276
to convert/Addons/Admin/reports.lua
Normal file
@@ -0,0 +1,276 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local report_to_warnings = 1 -- used in count_reports
|
||||
local varified_to_warings = 3 -- used in count_reports
|
||||
local reports_needed_for_jail = 6
|
||||
local min_time_to_remove_warning = 18000 -- this is in ticks
|
||||
local take_action = 8 -- below this number no action is taken, the first admin given warning jumps to this number
|
||||
local punishments = {
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'nothing'},
|
||||
{'message',{'reports.message'},defines.text_color.info},
|
||||
{'message',{'reports.message'},defines.text_color.info},
|
||||
{'report',{'reports.reported'},defines.text_color.med},
|
||||
{'message',{'reports.kick-warn'},defines.text_color.med},
|
||||
{'kick'},
|
||||
{'message',{'reports.temp-warn'},defines.text_color.high},
|
||||
{'temp-ban'},
|
||||
{'message',{'reports.ban-warn'},defines.text_color.high},
|
||||
{'message',{'reports.last-warn'},defines.text_color.crit},
|
||||
{'ban'}
|
||||
}
|
||||
|
||||
local actions = {
|
||||
none=0,
|
||||
report=1,
|
||||
jail=2,
|
||||
kick=3,
|
||||
temp=4,
|
||||
ban=5
|
||||
}
|
||||
|
||||
local function valid_players(player,by_player)
|
||||
local player = Game.get_player(player)
|
||||
local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '<server>'
|
||||
local rank = Ranking.get_rank(by_player_name)
|
||||
return player, by_player_name, rank
|
||||
end
|
||||
|
||||
local function _reports(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.reports = not reset and global.addons.reports or {warnings={},reports={},varified={},actions={}}
|
||||
return global.addons.reports
|
||||
end
|
||||
|
||||
local function get_warnings(player)
|
||||
local player = Game.get_player(player)
|
||||
return _reports().warnings[player.name] or 0
|
||||
end
|
||||
|
||||
local function report_message(player,by_player,reason)
|
||||
local low_rank = Ranking.get_group('User').highest
|
||||
local high_rank = Ranking.get_group('Admin').lowest
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
if _reports().actions[player.name] == actions.report then return end
|
||||
Ranking.print(low_rank,{'reports.low-print',player.name,reason},defines.text_color.info,true)
|
||||
Ranking.print(high_rank,{'reports.high-print',player.name,by_player_name,reason},defines.text_color.med)
|
||||
Sync.emit_embeded{
|
||||
title='Player Report',
|
||||
color=Color.to_hex(defines.text_color.med),
|
||||
description='A player was reported.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=reason
|
||||
}
|
||||
end
|
||||
|
||||
local function count_reports(player)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return 0 end
|
||||
local _count = 0
|
||||
local data = _reports()
|
||||
if data.reports[player.name] then
|
||||
for _,report in pairs(data.reports[player.name]) do
|
||||
_count=_count+report_to_warnings
|
||||
end
|
||||
end
|
||||
if data.varified[player.name] then
|
||||
for _,report in pairs(data.varified[player.name]) do
|
||||
_count=_count+varified_to_warings
|
||||
end
|
||||
end
|
||||
return _count
|
||||
end
|
||||
|
||||
local function cheak_reports(player)
|
||||
local player = Game.get_player(player)
|
||||
if not player then return end
|
||||
local reports = count_reports(player)
|
||||
if reports >= reports_needed_for_jail and _reports().actions[player.name] ~= 'report-jail' and Ranking.get_rank(player).group.name ~= 'Jail' then
|
||||
_reports().actions[player.name] = actions.report
|
||||
Admin.jail(player,'<server>','Too many user reports. Contact an Admin to be unjailed.')
|
||||
end
|
||||
end
|
||||
|
||||
local function give_punishment(player,by_player,reason)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
local warnings = get_warnings(player)
|
||||
local punishment = punishments[warnings]
|
||||
local reason = reason or 'No Other Reason'
|
||||
if not punishment or punishment[1] == 'nothing' then return
|
||||
elseif punishment[1] == 'message' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
elseif punishment[1] == 'report' then
|
||||
local message = punishment[2]
|
||||
local colour = punishment[3]
|
||||
player_return(message,colour,player)
|
||||
report_message(player,'<server>',reason)
|
||||
elseif punishment[1] == 'kick' then
|
||||
_reports().actions[player.name] = actions.kick
|
||||
Admin.kick(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
elseif punishment[1] == 'temp-ban' then
|
||||
--_reports().actions[player.name] = actions.temp -- see Admin.temp-ban
|
||||
Admin.temp_ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
elseif punishment[1] == 'ban' then
|
||||
_reports().actions[player.name] = actions.ban
|
||||
Admin.ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason)
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.give_warning(player,by_player,reason,min)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
local min = Game.get_player(by_player) and take_action or min or 0
|
||||
local warnings = get_warnings(player)
|
||||
if warnings < min then warnings = min end
|
||||
warnings = warnings+1
|
||||
_reports().warnings[player.name] = warnings
|
||||
if warnings > take_action then
|
||||
player_return({'reports.warning-given-by',by_player_name},defines.text_color.info,player)
|
||||
game.print({'reports.player-warning',player.name,by_player_name,reason})
|
||||
end
|
||||
give_punishment(player,by_player,reason)
|
||||
end
|
||||
|
||||
function Admin.report(player,by_player,reason)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player or Ranking.get_rank(player):allowed('no-report') then return end
|
||||
if Admin.is_banned(by_player) or Ranking.get_group(by_player).name == 'Jail' then return end
|
||||
if Ranking.get_rank(by_player):allowed('varified') then
|
||||
_reports().varified[player.name] = _reports().varified[player.name] or {}
|
||||
local reports = _reports().varified[player.name]
|
||||
for _,value in pairs(reports) do
|
||||
if value[1] == by_player_name then return end
|
||||
end
|
||||
table.insert(reports,{by_player_name,reason})
|
||||
else
|
||||
_reports().reports[player.name] = _reports().reports[player.name] or {}
|
||||
local reports = _reports().reports[player.name]
|
||||
for _,value in pairs(reports) do
|
||||
if value[1] == by_player_name then return end
|
||||
end
|
||||
table.insert(reports,{by_player_name,reason})
|
||||
end
|
||||
report_message(player,by_player,reason)
|
||||
cheak_reports(player)
|
||||
end
|
||||
|
||||
function Admin.clear_warings(player,by_player,no_emit)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
_reports().warnings[player.name]=0
|
||||
if not no_emit then
|
||||
Sync.emit_embeded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had their warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.clear_reports(player,by_player,no_emit)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
_reports().reports[player.name]={}
|
||||
_reports().varified[player.name]={}
|
||||
if not no_emit then
|
||||
Sync.emit_embeded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had their reports cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function Admin.clear_player(player,by_player)
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player then return end
|
||||
Admin.clear_warings(player,by_player,true)
|
||||
Admin.clear_reports(player,by_player,true)
|
||||
_reports().actions[player.name]=actions.none
|
||||
if Ranking.get_rank(player).group.name == 'Jail' then Server.interface(Ranking.revert,true,player,by_player) end
|
||||
Sync.emit_embeded{
|
||||
title='Player Clear',
|
||||
color=Color.to_hex(defines.text_color.low),
|
||||
description='A player had their reports and warnings cleared.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
}
|
||||
end
|
||||
|
||||
function Admin.temp_ban(player,by_player,reason)
|
||||
local function append_name(reason,name)
|
||||
local reason = reason or 'No Reason'
|
||||
if not string.find(string.lower(reason),string.lower(name)) then return reason..' - '..name
|
||||
else return reason end
|
||||
end
|
||||
local player, by_player_name = valid_players(player,by_player)
|
||||
if not player or Admin.is_banned(player) then return end
|
||||
_reports().actions[player.name] = actions.temp
|
||||
Sync.emit_embeded{
|
||||
title='Player Temp-Ban',
|
||||
color=Color.to_hex(defines.text_color.high),
|
||||
description='A player was jailed.',
|
||||
['Player:']='<<inline>>'..player.name,
|
||||
['By:']='<<inline>>'..by_player_name,
|
||||
['Reason:']=append_name(reason,by_player_name)
|
||||
}
|
||||
game.print({'reports.temp-ban',player.name,by_player_name,reason},defines.text_color.info)
|
||||
Admin.move_inventory(player)
|
||||
Ranking._presets().last_jail = player.name
|
||||
Server.interface(Ranking.give_rank,true,player,'Jail',by_player_name)
|
||||
end
|
||||
|
||||
function Admin.is_banned(player)
|
||||
local player=Game.get_player(player)
|
||||
if not player then return false end
|
||||
local action = _reports().actions[player.name]
|
||||
if action == actions.temp then return 'temp'
|
||||
elseif action == actions.ban then return true
|
||||
else return false end
|
||||
end
|
||||
|
||||
Event.register(defines.events.on_tick,function(event)
|
||||
if not _reports().remove_warnings_time then
|
||||
_reports().remove_warnings_time = {}
|
||||
local highest = nil
|
||||
for power,rank in pairs(Ranking._ranks()) do
|
||||
if not highest and not rank:allowed('no-report') then highest = power-1 end
|
||||
local _power = power; if highest then _power = power-highest end
|
||||
if rank:allowed('no-report') then _reports().remove_warnings_time[power] = 0
|
||||
else _reports().remove_warnings_time[power] = min_time_to_remove_warning*_power end
|
||||
end
|
||||
end
|
||||
if (game.tick % min_time_to_remove_warning) == 0 then
|
||||
for name,warnings in pairs(_reports().warnings) do
|
||||
if warnings > 0 then
|
||||
local rank = Ranking.get_rank(name)
|
||||
local time_to_remove = _reports().remove_warnings_time[rank.power]
|
||||
if (game.tick % time_to_remove) == 0 then
|
||||
_reports().warnings[name]=warnings-1
|
||||
if _reports().warnings[name] > 5 then
|
||||
player_return({'reports.remove-warn',_reports().warnings[name],tick_to_display_format(time_to_remove)},defines.text_color.low,name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
54
to convert/Addons/Admin/tree-decon.lua
Normal file
54
to convert/Addons/Admin/tree-decon.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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
Event.register(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='tree-decon',
|
||||
data={trees={},chache={},clear=0}
|
||||
}:on_event('tick',function(self)
|
||||
local trees = self.data.trees
|
||||
if self.data.clear ~= 0 and self.data.clear < game.tick then self.data.chache = {} self.data.clear = 0 end
|
||||
if #trees == 0 then return end
|
||||
for i = 0,math.ceil(#trees/10) do
|
||||
local tree = table.remove(trees,1)
|
||||
if tree and tree.valid then tree.destroy() end
|
||||
end
|
||||
end):on_event(defines.events.on_marked_for_deconstruction,function(self,event)
|
||||
local chache = self.data.chache[event.player_index]
|
||||
if not chache then
|
||||
local player = Game.get_player(event)
|
||||
if not player then return end
|
||||
local rank = Ranking.get_rank(player)
|
||||
if rank:allowed('tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false}
|
||||
elseif not rank:allowed('decon') then self.data.chache[event.player_index] = {'no-decon',false}
|
||||
else self.data.chache[event.player_index] = {'decon',false} end
|
||||
chache = self.data.chache[event.player_index]
|
||||
end
|
||||
if not event.entity.last_user or event.entity.name == 'entity-ghost' then
|
||||
if chache[1] == 'tree-decon' then
|
||||
table.insert(self.data.trees,event.entity)
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
else
|
||||
if chache[1] == 'no-decon' then
|
||||
event.entity.cancel_deconstruction('player')
|
||||
if not chache[2] then
|
||||
chache[2] = true
|
||||
local player = Game.get_player(event)
|
||||
player_return({'tree-decon.player-print'},defines.text_color.crit,player)
|
||||
local rank = Ranking.get_group('Admin').lowest
|
||||
Ranking.print(rank,{'tree-decon.rank-print',player.name},defines.text_color.info)
|
||||
Admin.give_warning(player,'<server>','Trying To Decon The Base')
|
||||
end
|
||||
self.data.clear = game.tick + 10
|
||||
end
|
||||
end
|
||||
end):open()
|
||||
end)
|
||||
81
to convert/Addons/Commands/admin.lua
Normal file
81
to convert/Addons/Commands/admin.lua
Normal file
@@ -0,0 +1,81 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
commands.add_command('report', 'Reports a player', {'player','reason',true}, function(event,args)
|
||||
local _player = Game.get_player(event)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'reports.cant-report-ban',args.player}) return commands.error end
|
||||
if Ranking.get_rank(player):allowed('no-report') then player_return({'reports.cant-report',args.player}) return commands.error end
|
||||
for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'reports.cant-report',args.player}) return commands.error end end
|
||||
for _,report in pairs(global.addons.reports.varified) do if report[1] == _player.name then player_return({'reports.cant-report',args.player}) return commands.error end end
|
||||
Admin.report(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
commands.add_command('warn', 'Gives a player a warning', {'player','reason',true}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'reports.cant-report-ban',args.player}) return commands.error end
|
||||
if Ranking.get_rank(player):allowed('no-report') then player_return({'reports.cant-report',args.player}) return commands.error end
|
||||
Admin.give_warning(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
commands.add_command('jail', 'Jails a player', {'player','reason',true}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Ranking.get_rank(player):allowed('no-report') then player_return({'reports.cant-report',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'commands.cant-report-ban',args.player}) return commands.error end
|
||||
Admin.jail(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
commands.add_command('unjail', 'Returns a player\'s old rank', {'player',true}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'commands.cant-report-ban',args.player}) return commands.error end
|
||||
Server.interface(Ranking.revert,true,player,event.player_index)
|
||||
end)
|
||||
|
||||
commands.add_command('temp-ban', 'Temporarily ban a player', {'player','reason',true}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
local reason = args.reason
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'reports.cant-report-ban',args.player}) return commands.error end
|
||||
Admin.temp_ban(player,event.player_index,reason)
|
||||
end)
|
||||
|
||||
commands.add_command('clear-inv', 'Clears a player\'s invetory', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'reports.cant-report-ban',args.player}) return commands.error end
|
||||
Admin.move_inventory(player)
|
||||
end)
|
||||
|
||||
commands.add_command('clear-warnings', 'Clears a player\'s warnings', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'reports.cant-report-ban',args.player}) return commands.error end
|
||||
Admin.clear_warings(player,event.player_index)
|
||||
end)
|
||||
|
||||
commands.add_command('clear-reports', 'Clears a player\'s reports', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if Admin.is_banned(player) then player_return({'reports.cant-report-ban',args.player}) return commands.error end
|
||||
Admin.clear_reports(player,event.player_index)
|
||||
end)
|
||||
|
||||
commands.add_command('clear-all', 'Clears a player of any temp-ban, reports or warnings', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
Admin.clear_player(player,event.player_index)
|
||||
end)
|
||||
66
to convert/Addons/Commands/bonus.lua
Normal file
66
to convert/Addons/Commands/bonus.lua
Normal file
@@ -0,0 +1,66 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local settings = {
|
||||
{key='character_mining_speed_modifier',scale=3},
|
||||
{key='character_crafting_speed_modifier',scale=3},
|
||||
{key='character_running_speed_modifier',scale=3},
|
||||
{key='character_build_distance_bonus',scale=20},
|
||||
{key='character_reach_distance_bonus',scale=20},
|
||||
{key='character_inventory_slots_bonus',scale=200}
|
||||
}
|
||||
|
||||
local function _bonus(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.bonus = not reset and global.addons.bonus or {}
|
||||
return global.addons.bonus
|
||||
end
|
||||
|
||||
commands.add_command('bonus', 'Set your player bonus (default is 20, guest has 0)', {'bonus'}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
local bonus = tonumber(args.bonus)
|
||||
if not bonus or bonus < 0 or bonus > 50 then player_return{'commands.invalid-range',0,50} return commands.error end
|
||||
for _,setting in pairs(settings) do player[setting.key] = setting.scale*math.floor(bonus)*0.01 end
|
||||
_bonus()[player.index]=bonus
|
||||
player_return('Bonus set to: '..math.floor(bonus)..'%')
|
||||
end)
|
||||
|
||||
Event.register(defines.events.rank_change,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if event.new_rank:allowed('bonus') then
|
||||
for _,setting in pairs(settings) do player[setting.key] = setting.scale*0.2 end
|
||||
_bonus()[player.index]=20
|
||||
else
|
||||
for _,setting in pairs(settings) do player[setting.key] = 0 end
|
||||
_bonus()[player.index]=nil
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_respawned,function(event)
|
||||
local player = Game.get_player(event)
|
||||
local bonus = _bonus()[player.index]
|
||||
if bonus then
|
||||
for _,setting in pairs(settings) do player[setting.key] = setting.scale*math.floor(bonus)*0.01 end
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_pre_player_died,function(event)
|
||||
local player = Game.get_player(event)
|
||||
if Ranking.get_rank(player):allowed('bonus-respawn') then
|
||||
player.ticks_to_respawn = 120
|
||||
-- manually dispatch death event because it is not fired when ticks_to_respawn is set pre death
|
||||
Event.dispatch{
|
||||
name=defines.events.on_player_died,
|
||||
tick=event.tick,
|
||||
player_index=event.player_index,
|
||||
cause = event.cause
|
||||
}
|
||||
end
|
||||
end)
|
||||
15
to convert/Addons/Commands/cheat-mode.lua
Normal file
15
to convert/Addons/Commands/cheat-mode.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
commands.add_command('cheat-mode', 'Toggles cheat mode for a player', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if player.cheat_mode == true then player.cheat_mode = false else player.cheat_mode = true end
|
||||
end)
|
||||
37
to convert/Addons/Commands/home.lua
Normal file
37
to convert/Addons/Commands/home.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local function _homes(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.homes = not reset and global.addons.homes or {}
|
||||
return global.addons.homes
|
||||
end
|
||||
|
||||
commands.add_command('set-home', 'Set your home position', {}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
if not _homes()[player.index] then _homes()[player.index] = {player.force.get_spawn_position(player.surface),player.force.get_spawn_position(player.surface)} end
|
||||
_homes()[player.index][1] = {math.floor(player.position.x),math.floor(player.position.y)}
|
||||
player_return('Home set at: ('..math.floor(player.position.x)..','..math.floor(player.position.y)..')')
|
||||
end)
|
||||
|
||||
commands.add_command('home', 'Go to you home position', {}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
if not _homes()[player.index] then _homes()[player.index] = {player.force.get_spawn_position(player.surface),player.force.get_spawn_position(player.surface)} end
|
||||
_homes()[player.index][2] = {math.floor(player.position.x),math.floor(player.position.y)}
|
||||
player.teleport(player.surface.find_non_colliding_position('player',_homes()[player.index][1],32,1),player.surface)
|
||||
end)
|
||||
|
||||
commands.add_command('return', 'Return to your previous position after using /home', {}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
if not _homes()[player.index] then _homes()[player.index] = {player.force.get_spawn_position(player.surface),player.force.get_spawn_position(player.surface)} end
|
||||
local _temp = {math.floor(player.position.x),math.floor(player.position.y)}
|
||||
player.teleport(player.surface.find_non_colliding_position('player',_homes()[player.index][2],32,1),player.surface)
|
||||
_homes()[player.index][2] = _temp
|
||||
end)
|
||||
21
to convert/Addons/Commands/kill.lua
Normal file
21
to convert/Addons/Commands/kill.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
commands.add_command('kill', 'Kills a player. Must be either yourself (/kill self) or a person of a lower rank', {'player'}, function(event,args)
|
||||
local _player = Game.get_player(event)
|
||||
local player = Game.get_player(args.player)
|
||||
if args.player ~= 'self' and not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if args.player == 'self' or _player.name == player.name then
|
||||
if _player.character then _player.character.die() else player_return({'commands.dead-player'}) return commands.error end
|
||||
elseif Ranking.get_rank(player).power > Ranking.get_rank(_player).power then
|
||||
if player.connected then else player_return({'commands.offline-player'}) return commands.error end
|
||||
if player.character then player.character.die() else player_return({'commands.dead-player'}) return commands.error end
|
||||
else player_return({'commands.unauthorized'}) return commands.error end
|
||||
end)
|
||||
47
to convert/Addons/Commands/repair.lua
Normal file
47
to convert/Addons/Commands/repair.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
-- Set an item to true to disallow it from being repaired
|
||||
local disallow = {
|
||||
['loader']=true,
|
||||
['fast-loader']=true,
|
||||
['express-loader']=true,
|
||||
['electric-energy-interface']=true,
|
||||
['infinity-chest']=true
|
||||
}
|
||||
|
||||
local const = 100
|
||||
-- Given const = 100: admin+ has unlimited, admin has const (100), mod has const / 2 (50), member has const / 5 (20)
|
||||
|
||||
commands.add_command('repair', 'Repairs all destoryed and damaged entites in an area.', {'range'}, function(event,args)
|
||||
local range = tonumber(args.range)
|
||||
local player = Game.get_player(event)
|
||||
local rank = Ranking.get_rank(player)
|
||||
local highest_admin_power = Ranking.get_group('Admin').highest.power-1
|
||||
local max_range = rank.power-highest_admin_power > 0 and const/(rank.power-highest_admin_power) or nil
|
||||
local center = player and player.position or {x=0,y=0}
|
||||
if not range or max_range and range > max_range then player_return({'commands.invalid-range',0,math.floor(max_range)}) return commands.error end
|
||||
local area = {{center.x-range,center.y-range},{center.x+range,center.y+range}}
|
||||
local max_time_to_live = 2^32 - 1
|
||||
local sq_range = range^2
|
||||
for key, entity in pairs(player.surface.find_entities_filtered({area=area,type='entity-ghost'})) do
|
||||
if entity.force == player.force and (entity.position.x-center.x)^2+(entity.position.y-center.y)^2 < sq_range then
|
||||
if disallow[entity.ghost_prototype.name] then
|
||||
player_return('You have repaired: '..entity.name..' this item is not allowed.',defines.text_color.crit,player)
|
||||
Admin.temp_ban(player,'<server>','Attempt To Repair A Banned Item')
|
||||
entity.destroy()
|
||||
elseif entity.time_to_live ~= max_time_to_live then
|
||||
entity.revive() end
|
||||
end
|
||||
end
|
||||
for key, entity in pairs(player.surface.find_entities(area)) do
|
||||
if entity.force == player.force and (entity.position.x-center.x)^2+(entity.position.y-center.y)^2 < sq_range and entity.health then entity.health = 10000 end
|
||||
end
|
||||
end)
|
||||
30
to convert/Addons/Commands/tags.lua
Normal file
30
to convert/Addons/Commands/tags.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local const = 20
|
||||
-- this is the max lenth of a tag
|
||||
|
||||
commands.add_command('tag', 'Give yourself a custom tag. Use /tag-clear self to remove tag', {'tag',true}, function(event,args)
|
||||
local player = Game.get_player(event)
|
||||
local rank = Ranking.get_rank(player)
|
||||
if string.len(args.tag) > const then player_return({'commands.invalid-length',const}) return commands.error end
|
||||
player.tag = rank.tag..' - '..args.tag
|
||||
end)
|
||||
|
||||
commands.add_command('tag-clear', 'Removes a custom tag. Player can be self (/tag-clear self)', {'player'}, function(event,args)
|
||||
local _player = Game.get_player(event)
|
||||
local _rank = Ranking.get_rank(_player)
|
||||
local player = Game.get_player(args.player)
|
||||
local rank = Ranking.get_rank(player)
|
||||
if args.player ~= 'self' and not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
if args.player == 'self' or _player.name == player.name then _player.tag = _rank.tag
|
||||
elseif _rank.power < rank.power then player.tag = rank.tag
|
||||
else player_return({'commands.unauthorized'}) return commands.error end
|
||||
end)
|
||||
31
to convert/Addons/Commands/tp.lua
Normal file
31
to convert/Addons/Commands/tp.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
commands.add_command('go-to', 'Go to a player\'s location', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
Admin.go_to(player,event)
|
||||
end)
|
||||
|
||||
commands.add_command('bring', 'Bring a player to your location', {'player'}, function(event,args)
|
||||
local player = Game.get_player(args.player)
|
||||
if not player then player_return({'commands.invalid-player',args.player}) return commands.error end
|
||||
Admin.bring(player,event)
|
||||
end)
|
||||
|
||||
commands.add_command('tp', 'Teleport a player to another player\'s location', {'from', 'to'}, function(event,args)
|
||||
local from_player = Game.get_player(args.from)
|
||||
if not from_player then player_return({'commands.invalid-player',args.from_player}) return commands.error end
|
||||
|
||||
local to_player = Game.get_player(args.to)
|
||||
if not to_player then player_return({'commands.invalid-player',args.to_player}) return commands.error end
|
||||
|
||||
Admin.tp(from_player, to_player)
|
||||
end)
|
||||
177
to convert/Addons/Guis/admin-gui.lua
Normal file
177
to convert/Addons/Guis/admin-gui.lua
Normal file
@@ -0,0 +1,177 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
Admin = Admin or {}
|
||||
|
||||
local get_player_info = get_player_info or function(player,frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'admin-commands.no-info-file'}
|
||||
}
|
||||
end
|
||||
|
||||
local function _players(_player,root_frame,state)
|
||||
local players = {'Select Player'}
|
||||
local _players = state and game.players or game.connected_players
|
||||
for _,player in pairs(_players) do
|
||||
if player.name ~= _player.name then
|
||||
if Admin.is_banned and Admin.is_banned(player) then else
|
||||
table.insert(players,player.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
end
|
||||
|
||||
local online_check = Gui.inputs.add_checkbox('online-check-admin-commands',false,'Show Offline',false,function(player,element)
|
||||
element.parent['player-drop-down-admin-commands'].items = _players(player,element.parent,true)
|
||||
element.parent['player-drop-down-admin-commands'].selected_index = 1
|
||||
end,function(player,element)
|
||||
element.parent['player-drop-down-admin-commands'].items = _players(player,element.parent,false)
|
||||
element.parent['player-drop-down-admin-commands'].selected_index = 1
|
||||
end)
|
||||
|
||||
local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',_players,1,function(player,selected,items,element)
|
||||
element.parent.parent.player.caption = selected
|
||||
local player_info_flow = element.parent.parent.info_flow
|
||||
player_info_flow.clear()
|
||||
if selected == 'Select Player' then return
|
||||
else get_player_info(selected,player_info_flow,true) end
|
||||
local rank = Ranking.get_rank(player)
|
||||
local _rank = Ranking.get_rank(selected)
|
||||
if rank.power >= _rank.power then element.parent.warning.caption = {'admin-commands.warning'}
|
||||
else element.parent.warning.caption = '' end
|
||||
end)
|
||||
|
||||
local reason_input = Gui.inputs.add_text('reason-input-admin-commands',false,'Enter Reason',function(player,text,element)
|
||||
if string.len(text) < 20 or text == 'Enter Reason' then
|
||||
element.parent.warning.caption = {'admin-commands.short-reason'}
|
||||
else
|
||||
element.parent.warning.caption = ''
|
||||
end
|
||||
end)
|
||||
|
||||
local function _actions(player)
|
||||
return {
|
||||
'Select Action',
|
||||
'GoTo',
|
||||
'Bring',
|
||||
'Jail',
|
||||
'Kick',
|
||||
'Temp Ban',
|
||||
'Ban'
|
||||
}
|
||||
end
|
||||
|
||||
local action_drop_down = Gui.inputs.add_drop_down('action-drop-down-rank-change',_actions,1,function(player,selected,items,element)
|
||||
element.parent.parent.action.caption = selected
|
||||
if selected == 'Jail' or selected == 'Kick' or selected == 'Ban' or selected == 'Temp Ban' then
|
||||
element.parent['reason-input-admin-commands'].style.visible = true
|
||||
else
|
||||
element.parent['reason-input-admin-commands'].style.visible = false
|
||||
end
|
||||
end)
|
||||
|
||||
local take_action = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-commands-take',
|
||||
caption={'admin-commands.take-action'}
|
||||
}:on_event('click',function(event)
|
||||
local dropdowns = event.element.parent
|
||||
local rank = Ranking.get_rank(event.player_index)
|
||||
local _action= dropdowns.parent.action.caption ~= 'Select Action' and dropdowns.parent.action.caption or nil
|
||||
local _player = Game.get_player(dropdowns.parent.player.caption)
|
||||
if not _player or not _action then dropdowns.warning.caption = {'admin-commands.invalid'} return end
|
||||
local _rank = Ranking.get_rank(_player)
|
||||
if rank.power >= _rank.power then dropdowns.warning.caption = {'admin-commands.rank-high'} return end
|
||||
local _reason = dropdowns['reason-input-admin-commands'] and dropdowns['reason-input-admin-commands'].text
|
||||
if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 20) then return end
|
||||
Admin.take_action(_action,_player,event.player_index,_reason)
|
||||
Gui.center.clear(event)
|
||||
end)
|
||||
|
||||
Admin.center = Gui.center.add{
|
||||
name='admin-commands',
|
||||
caption='utility/danger_icon',
|
||||
tooltip={'admin-commands.tooltip'},
|
||||
open=function(event,pre_select_player,pre_select_action)
|
||||
local _player = Game.get_player(pre_select_player)
|
||||
local player = Game.get_player(event)
|
||||
local _center = Gui._get_data('center')['admin-commands']
|
||||
local center_flow = Gui.center.get_flow(player)
|
||||
if center_flow[_center.name] then Gui.center.clear(player) return end
|
||||
local center_frame = center_flow.add{
|
||||
name=_center.name,
|
||||
type='frame',
|
||||
direction='vertical',
|
||||
style=mod_gui.frame_style
|
||||
}
|
||||
-- only edit i made was passing diffrent arguments to the draw function
|
||||
local success, err = pcall(_center.draw,center_frame,_player,pre_select_action)
|
||||
if not success then error(err) end
|
||||
player.opened=center_frame
|
||||
end,
|
||||
draw=function(frame,pre_select_player,pre_select_action)
|
||||
frame.caption={'admin-commands.name'}
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
local dropdowns = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
local player_info_flow = frame.add{
|
||||
name='info_flow',
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
player_info_flow.style.height = 280
|
||||
player_info_flow.style.width = 200
|
||||
local label = dropdowns.add{
|
||||
type='label',
|
||||
caption={'admin-commands.message'}
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
online_check:draw(dropdowns)
|
||||
local _drop = player_drop_down:draw(dropdowns)
|
||||
if pre_select_player then Gui.set_dropdown_index(_drop,pre_select_player.name) end
|
||||
local _drop = action_drop_down:draw(dropdowns)
|
||||
Gui.set_dropdown_index(_drop,pre_select_action)
|
||||
local _text = reason_input:draw(dropdowns)
|
||||
if pre_select_action == 'Jail' or pre_select_action == 'Kick' or pre_select_action == 'Ban' then
|
||||
_text.style.visible = true else _text.style.visible = false
|
||||
end
|
||||
if pre_select_player then get_player_info(pre_select_player,player_info_flow,true) end
|
||||
_text.style.width = 200
|
||||
local label = dropdowns.add{
|
||||
name='warning',
|
||||
type='label',
|
||||
caption='',
|
||||
style='bold_red_label'
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
take_action:draw(dropdowns)
|
||||
local _caption = pre_select_player and pre_select_player.name or ''
|
||||
frame.add{
|
||||
name='player',
|
||||
type='label',
|
||||
caption=_caption
|
||||
}.style.visible = false
|
||||
local _caption = pre_select_action or ''
|
||||
frame.add{
|
||||
name='action',
|
||||
type='label',
|
||||
caption=_caption
|
||||
}.style.visible = false
|
||||
end
|
||||
}
|
||||
99
to convert/Addons/Guis/announcements.lua
Normal file
99
to convert/Addons/Guis/announcements.lua
Normal file
@@ -0,0 +1,99 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local function _ranks(player)
|
||||
local ranks = {'Select Rank'}
|
||||
local _rank = Ranking.get_rank(player)
|
||||
for _,rank in pairs(Ranking._ranks()) do
|
||||
if rank.power >= _rank.power then
|
||||
table.insert(ranks,rank.name)
|
||||
end
|
||||
end
|
||||
return ranks
|
||||
end
|
||||
|
||||
local rank_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_ranks,1,function(player,selected,items,element)
|
||||
element.parent.rank.caption = selected
|
||||
if selected == 'Select Rank' then element.parent['send-annoncement'].style.visible = false
|
||||
else element.parent['send-annoncement'].style.visible = true end
|
||||
end)
|
||||
|
||||
local send_popup = Gui.inputs.add{
|
||||
type='button',
|
||||
name='send-annoncement',
|
||||
caption='utility/export_slot'
|
||||
}:on_event('click',function(event)
|
||||
local meta_data = Ranking._presets().meta
|
||||
local default = Ranking.get_rank(meta_data.default)
|
||||
local player = Game.get_player(event)
|
||||
local rank = Ranking.get_rank(player)
|
||||
local _rank = Ranking.get_rank(event.element.parent.rank.caption); if not _rank then return end
|
||||
local sent_by = {'announcements.sent-by',player.name,rank.name}
|
||||
local rank_name = _rank.name..'s'; if rank_name == default.name..'s' then rank_name = 'Everyone' end
|
||||
local sent_to = {'announcements.sent-to',rank_name}
|
||||
local message = event.element.parent.parent.message.text
|
||||
for power,__rank in pairs(Ranking._ranks()) do
|
||||
if power <= _rank.power then
|
||||
Gui.popup.open('announcements',{sent_by=sent_by,sent_to=sent_to,message=message},__rank:get_players(true))
|
||||
event.element.parent.parent.message.text = ''
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Gui.popup.add{
|
||||
name='announcements',
|
||||
caption={'announcements.name'},
|
||||
draw=function(frame,data)
|
||||
frame.style.right_padding = 5
|
||||
frame.style.bottom_padding = 5
|
||||
frame.add{type='label',caption=data.sent_by,style='caption_label'}
|
||||
frame.add{type='label',caption=data.sent_to,style='caption_label'}
|
||||
local text_box = frame.add{type='text-box'}
|
||||
text_box.text = data.message
|
||||
text_box.style.width = 400
|
||||
text_box.read_only = true
|
||||
text_box.word_wrap = true
|
||||
text_box.selectable = true
|
||||
end
|
||||
}:add_left{
|
||||
caption='item/programmable-speaker',
|
||||
tooltip={'announcements.tooltip'},
|
||||
draw=function(frame)
|
||||
frame.caption = {'announcements.name'}
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
local text_box = frame.add{
|
||||
type='text-box',
|
||||
name='message'
|
||||
}
|
||||
text_box.style.width = 400
|
||||
text_box.style.minimal_height = 100
|
||||
text_box.read_only = false
|
||||
text_box.word_wrap = true
|
||||
text_box.selectable = true
|
||||
local flow = frame.add{type='flow'}
|
||||
flow.add{
|
||||
type='label',
|
||||
caption={'announcements.select-rank'}
|
||||
}
|
||||
rank_drop_down:draw(flow)
|
||||
local btn = send_popup:draw(flow)
|
||||
btn.style.visible = false
|
||||
btn.style.height = 25
|
||||
btn.style.width = 25
|
||||
flow.add{
|
||||
type='label',
|
||||
name='rank',
|
||||
caption=''
|
||||
}.style.visible = false
|
||||
end
|
||||
}
|
||||
182
to convert/Addons/Guis/game-settings.lua
Normal file
182
to convert/Addons/Guis/game-settings.lua
Normal file
@@ -0,0 +1,182 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
--{type='slider',object='',key='',name='',min=x,max=y}
|
||||
--{type='function',object='',key='',name='',param={}}
|
||||
local basic_settings = {
|
||||
{type='slider',object='force',key='manual_mining_speed_modifier',name='mining-speed',min=0,max=10},
|
||||
{type='slider',object='force',key='manual_crafting_speed_modifier',name='craft-speed',min=0,max=10},
|
||||
{type='slider',object='force',key='character_running_speed_modifier',name='running-speed',min=0,max=10},
|
||||
{type='slider',object='force',key='character_build_distance_bonus',name='build-distance',min=0,max=50},
|
||||
{type='slider',object='force',key='character_reach_distance_bonus',name='reach-distance',min=0,max=50},
|
||||
{type='slider',object='force',key='worker_robots_speed_modifier',name='bot-speed',min=0,max=10},
|
||||
{type='slider',object='force',key='laboratory_speed_modifier',name='lab-speed',min=0,max=10},
|
||||
{type='slider',object='force',key='stack_inserter_capacity_bonus',name='stack-bonus',min=1,max=30}
|
||||
}
|
||||
|
||||
local advanced_settings = {
|
||||
{type='slider',object='force',key='quickbar_count',name='quickbar-count',min=1,max=5},
|
||||
{type='slider',object='force',key='character_inventory_slots_bonus',name='inventory-size',min=0,max=1000},
|
||||
{type='slider',object='force',key='mining_drill_productivity_bonus',name='mining-prod',min=0,max=10},
|
||||
{type='slider',object='game',key='speed',name='game-speed',min=0.01,max=5},
|
||||
{type='function',object='game',key='server_save',name='save'},
|
||||
{type='function',object='force',key='reset_technology_effects',name='reload-effects'},
|
||||
{type='function',object='enemy',key='kill_all_units',name='kill-biters'},
|
||||
{type='function',object='force',key='rechart',name='reload-map'},
|
||||
{type='function',object='game',key='force_crc',name='crc'},
|
||||
{type='function',object='force',key='reset',name='reset-force'}
|
||||
}
|
||||
|
||||
local personal_settings = {
|
||||
{type='slider',object='player',key='character_mining_speed_modifier',name='mining-speed',min=0,max=10},
|
||||
{type='slider',object='player',key='character_crafting_speed_modifier',name='craft-speed',min=0,max=10},
|
||||
{type='slider',object='player',key='character_running_speed_modifier',name='running-speed',min=0,max=10},
|
||||
{type='slider',object='player',key='character_build_distance_bonus',name='build-distance',min=0,max=50},
|
||||
{type='slider',object='player',key='character_reach_distance_bonus',name='reach-distance',min=0,max=50},
|
||||
{type='slider',object='player',key='character_inventory_slots_bonus',name='inventory-size',min=0,max=1000},
|
||||
{type='slider',object='player',key='quickbar_count_bonus',name='quickbar-count',min=0,max=5}
|
||||
}
|
||||
|
||||
local _root_list = {basic_settings=basic_settings,advanced_settings=advanced_settings,personal_settings=personal_settings}
|
||||
|
||||
local function _get_data(root_frame)
|
||||
local object = root_frame.name
|
||||
local key = root_frame.setting_name.caption
|
||||
for _,setting in pairs(_root_list[object]) do
|
||||
if key == setting.key then return setting end
|
||||
end
|
||||
end
|
||||
|
||||
local function _object_list(player) return {game=game,player=player,force=player.force,enemy=game.forces['enemy']} end
|
||||
|
||||
for name,group in pairs(_root_list) do
|
||||
for key,setting in pairs(group) do
|
||||
local _added = nil
|
||||
if setting.type == 'slider' then
|
||||
_added = Gui.inputs.add_slider('game-settings-'..setting.name,'horizontal',setting.min,setting.max,
|
||||
function(player,root_frame)
|
||||
local data = _get_data(root_frame)
|
||||
local objects = _object_list(player)
|
||||
local object = objects[data.object]
|
||||
return object[data.key] or 1
|
||||
end,
|
||||
function(player,value,percent,element)
|
||||
local data = _get_data(element.parent)
|
||||
local objects = _object_list(player)
|
||||
local object = objects[data.object]
|
||||
local _caption = string.format('%.2f',value); if value > 2 then _caption = string.format('%.2f',math.floor(value)) end
|
||||
object[data.key] = tonumber(_caption)
|
||||
element.parent.counter.caption = _caption
|
||||
end
|
||||
)
|
||||
elseif setting.type == 'function' then
|
||||
_added = Gui.inputs.add_checkbox('game-settings-'..setting.name,true,nil,false,function(player,element)
|
||||
local data = _get_data(element.parent.parent)
|
||||
local objects = _object_list(player)
|
||||
local object = objects[data.object]
|
||||
pcall(object[data.key],unpack(data.params))
|
||||
Server.new_thread{
|
||||
timeout=60,
|
||||
data=element
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data and self.data.valid then
|
||||
element.parent.parent['game-settings-are-you-sure'].state = false
|
||||
self.data.parent.style.visible = false
|
||||
self.data.state = false
|
||||
end
|
||||
end):open()
|
||||
end)
|
||||
if not setting.params then setting.params = {} end
|
||||
end
|
||||
setting._loaded = _added
|
||||
setting._group = name
|
||||
end
|
||||
end
|
||||
|
||||
local are_you_sure = Gui.inputs.add_checkbox('game-settings-are-you-sure',true,nil,false,function(player,element)
|
||||
element.parent.sure.style.visible = true
|
||||
Server.new_thread{
|
||||
timeout=600,
|
||||
data=element
|
||||
}:on_event('timeout',function(self)
|
||||
if self.data and self.data.valid then
|
||||
self.data.state = false
|
||||
self.data.parent.sure.style.visible = false
|
||||
end
|
||||
end):open()
|
||||
end)
|
||||
|
||||
local function _draw_setting(frame,setting)
|
||||
local frame = frame.add{type='flow'}
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
name=setting._group
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'game-settings.effect-'..setting.name},
|
||||
style='caption_label'
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption=setting.key,
|
||||
name='setting_name'
|
||||
}.style.visible = false
|
||||
if setting.type == 'slider' then
|
||||
local slider = setting._loaded:draw(frame)
|
||||
slider.style.width = 300
|
||||
local _caption = string.format('%.2f',slider.slider_value); if slider.slider_value > 2 then _caption = tostring(math.floor(slider.slider_value)) end
|
||||
frame.add{
|
||||
type='label',
|
||||
name='counter',
|
||||
caption=_caption
|
||||
}
|
||||
elseif setting.type == 'function' then
|
||||
are_you_sure:draw(frame)
|
||||
local flow = frame.add{type='flow',name='sure'}
|
||||
flow.style.visible = false
|
||||
flow.add{
|
||||
type='label',
|
||||
caption={'game-settings.sure'},
|
||||
style='bold_red_label'
|
||||
}
|
||||
setting._loaded:draw(flow)
|
||||
end
|
||||
end
|
||||
|
||||
Gui.center.add{
|
||||
name='game-settings',
|
||||
caption='utility/no_building_material_icon',
|
||||
tooltip={'game-settings.tooltip'}
|
||||
}:add_tab('basic',{'game-settings.basic-name'},{'game-settings.basic-name'},function(frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'game-settings.basic-message'}
|
||||
}.style.single_line = false
|
||||
for _,setting in pairs(basic_settings) do
|
||||
_draw_setting(frame,setting)
|
||||
end
|
||||
end):add_tab('advanced',{'game-settings.advanced-name'},{'game-settings.advanced-tooltip'},function(frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'game-settings.advanced-message'}
|
||||
}.style.single_line = false
|
||||
for _,setting in pairs(advanced_settings) do
|
||||
_draw_setting(frame,setting)
|
||||
end
|
||||
end):add_tab('personal',{'game-settings.personal-name'},{'game-settings.personal-tooltip'},function(frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'game-settings.personal-message'}
|
||||
}.style.single_line = false
|
||||
for _,setting in pairs(personal_settings) do
|
||||
_draw_setting(frame,setting)
|
||||
end
|
||||
end)
|
||||
115
to convert/Addons/Guis/player-list.lua
Normal file
115
to convert/Addons/Guis/player-list.lua
Normal file
@@ -0,0 +1,115 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local function _global(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.player_list = not reset and global.addons.player_list or {update=0,delay=10,intervial=54000}
|
||||
return global.addons.player_list
|
||||
end
|
||||
|
||||
local get_player_info = get_player_info or function(player,frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'player-list.no-info-file'}
|
||||
}
|
||||
end
|
||||
|
||||
local function update()
|
||||
Gui.left.update('player-list')
|
||||
end
|
||||
|
||||
local function queue_update(tick)
|
||||
local data = _global()
|
||||
local tick = is_type(tick,'table') and tick.tick or is_type(tick,'number') and tick or game.tick
|
||||
if tick + data.delay > data.update - data.intervial then
|
||||
data.update = tick + data.delay
|
||||
end
|
||||
end
|
||||
|
||||
local back_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
caption='utility/enter',
|
||||
name='player-list-back'
|
||||
}:on_event('click',function(event)
|
||||
event.element.parent.parent.scroll.style.visible = true
|
||||
event.element.parent.destroy()
|
||||
end)
|
||||
|
||||
Gui.left.add{
|
||||
name='player-list',
|
||||
caption='entity/player',
|
||||
tooltip={'player-list.tooltip'},
|
||||
draw=function(frame)
|
||||
frame.caption = ''
|
||||
local player_list = frame.add{
|
||||
name='scroll',
|
||||
type = 'scroll-pane',
|
||||
direction = 'vertical',
|
||||
vertical_scroll_policy='auto',
|
||||
horizontal_scroll_policy='never'
|
||||
}
|
||||
player_list.vertical_scroll_policy = 'auto'
|
||||
player_list.style.maximal_height=195
|
||||
for _,rank in pairs(Ranking._ranks()) do
|
||||
for _,player in pairs(rank:get_players(true)) do
|
||||
local flow = player_list.add{type='flow'}
|
||||
if rank.short_hand == '' then
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'player-list.format-nil',tick_to_display_format(player.online_time),player.name}
|
||||
}.style.font_color = rank.colour
|
||||
else
|
||||
flow.add{
|
||||
type='label',
|
||||
name=player.name,
|
||||
style='caption_label',
|
||||
caption={'player-list.format',tick_to_display_format(player.online_time),player.name,rank.short_hand}
|
||||
}.style.font_color = rank.colour
|
||||
end
|
||||
if Admin.report_btn then
|
||||
if not rank:allowed('no-report') and player.index ~= frame.player_index then
|
||||
local btn = Admin.report_btn:draw(flow)
|
||||
btn.style.height = 20
|
||||
btn.style.width = 20
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
open_on_join=true
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_tick,function(event)
|
||||
local data = _global()
|
||||
if event.tick > data.update then
|
||||
update()
|
||||
data.update = event.tick + data.intervial
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_gui_click,function(event)
|
||||
if event.element and event.element.valid
|
||||
and event.element.parent and event.element.parent.parent and event.element.parent.parent.parent
|
||||
and event.element.parent.parent.parent.name == 'player-list' then else return end
|
||||
if event.button == defines.mouse_button_type.right then else return end
|
||||
local player_list = event.element.parent.parent.parent
|
||||
player_list.scroll.style.visible = false
|
||||
local flow = player_list.add{type='flow',direction='vertical'}
|
||||
back_btn:draw(flow)
|
||||
get_player_info(event.element.name,flow,true)
|
||||
if Game.get_player(event.element.name) and event.player_index == Game.get_player(event.element.name).index then return end
|
||||
if Admin and Admin.allowed(event.player_index) then Admin.btn_flow(flow).caption = event.element.name end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_joined_game,queue_update)
|
||||
Event.register(defines.events.on_player_left_game,queue_update)
|
||||
Event.register(defines.events.rank_change,queue_update)
|
||||
260
to convert/Addons/Guis/polls.lua
Normal file
260
to convert/Addons/Guis/polls.lua
Normal file
@@ -0,0 +1,260 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local poll_time_out = 90 -- In seconds
|
||||
|
||||
local function _polls(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.polls = not reset and global.addons.polls or {active={},old={}}
|
||||
return global.addons.polls
|
||||
end
|
||||
|
||||
function _poll_end(self)
|
||||
local uuid = self.data.poll_uuid
|
||||
local poll = _polls().active[uuid]
|
||||
if not poll then return end
|
||||
local highest = {nil,-1}
|
||||
local _votes = {}
|
||||
for index,answer in pairs(poll.answers) do
|
||||
local _result = poll.votes[index] or 0
|
||||
if _result > highest[2] then highest = {answer,_result} end
|
||||
_votes[answer] = _result
|
||||
end
|
||||
local uuid = poll.uuid
|
||||
poll.uuid = nil
|
||||
poll.votes = _votes
|
||||
poll.answers = nil
|
||||
poll.voted = nil
|
||||
table.insert(_polls().old,poll)
|
||||
_polls().active[uuid] = nil
|
||||
game.print({'polls.end',poll.question},defines.text_color.info)
|
||||
game.print({'polls.winner',highest[1]},defines.text_color.info)
|
||||
end
|
||||
|
||||
local function _poll_data(question,answers)
|
||||
local poll = {
|
||||
uuid=Server.new_uuid(),
|
||||
question=question,
|
||||
answers=answers or {'None'},
|
||||
votes={},
|
||||
voted={}
|
||||
}
|
||||
Server.new_thread{
|
||||
data={poll_uuid=poll.uuid},
|
||||
timeout=poll_time_out*60
|
||||
}:on_event('timeout',_poll_end):open()
|
||||
-- This time out is known to cause desyncs and so I have moved it to a hard coded function
|
||||
_polls().active[poll.uuid]=poll
|
||||
return poll.uuid
|
||||
end
|
||||
|
||||
local function draw_poll(frame)
|
||||
frame.clear()
|
||||
local index = tonumber(frame.parent.current_index.caption)
|
||||
local poll = _polls().old[index]
|
||||
if not poll then
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'polls.no-poll'}
|
||||
}
|
||||
return
|
||||
end
|
||||
frame.add{
|
||||
type='label',
|
||||
caption='Question: '..poll.question
|
||||
}
|
||||
for answer,votes in pairs(poll.votes) do
|
||||
frame.add{
|
||||
type='label',
|
||||
caption=answer..') '..votes
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
local function _opptions(player,root_frame)
|
||||
local opptions = {'Please Select An Opption'}
|
||||
local uuid = root_frame.name
|
||||
local poll = _polls().active[uuid]
|
||||
if not poll then return {'Invalid Poll'} end
|
||||
for _,answer in pairs(poll.answers) do
|
||||
table.insert(opptions,answer)
|
||||
end
|
||||
return opptions
|
||||
end
|
||||
|
||||
local opption_drop_down = Gui.inputs.add_drop_down('opption-drop-down-polls',_opptions,1,function(player,selected,items,element)
|
||||
local uuid = element.parent.name
|
||||
local poll = _polls().active[uuid]
|
||||
if not poll then return end
|
||||
if poll.voted[player.index] and poll.voted[player.index] > 1 then
|
||||
local old_vote = poll.voted[player.index]
|
||||
poll.votes[old_vote-1] = poll.votes[old_vote-1] and poll.votes[old_vote-1]-1 or 0
|
||||
end
|
||||
if element.selected_index > 1 then
|
||||
poll.votes[element.selected_index-1] = poll.votes[element.selected_index-1] and poll.votes[element.selected_index-1]+1 or 1
|
||||
end
|
||||
poll.voted[player.index]=element.selected_index
|
||||
element.parent.answer.caption = 'Your Answer: '..selected
|
||||
end)
|
||||
|
||||
local prev = Gui.inputs.add{
|
||||
type='button',
|
||||
name='prev-poll',
|
||||
caption='utility/hint_arrow_left'
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local index = parent.parent.current_index.caption
|
||||
local _index = tonumber(index)-1
|
||||
if _index < 1 then _index = #_polls().old end
|
||||
parent.parent.current_index.caption = _index
|
||||
parent.parent.title.title.caption = 'Viewing Poll: '.._index
|
||||
draw_poll(parent.parent.poll_area)
|
||||
end)
|
||||
|
||||
local next = Gui.inputs.add{
|
||||
type='button',
|
||||
name='next-poll',
|
||||
caption='utility/hint_arrow_right'
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local index = parent.parent.current_index.caption
|
||||
local _index = tonumber(index)+1
|
||||
if _index > #_polls().old then _index = 1 end
|
||||
parent.parent.current_index.caption = _index
|
||||
parent.parent.title.title.caption = 'Viewing Poll: '.._index
|
||||
draw_poll(parent.parent.poll_area)
|
||||
end)
|
||||
|
||||
local poll_question_input = Gui.inputs.add_text('poll-question-input',true,'Question',function(player,text,element)
|
||||
local options = element.parent.options
|
||||
if not options.question then options.add{type='label',name='question',caption=''}
|
||||
else options.question.caption = text end
|
||||
end)
|
||||
|
||||
local _self_referace_poll_option_input = nil
|
||||
local poll_option_input = Gui.inputs.add_text('poll-option-input',true,'Enter Option',function(player,text,element)
|
||||
local options = element.parent.parent.parent.options
|
||||
if not options[element.parent.name] then options.add{type='label',name=element.parent.name,caption=text}
|
||||
else options[element.parent.name].caption = text end
|
||||
if options.last.caption == element.parent.name then
|
||||
options.last.caption = tonumber(options.last.caption)+1
|
||||
_self_referace_poll_option_input:draw(element.parent.parent.add{type='flow',name=options.last.caption}).style.minimal_width = 200
|
||||
end
|
||||
end)
|
||||
_self_referace_poll_option_input = poll_option_input
|
||||
|
||||
local function poll_assembler(frame)
|
||||
frame.clear()
|
||||
local options = frame.add{type='flow',name='options'}
|
||||
options.style.visible = false
|
||||
options.add{type='label',name='last',caption='2'}
|
||||
poll_question_input:draw(frame).style.minimal_width = 200
|
||||
local flow = frame.add{type='flow',direction='vertical'}
|
||||
poll_option_input:draw(flow.add{type='flow',name='1'}).style.minimal_width = 200
|
||||
poll_option_input:draw(flow.add{type='flow',name='2'}).style.minimal_width = 200
|
||||
end
|
||||
|
||||
local create_poll = Gui.inputs.add{
|
||||
type='button',
|
||||
name='create-poll',
|
||||
caption='utility/add'
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
if event.element.sprite == 'utility/enter' then
|
||||
local inputs = parent.parent.poll_area.options
|
||||
if not inputs then
|
||||
event.element.sprite = 'utility/add'
|
||||
draw_poll(parent.parent.poll_area)
|
||||
return
|
||||
end
|
||||
local options = {}
|
||||
for _,option in pairs(inputs.children) do
|
||||
if option.name ~= 'question' and option.name ~= 'last' then
|
||||
if option.caption ~= 'Enter Option' and option.caption ~= '' then table.insert(options,option.caption) end
|
||||
end
|
||||
end
|
||||
if not inputs.question or #options == 0 then
|
||||
event.element.sprite = 'utility/add'
|
||||
draw_poll(parent.parent.poll_area)
|
||||
return
|
||||
end
|
||||
local uuid = _poll_data(inputs.question.caption,options)
|
||||
Gui.popup.open('polls',{uuid=uuid})
|
||||
event.element.sprite = 'utility/add'
|
||||
draw_poll(parent.parent.poll_area)
|
||||
else
|
||||
event.element.sprite = 'utility/enter'
|
||||
poll_assembler(parent.parent.poll_area)
|
||||
end
|
||||
end)
|
||||
|
||||
Gui.popup.add{
|
||||
name='polls',
|
||||
caption={'polls.name'},
|
||||
draw=function(frame,data)
|
||||
frame.style.right_padding = 5
|
||||
frame.style.bottom_padding = 5
|
||||
local uuid = data.uuid
|
||||
local poll = _polls().active[uuid]
|
||||
if not poll then return end
|
||||
local flow = frame.add{
|
||||
type='flow',
|
||||
name=uuid,
|
||||
direction='vertical'
|
||||
}
|
||||
flow.add{type='label',caption={'polls.time-left',poll_time_out}}
|
||||
flow.add{type='label',caption='Question: '..poll.question}
|
||||
flow.add{type='label',name='answer',caption='Your Answer: None'}
|
||||
opption_drop_down:draw(flow)
|
||||
end
|
||||
}:add_left{
|
||||
caption='utility/item_editor_icon',
|
||||
tooltip={'polls.tooltip'},
|
||||
draw=function(frame)
|
||||
frame.caption={'polls.name'}
|
||||
frame.add{
|
||||
type='label',
|
||||
name='current_index',
|
||||
caption=1
|
||||
}.style.visible = false
|
||||
local title = frame.add{
|
||||
type='flow',
|
||||
name='title'
|
||||
}
|
||||
local btn = prev:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
title.add{
|
||||
type='label',
|
||||
name='title',
|
||||
caption='Viewing Poll: 1',
|
||||
style='caption_label'
|
||||
}
|
||||
local btn = next:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
if Ranking.get_rank(frame.player_index):allowed('create-poll') then
|
||||
local btn = create_poll:draw(title)
|
||||
btn.style.width = 20
|
||||
btn.style.height = 20
|
||||
end
|
||||
local flow = frame.add{
|
||||
type='flow',
|
||||
name='poll_area',
|
||||
direction='vertical'
|
||||
}
|
||||
draw_poll(flow)
|
||||
end,
|
||||
can_open=function(player)
|
||||
if #_polls().old > 0 then return true
|
||||
elseif Ranking.get_rank(player):allowed('create-poll') then return true
|
||||
else return {'polls.no-poll'} end
|
||||
end
|
||||
}
|
||||
132
to convert/Addons/Guis/rank-changer.lua
Normal file
132
to convert/Addons/Guis/rank-changer.lua
Normal file
@@ -0,0 +1,132 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local get_player_info = get_player_info or function(player,frame)
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'rank-changer.no-info-file'}
|
||||
}
|
||||
end
|
||||
|
||||
local function _players(_player,root_frame,state)
|
||||
local players = {'Select Player'}
|
||||
local _players = state and game.players or game.connected_players
|
||||
for _,player in pairs(_players) do
|
||||
if player.name ~= _player.name then
|
||||
if Admin.is_banned and Admin.is_banned(player) then else
|
||||
table.insert(players,player.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
return players
|
||||
end
|
||||
|
||||
local online_check = Gui.inputs.add_checkbox('online-check-rank-change',false,'Show Offline',false,function(player,element)
|
||||
element.parent['player-drop-down-rank-change'].items = _players(player,element.parent,true)
|
||||
element.parent['player-drop-down-rank-change'].selected_index = 1
|
||||
end,function(player,element)
|
||||
element.parent['player-drop-down-rank-change'].items = _players(player,element.parent,false)
|
||||
element.parent['player-drop-down-rank-change'].selected_index = 1
|
||||
end)
|
||||
|
||||
local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-rank-change',_players,1,function(player,selected,items,element)
|
||||
element.parent.parent.player.caption = selected
|
||||
local player_info_flow = element.parent.parent.info_flow
|
||||
player_info_flow.clear()
|
||||
if selected == 'Select Player' then return
|
||||
else get_player_info(selected,player_info_flow,true) end
|
||||
local rank = Ranking.get_rank(player)
|
||||
local _rank = Ranking.get_rank(selected)
|
||||
if rank.power >= _rank.power then element.parent.warning.caption = {'rank-changer.warning'}
|
||||
else element.parent.warning.caption = '' end
|
||||
end)
|
||||
|
||||
local function _ranks(player)
|
||||
local ranks = {'Select Rank'}
|
||||
local _rank = Ranking.get_rank(player)
|
||||
for _,rank in pairs(Ranking._ranks()) do
|
||||
if rank.power > _rank.power then
|
||||
table.insert(ranks,rank.name)
|
||||
end
|
||||
end
|
||||
return ranks
|
||||
end
|
||||
|
||||
local rank_drop_down = Gui.inputs.add_drop_down('rank-drop-down-rank-change',_ranks,1,function(player,selected,items,element)
|
||||
element.parent.parent.rank.caption = selected
|
||||
end)
|
||||
|
||||
local set_rank = Gui.inputs.add{
|
||||
type='button',
|
||||
name='rank-change-set',
|
||||
caption={'rank-changer.set-rank'}
|
||||
}:on_event('click',function(event)
|
||||
local dropdowns = event.element.parent
|
||||
local rank = Ranking.get_rank(event.player_index)
|
||||
local _rank = Ranking.get_rank(dropdowns.parent.rank.caption)
|
||||
local _player = Game.get_player(dropdowns.parent.player.caption)
|
||||
if not _player or not _rank then dropdowns.warning.caption = {'rank-changer.invalid'} return end
|
||||
local __rank = Ranking.get_rank(_player)
|
||||
if rank.power >= __rank.power then dropdowns.warning.caption = {'rank-changer.rank-high'} return end
|
||||
Ranking.give_rank(_player,_rank,event)
|
||||
Gui.center.clear(event)
|
||||
end)
|
||||
|
||||
Gui.center.add{
|
||||
name='rank-changer',
|
||||
caption='utility/circuit_network_panel',
|
||||
tooltip={'rank-changer.tooltip'},
|
||||
draw=function(self,frame)
|
||||
frame.caption={'rank-changer.name'}
|
||||
local frame = frame.add{
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
local dropdowns = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
local player_info_flow = frame.add{
|
||||
name='info_flow',
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
player_info_flow.style.height = 200
|
||||
player_info_flow.style.width = 200
|
||||
local label = dropdowns.add{
|
||||
type='label',
|
||||
caption={'rank-changer.message'}
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
online_check:draw(dropdowns)
|
||||
player_drop_down:draw(dropdowns)
|
||||
rank_drop_down:draw(dropdowns)
|
||||
local label = dropdowns.add{
|
||||
name='warning',
|
||||
type='label',
|
||||
caption='',
|
||||
style='bold_red_label'
|
||||
}
|
||||
label.style.single_line = false
|
||||
label.style.width = 200
|
||||
set_rank:draw(dropdowns)
|
||||
frame.add{
|
||||
name='player',
|
||||
type='label',
|
||||
caption='///'
|
||||
}.style.visible = false
|
||||
frame.add{
|
||||
name='rank',
|
||||
type='label',
|
||||
caption='///'
|
||||
}.style.visible = false
|
||||
end
|
||||
}
|
||||
132
to convert/Addons/Guis/readme.lua
Normal file
132
to convert/Addons/Guis/readme.lua
Normal file
@@ -0,0 +1,132 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local function format_label(label)
|
||||
label.style.maximal_width = 480
|
||||
label.style.single_line = false
|
||||
end
|
||||
|
||||
Gui.center.add{
|
||||
name='readme',
|
||||
caption='utility/questionmark',
|
||||
tooltip={'readme.tooltip'}
|
||||
}:add_tab('guildlines',{'readme.guildlines-name'},{'readme.guildlines-tooltip'},function(frame)
|
||||
for i = 1,10 do
|
||||
local style=nil; if i == 1 then style = 'caption_label' end
|
||||
format_label(frame.add{
|
||||
type='label',
|
||||
caption={'readme.guildlines-line'..tostring(i)},
|
||||
style=style
|
||||
})
|
||||
end
|
||||
end):add_tab('chat',{'readme.chat-name'},{'readme.chat-tooltip'},function(frame)
|
||||
format_label(frame.add{
|
||||
type='label',
|
||||
caption={'readme.chat-singleline'}
|
||||
})
|
||||
end):add_tab('commands',{'readme.commands-name'},{'readme.commands-tooltip'},function(frame)
|
||||
format_label(frame.add{
|
||||
type='label',
|
||||
caption={'readme.commands-singleline'}
|
||||
})
|
||||
Gui.bar(frame,480)
|
||||
local table = frame.add{name='command_table',type='table',column_count=2}
|
||||
table.add{
|
||||
type='label',
|
||||
caption={'readme.commands-col1'},
|
||||
style='caption_label'
|
||||
}
|
||||
table.add{
|
||||
type='label',
|
||||
caption={'readme.commands-col2'},
|
||||
style='caption_label'
|
||||
}
|
||||
table.style.width = 480
|
||||
table.draw_vertical_lines = true
|
||||
table.draw_horizontal_line_after_headers = true
|
||||
for _,command in pairs(commands.get_commands(frame.player_index)) do
|
||||
table.add{
|
||||
type='label',
|
||||
caption='/'..command.name
|
||||
}
|
||||
local discription = table.add{
|
||||
type='label',
|
||||
caption=command.description,
|
||||
}
|
||||
discription.style.maximal_width = 400
|
||||
discription.style.single_line = false
|
||||
end
|
||||
end):add_tab('links',{'readme.links-name'},{'readme.links-tooltip'},function(frame)
|
||||
local links={
|
||||
'https://discord.explosivegaming.nl',
|
||||
'https://explosivegaming.nl',
|
||||
'http://steamcommunity.com/groups/tntexplosivegaming',
|
||||
'https://www.patreon.com/badgamernl',
|
||||
'https://wiki.explosivegaming.nl/'
|
||||
}
|
||||
local function format(text_box)
|
||||
text_box.style.minimal_width=400
|
||||
text_box.read_only = true
|
||||
text_box.word_wrap = true
|
||||
text_box.selectable = true
|
||||
end
|
||||
for i,link in pairs(links) do
|
||||
frame.add{
|
||||
type="label",
|
||||
caption={'readme.links-cap'..tostring(i)},
|
||||
style='caption_label'
|
||||
}
|
||||
format(frame.add{
|
||||
type='text-box',
|
||||
text=link
|
||||
})
|
||||
end
|
||||
end):add_tab('servers',{'readme.servers-name'},{'readme.servers-tooltip'},function(frame)
|
||||
format_label(frame.add{
|
||||
type='label',
|
||||
caption={'readme.servers-singleline'}
|
||||
})
|
||||
Gui.bar(frame,480)
|
||||
for i = 1,6 do
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'readme.servers-format',tostring(i),{'readme.servers-cap'..tostring(i)}},
|
||||
style='caption_label'
|
||||
}
|
||||
format_label(frame.add{
|
||||
type='label',
|
||||
caption={'readme.servers-des'..tostring(i)}
|
||||
})
|
||||
end
|
||||
end):add_tab('rules',{'readme.rules-name'},{'readme.rules-tooltip'},function(frame)
|
||||
format_label(frame.add{
|
||||
type='label',
|
||||
caption={'readme.rules-singleline'}
|
||||
})
|
||||
Gui.bar(frame,480)
|
||||
for i = 1,20 do
|
||||
format_label(frame.add{
|
||||
type='label',
|
||||
caption={'readme.rules-format',i,{'readme.rules-rule'..tostring(i)}}
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
Sync.add_to_gui(Gui.inputs.add_button('readme-sync-guildlines','View Guildlines','View the guildlines in the readme',function(player,element)
|
||||
Gui.center.open_tab(player,'readme','guildlines')
|
||||
end))
|
||||
|
||||
Sync.add_to_gui(Gui.inputs.add_button('readme-sync-links','View Other Links','View the links in the readme',function(player,element)
|
||||
Gui.center.open_tab(player,'readme','links')
|
||||
end))
|
||||
|
||||
Sync.add_to_gui(Gui.inputs.add_button('readme-sync-rules','View All Rules','View the all rules in the readme',function(player,element)
|
||||
Gui.center.open_tab(player,'readme','rules')
|
||||
end))
|
||||
53
to convert/Addons/Guis/reports.lua
Normal file
53
to convert/Addons/Guis/reports.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local confirm_report = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-report-confirm',
|
||||
caption='utility/spawn_flag',
|
||||
tooltip={'reports.name'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local player = Game.get_player(parent.player.caption)
|
||||
local reason = parent.reason.text
|
||||
Admin.report(player,event.player_index,reason)
|
||||
Gui.center.clear(event.player_index)
|
||||
end)
|
||||
|
||||
Admin.report_btn = Gui.inputs.add{
|
||||
type='button',
|
||||
name='admin-report',
|
||||
caption='utility/spawn_flag',
|
||||
tooltip={'reports.name'}
|
||||
}:on_event('click',function(event)
|
||||
local parent = event.element.parent
|
||||
local player = Game.get_player(parent.children[1].name)
|
||||
if not player then return end
|
||||
local _player = Game.get_player(event)
|
||||
Gui.center.clear(_player)
|
||||
local frame = Gui.center.get_flow(_player).add{
|
||||
type='frame',
|
||||
name='report-gui'
|
||||
}
|
||||
_player.opened=frame
|
||||
frame.caption={'reports.name'}
|
||||
frame.add{
|
||||
type='textfield',
|
||||
name='reason'
|
||||
}.style.width = 300
|
||||
local btn = confirm_report:draw(frame)
|
||||
btn.style.height = 30
|
||||
btn.style.width = 30
|
||||
frame.add{
|
||||
type='label',
|
||||
name='player',
|
||||
caption=player.name
|
||||
}.style.visible = false
|
||||
end)
|
||||
104
to convert/Addons/Guis/rockets.lua
Normal file
104
to convert/Addons/Guis/rockets.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local function _global(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.rockets = not reset and global.addons.rockets or {update=0,first=0,_last=0,last=0,fastest=0,milestones={m1=0,m2=0,m5=0,m10=0,m20=0,m50=0,m100=0,m200=0,m500=0,m1000=0,m2000=0,m5000=0}}
|
||||
return global.addons.rockets
|
||||
end
|
||||
Gui.left.add{
|
||||
name='rockets',
|
||||
caption='item/rocket-silo',
|
||||
tooltip={'rockets.tooltip'},
|
||||
draw=function(frame)
|
||||
frame.caption = {'rockets.name'}
|
||||
local player = Game.get_player(frame.player_index)
|
||||
local data = _global()
|
||||
local satellites = player.force.get_item_launched('satellite')
|
||||
local time = {'rockets.nan'}
|
||||
if satellites == 1 then time = tick_to_display_format(game.tick)
|
||||
elseif satellites > 1 then time = tick_to_display_format((game.tick-data.first)/satellites) end
|
||||
if satellites ~= data.update then
|
||||
data.update = satellites
|
||||
if data.first == 0 then data.first = game.tick end
|
||||
data._last = data.last
|
||||
data.last = game.tick
|
||||
if data.last-data._last < data.fastest or data.fastest == 0 then data.fastest = data.last-data._last end
|
||||
end
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'rockets.sent',satellites}
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'rockets.first',tick_to_display_format(data.first)}
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'rockets.last',tick_to_display_format(data.last-data._last)}
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'rockets.time',time}
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'rockets.fastest',tick_to_display_format(data.fastest)}
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'rockets.milestones'},
|
||||
style='caption_label'
|
||||
}
|
||||
local milestones = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
for milestone,time in pairs(data.milestones) do
|
||||
local milestone = tonumber(milestone:match('%d+'))
|
||||
if time == 0 and satellites == milestone then
|
||||
data.milestones['m'..milestone] = data.last
|
||||
time = data.last
|
||||
Gui.left.open('rockets')
|
||||
end
|
||||
local _time = {'rockets.nan'}
|
||||
if time > 0 then _time = tick_to_display_format(time) end
|
||||
milestones.add{
|
||||
type='label',
|
||||
caption={'rockets.format',tostring(milestone),_time}
|
||||
}
|
||||
if time == 0 then break end
|
||||
end
|
||||
end,
|
||||
can_open=function(player)
|
||||
if player.force.get_item_launched('satellite') > 0 then return true
|
||||
else return {'rockets.none'} end
|
||||
end
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_rocket_launched,function(event) Gui.left.update('rockets') end)
|
||||
Sync.add_update('rockets',function()
|
||||
local _return = {}
|
||||
local data = _global()
|
||||
local satellites = game.forces.player.get_item_launched('satellite')
|
||||
local time = {'rockets.nan'}
|
||||
if satellites == 1 then time = tick_to_display_format(game.tick)
|
||||
elseif satellites > 1 then time = tick_to_display_format((game.tick-data.first)/satellites) end
|
||||
_return.total = satellites
|
||||
_return.first = Sync.tick_format(data.first)
|
||||
_return.last = Sync.tick_format(data.last-data._last)
|
||||
_return.time = Sync.tick_format(time)
|
||||
_return.fastest = Sync.tick_format(data.fastest)
|
||||
_return.milestones = {}
|
||||
for milestone,time in pairs(data.milestones) do
|
||||
_return.milestones[milestone] = Sync.tick_format(time)
|
||||
end
|
||||
return _return
|
||||
end)
|
||||
102
to convert/Addons/Guis/science.lua
Normal file
102
to convert/Addons/Guis/science.lua
Normal file
@@ -0,0 +1,102 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local science_packs = {
|
||||
'science-pack-1',
|
||||
'science-pack-2',
|
||||
'science-pack-3',
|
||||
'military-science-pack',
|
||||
'production-science-pack',
|
||||
'high-tech-science-pack',
|
||||
'space-science-pack'
|
||||
}
|
||||
|
||||
local function _global(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.science = not reset and global.addons.science or {_base={update=0,_update=0,made={0,0,0,0,0,0,0},_made={0,0,0,0,0,0,0}}}
|
||||
return global.addons.science
|
||||
end
|
||||
|
||||
Gui.left.add{
|
||||
name='science',
|
||||
caption='item/lab',
|
||||
tooltip={'science.tooltip'},
|
||||
draw=function(frame)
|
||||
local data = _global()
|
||||
local player = Game.get_player(frame.player_index)
|
||||
if not data[player.force.name] then
|
||||
data[player.force.name] = table.deepcopy(data._base)
|
||||
end
|
||||
data = data[player.force.name]
|
||||
frame.caption = {'science.name'}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'science.total'},
|
||||
style='caption_label'
|
||||
}
|
||||
local totals = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
frame.add{
|
||||
type='label',
|
||||
caption={'science.time'},
|
||||
style='caption_label'
|
||||
}
|
||||
local times = frame.add{
|
||||
type='flow',
|
||||
direction='vertical'
|
||||
}
|
||||
if data.update < game.tick-100 then
|
||||
data._update = data.update
|
||||
data._made = table.deepcopy(data.made)
|
||||
for i,name in pairs(science_packs) do
|
||||
data.made[i] = player.force.item_production_statistics.get_input_count(name)
|
||||
end
|
||||
data.update = game.tick
|
||||
end
|
||||
for i,name in pairs(science_packs) do
|
||||
local made = data.made[i]
|
||||
if made > 0 then
|
||||
totals.add{
|
||||
type='label',
|
||||
caption={'science.format',{'science.'..name},made}
|
||||
}
|
||||
local _made = string.format('%.2f',(made-data._made[i])/((data.update-data._update)/(3600*game.speed)))
|
||||
times.add{
|
||||
type='label',
|
||||
caption={'science.format',{'science.'..name},_made}
|
||||
}
|
||||
end
|
||||
end
|
||||
end,
|
||||
can_open=function(player)
|
||||
if player.force.item_production_statistics.get_input_count('science-pack-1') > 0 then return true
|
||||
else return {'science.none'} end
|
||||
end
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_research_finished,function(event) Gui.left.update('science') end)
|
||||
Sync.add_update('science',function()
|
||||
local _return = {}
|
||||
local _data = _global()
|
||||
for force_name,data in pairs(_data) do
|
||||
if force_name ~= '_base' then
|
||||
_return[force_name] = {totals={},times={}}
|
||||
for i,name in pairs(science_packs) do
|
||||
local made = data.made[i]
|
||||
_return[force_name].totals[name] = made
|
||||
local _made = string.format('%.2f',(made-data._made[i])/((data.update-data._update)/(3600*game.speed)))
|
||||
_return[force_name].times[name] = _made
|
||||
end
|
||||
end
|
||||
end
|
||||
return _return
|
||||
end)
|
||||
193
to convert/Addons/Guis/tasklist.lua
Normal file
193
to convert/Addons/Guis/tasklist.lua
Normal file
@@ -0,0 +1,193 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local function _global(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.tasklist = not reset and global.addons.tasklist or {tasks={},_edit={},_base={_edit=false,_tasks={},_editing={}}}
|
||||
return global.addons.tasklist
|
||||
end
|
||||
|
||||
local edit = Gui.inputs.add{
|
||||
name='tasklist-edit',
|
||||
type='button',
|
||||
caption='utility/rename_icon_normal'
|
||||
}:on_event('click',function(event)
|
||||
local text_flow = event.element.parent.parent.text_flow
|
||||
local data = _global()._edit[event.player_index]
|
||||
if not data._edit then data._tasks = table.deepcopy(_global().tasks) end
|
||||
if text_flow.input.type == 'label' then
|
||||
data._editing[tonumber(text_flow.parent.name)]=true
|
||||
Gui.left.update('tasklist',event.player_index)
|
||||
elseif text_flow.input.type == 'textfield' then
|
||||
local text = text_flow.input.text
|
||||
data._editing[tonumber(text_flow.parent.name)]=false
|
||||
data._tasks[tonumber(text_flow.parent.name)]=text
|
||||
Gui.left.update('tasklist',event.player_index)
|
||||
end
|
||||
end)
|
||||
|
||||
local function _edit(frame)
|
||||
local element = edit:draw(frame)
|
||||
element.style.height = 20
|
||||
element.style.width = 20
|
||||
local text_flow = element.parent.parent.text_flow
|
||||
local data = _global()._edit[frame.player_index]
|
||||
data._tasks[text_flow.parent.name]=text
|
||||
if data._editing[tonumber(text_flow.parent.name)] then
|
||||
element.style.height = 30
|
||||
element.style.width = 30
|
||||
local text = text_flow.input.caption
|
||||
text_flow.clear()
|
||||
local _text = text_flow.add{
|
||||
name='input',
|
||||
type='textfield',
|
||||
text=text
|
||||
}
|
||||
_text.style.width = 200
|
||||
element.sprite = 'utility/enter'
|
||||
end
|
||||
end
|
||||
|
||||
local remove = Gui.inputs.add{
|
||||
name='tasklist-remove',
|
||||
type='button',
|
||||
caption='utility/remove'
|
||||
}:on_event('click',function(event)
|
||||
local frame = event.element.parent.parent
|
||||
local data = _global()._edit[event.player_index]
|
||||
if data._edit then
|
||||
table.remove(data._tasks,tonumber(frame.name))
|
||||
table.remove(data._editing,tonumber(frame.name))
|
||||
else
|
||||
table.remove(_global().tasks,tonumber(frame.name))
|
||||
Gui.left.update('tasklist')
|
||||
end
|
||||
Gui.left.update('tasklist',event.player_index)
|
||||
end)
|
||||
|
||||
local add = Gui.inputs.add{
|
||||
name='tasklist-add',
|
||||
type='button',
|
||||
caption='utility/add'
|
||||
}:on_event('click',function(event)
|
||||
local frame = event.element.parent.parent
|
||||
local data = _global()._edit[event.player_index]
|
||||
if data._edit then
|
||||
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
|
||||
table.insert(data._editing,tonumber(frame.name)+1,true)
|
||||
else
|
||||
data._tasks = table.deepcopy(_global().tasks)
|
||||
table.insert(data._tasks,tonumber(frame.name)+1,'New Value')
|
||||
table.insert(data._editing,tonumber(frame.name)+1,true)
|
||||
end
|
||||
Gui.left.update('tasklist',event.player_index)
|
||||
end)
|
||||
|
||||
local function _tasks(player)
|
||||
local player = Game.get_player(player)
|
||||
local data = _global()._edit[player.index]
|
||||
if not data then return _global().tasks end
|
||||
local _edit = false
|
||||
for _,v in pairs(data._editing) do
|
||||
if v == true then
|
||||
_edit = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if data._edit and not _edit then
|
||||
_global().tasks = table.deepcopy(data._tasks)
|
||||
_global()._edit[player.index] = table.deepcopy(_global()._base)
|
||||
Gui.left.update('tasklist')
|
||||
return _global().tasks
|
||||
elseif not data._edit and _edit then
|
||||
data._edit = true
|
||||
for key,_ in pairs(data._tasks) do if not data._editing[key] then data._editing[key] = false end end
|
||||
return data._tasks
|
||||
elseif _edit then return data._tasks
|
||||
else return _global().tasks
|
||||
end
|
||||
end
|
||||
|
||||
Gui.left.add{
|
||||
name='tasklist',
|
||||
caption='utility/not_enough_repair_packs_icon',
|
||||
tooltip={'tasklist.tooltip'},
|
||||
draw=function(frame)
|
||||
frame.caption = ''
|
||||
local title = frame.add{
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
title.add{
|
||||
type='label',
|
||||
caption={'tasklist.name'},
|
||||
style='caption_label'
|
||||
}
|
||||
local data = _global()
|
||||
local player = Game.get_player(frame.player_index)
|
||||
local rank = Ranking.get_rank(player)
|
||||
if rank:allowed('edit-tasklist') then
|
||||
if not data._edit[player.index] then data._edit[player.index] = table.deepcopy(data._base) end
|
||||
end
|
||||
for i,task in pairs(_tasks(player)) do
|
||||
local flow = frame.add{
|
||||
name=i,
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
local text_flow = flow.add{
|
||||
name='text_flow',
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
text_flow.add{
|
||||
name='input',
|
||||
type='label',
|
||||
caption=task
|
||||
}
|
||||
local button_flow = flow.add{
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
if rank:allowed('edit-tasklist') then
|
||||
_edit(button_flow)
|
||||
if data._edit[player.index]._editing[i] then
|
||||
local element = remove:draw(button_flow)
|
||||
element.style.height = 30
|
||||
element.style.width = 30
|
||||
local _element = add:draw(button_flow)
|
||||
_element.style.height = 30
|
||||
_element.style.width = 30
|
||||
end
|
||||
end
|
||||
end
|
||||
if rank:allowed('edit-tasklist') then
|
||||
local flow = title.add{
|
||||
name=#_tasks(player),
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
local button_flow = flow.add{
|
||||
type='flow',
|
||||
direction='horizontal'
|
||||
}
|
||||
local element = add:draw(button_flow)
|
||||
element.style.height = 20
|
||||
element.style.width = 20
|
||||
end
|
||||
if #_tasks(player) == 0 and not rank:allowed('edit-tasklist') then frame.style.visible = false end
|
||||
end,
|
||||
can_open=function(player)
|
||||
local rank = Ranking.get_rank(player)
|
||||
if rank:allowed('edit-tasklist') or #_global().tasks > 0 then return true
|
||||
else return {'tasklist.none'} end
|
||||
end,
|
||||
open_on_join=true
|
||||
}
|
||||
237
to convert/Addons/Guis/warp-system.lua
Normal file
237
to convert/Addons/Guis/warp-system.lua
Normal file
@@ -0,0 +1,237 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
local warp_tiles = {
|
||||
{-3,-2},{-3,-1},{-3,0},{-3,1},{-3,2},{3,-2},{3,-1},{3,0},{3,1},{3,2},
|
||||
{-2,-3},{-1,-3},{0,-3},{1,-3},{2,-3},{-2,3},{-1,3},{0,3},{1,3},{2,3}
|
||||
}
|
||||
|
||||
local warp_entities = {
|
||||
{'small-lamp',-3,-2},{'small-lamp',-3,2},{'small-lamp',3,-2},{'small-lamp',3,2},
|
||||
{'small-lamp',-2,-3},{'small-lamp',2,-3},{'small-lamp',-2,3},{'small-lamp',2,3},
|
||||
{'small-electric-pole',-3,-3},{'small-electric-pole',3,3},{'small-electric-pole',-3,3},{'small-electric-pole',3,-3}
|
||||
}
|
||||
|
||||
local warp_radius = 4
|
||||
local spawn_warp_scale = 5
|
||||
local warp_tile = 'tutorial-grid'
|
||||
local warp_limit = 60
|
||||
local warp_item = 'discharge-defense-equipment'
|
||||
local global_offset = {x=0,y=0}
|
||||
|
||||
local function _warps(reset)
|
||||
global.addons = not reset and global.addons or {}
|
||||
global.addons.warps = not reset and global.addons.warps or {warps={},cooldowns={}}
|
||||
return global.addons.warps
|
||||
end
|
||||
|
||||
local function remove_warp_point(name)
|
||||
local warp = _warps().warps[name]
|
||||
if not warp then return end
|
||||
local surface = warp.surface
|
||||
local offset = warp.position
|
||||
local tiles = {}
|
||||
local tiles = {}
|
||||
for x = -warp_radius-2, warp_radius+2 do
|
||||
for y = -warp_radius-2, warp_radius+2 do
|
||||
if x^2+y^2 < (warp_radius+1)^2 then
|
||||
table.insert(tiles,{name=warp.old_tile,position={x+offset.x,y+offset.y}})
|
||||
local entities = surface.find_entities_filtered{area={{x+offset.x-1,y+offset.y-1},{x+offset.x,y+offset.y}}}
|
||||
for _,entity in pairs(entities) do if entity.name ~= 'player' then entity.destroy() end end
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
if warp.tag.valid then warp.tag.destroy() end
|
||||
_warps().warps[name] = nil
|
||||
Gui.left.update('warp-list')
|
||||
end
|
||||
|
||||
local function make_warp_point(position,surface,force,name)
|
||||
local warp = _warps().warps[name]
|
||||
if warp then return end; warp = nil
|
||||
local offset = {x=math.floor(position.x),y=math.floor(position.y)}
|
||||
local old_tile = surface.get_tile(offset).name
|
||||
local base_tiles = {}
|
||||
local tiles = {}
|
||||
-- this makes a base plate to make the warp point
|
||||
for x = -warp_radius-2, warp_radius+2 do
|
||||
for y = -warp_radius-2, warp_radius+2 do
|
||||
if x^2+y^2 < warp_radius^2 then
|
||||
table.insert(base_tiles,{name=warp_tile,position={x+offset.x,y+offset.y}})
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(base_tiles)
|
||||
-- this adds the patern and entities
|
||||
for _,position in pairs(warp_tiles) do
|
||||
table.insert(tiles,{name=warp_tile,position={position[1]+offset.x+global_offset.x,position[2]+offset.y+global_offset.y}})
|
||||
end
|
||||
surface.set_tiles(tiles)
|
||||
for _,entity in pairs(warp_entities) do
|
||||
local entity = surface.create_entity{name=entity[1],position={entity[2]+offset.x+global_offset.x,entity[3]+offset.y+global_offset.y},force='neutral'}
|
||||
entity.destructible = false; entity.health = 0; entity.minable = false; entity.rotatable = false
|
||||
end
|
||||
local tag = force.add_chart_tag(surface,{
|
||||
position={offset.x+0.5,offset.y+0.5},
|
||||
text='Warp: '..name,
|
||||
icon={type='item',name=warp_item}
|
||||
})
|
||||
_warps().warps[name] = {tag=tag,surface=surface,position=tag.position,old_tile=old_tile}
|
||||
local _temp = {Spawn=_warps().warps.Spawn}
|
||||
_warps().warps.Spawn = nil
|
||||
for name,data in pairs(table.keysort(_warps().warps)) do _temp[name] = data end
|
||||
_warps().warps = _temp
|
||||
Gui.left.update('warp-list')
|
||||
end
|
||||
|
||||
commands.add_command('make-warp', 'Make a warp point at your location', {'name',true}, function(event,args)
|
||||
if not game.player then return end
|
||||
local position = game.player.position
|
||||
local name = args.name
|
||||
if game.player.gui.top[name] then player_return({'warp-system.name-used'},defines.text_color.med) return commands.error end
|
||||
if _warps().warps[name] then player_return({'warp-system.name-used'},defines.text_color.med) return commands.error end
|
||||
if position.x^2 + position.y^2 < 100 then player_return({'warp-system.too-close'},defines.text_color.med) return commands.error end
|
||||
-- to do add a test for all warps
|
||||
make_warp_point(position,game.player.surface,game.player.force,name)
|
||||
end)
|
||||
|
||||
local remove_warp = Gui.inputs.add{
|
||||
type='button',
|
||||
name='remove-warp-point',
|
||||
caption='utility/remove',
|
||||
tooltip={'warp-system.remove-tooltip'}
|
||||
}:on_event('click',function(event)
|
||||
local name = event.element.parent.name
|
||||
remove_warp_point(name)
|
||||
end)
|
||||
|
||||
local go_to_warp = Gui.inputs.add{
|
||||
type='button',
|
||||
name='go-to-warp-point',
|
||||
caption='utility/export_slot',
|
||||
tooltip={'warp-system.go-to-tooltip'}
|
||||
}:on_event('click',function(event)
|
||||
local player = Game.get_player(event)
|
||||
local cooldown = _warps().cooldowns[event.player_index] or 0
|
||||
local warp = _warps().warps[event.element.parent.name]
|
||||
if cooldown > 0 then player_return({'warp-system.cooldown',cooldown},nil,event) return end
|
||||
if player.vehicle then player.vehicle.set_driver(nil) end
|
||||
if player.vehicle then player.vehicle.set_passenger(nil) end
|
||||
if player.vehicle then return end
|
||||
player.teleport(warp.surface.find_non_colliding_position('player',warp.position,32,1),warp.surface)
|
||||
if not Ranking.get_rank(player):allowed('always-warp') then
|
||||
event.element.parent.parent.parent.parent.style.visible = false
|
||||
_warps().cooldowns[event.player_index] = warp_limit
|
||||
end
|
||||
end)
|
||||
|
||||
Gui.left.add{
|
||||
name='warp-list',
|
||||
caption='item/'..warp_item,
|
||||
tooltip={'warp-system.tooltip'},
|
||||
draw=function(frame)
|
||||
local player = Game.get_player(frame.player_index)
|
||||
frame.caption={'warp-system.name'}
|
||||
local warp_list = frame.add{
|
||||
type='scroll-pane',
|
||||
direction='vertical',
|
||||
vertical_scroll_policy='auto',
|
||||
horizontal_scroll_policy='never'
|
||||
}
|
||||
warp_list.vertical_scroll_policy = 'auto'
|
||||
warp_list.style.maximal_height = 150
|
||||
local table = warp_list.add{
|
||||
type='table',
|
||||
column_count=2
|
||||
}
|
||||
for name,warp in pairs(_warps().warps) do
|
||||
if not warp.tag or not warp.tag.valid then
|
||||
player.force.add_chart_tag(warp.surface,{
|
||||
position=warp.position,
|
||||
text='Warp: '..name,
|
||||
icon={type='item',name=warp_item}
|
||||
})
|
||||
end
|
||||
table.add{
|
||||
type='label',
|
||||
caption=name,
|
||||
style='caption_label'
|
||||
}
|
||||
local _flow = table.add{
|
||||
type='flow',
|
||||
name=name
|
||||
}
|
||||
local btn = go_to_warp:draw(_flow)
|
||||
btn.style.height = 20
|
||||
btn.style.width = 20
|
||||
if Ranking.get_rank(player):allowed('make-warp') and name ~= 'Spawn' then
|
||||
local btn = remove_warp:draw(_flow)
|
||||
btn.style.height = 20
|
||||
btn.style.width = 20
|
||||
end
|
||||
end
|
||||
local cooldown = _warps().cooldowns[player.index] or 0
|
||||
if cooldown > 0 then frame.style.visible = false return
|
||||
elseif Ranking.get_rank(player):allowed('always-warp') then return
|
||||
elseif player.surface.get_tile(player.position).name == warp_tile
|
||||
and player.surface.name == 'nauvis'
|
||||
then return
|
||||
elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then return
|
||||
else frame.style.visible = false end
|
||||
end,
|
||||
can_open=function(player)
|
||||
local cooldown = _warps().cooldowns[player.index] or 0
|
||||
if Ranking.get_rank(player):allowed('always-warp') then return true
|
||||
elseif player.surface.get_tile(player.position).name == warp_tile
|
||||
and player.surface.name == 'nauvis'
|
||||
then return true
|
||||
elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then return true
|
||||
elseif cooldown > 0 then return {'warp-system.cooldown',cooldown}
|
||||
else return {'warp-system.not-on-warp'} end
|
||||
end,
|
||||
open_on_join=true
|
||||
}
|
||||
|
||||
Event.register(defines.events.on_tick,function(event)
|
||||
if not (event.tick % 60 == 0) then return end
|
||||
for index,time in pairs(_warps().cooldowns) do
|
||||
if time > 0 then
|
||||
_warps().cooldowns[index] = time-1
|
||||
if _warps().cooldowns[index] == 0 then player_return({'warp-system.cooldown-zero'},defines.text_color.low,index) end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_changed_position, function(event)
|
||||
local player = Game.get_player(event)
|
||||
local cooldown = _warps().cooldowns[player.index] or 0
|
||||
local tile = player.surface.get_tile(player.position).name
|
||||
if not Ranking.get_rank(player):allowed('always-warp') and cooldown == 0 then
|
||||
if tile == warp_tile and player.surface.name == 'nauvis' then
|
||||
mod_gui.get_frame_flow(player)['warp-list'].style.visible = true
|
||||
elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then
|
||||
mod_gui.get_frame_flow(player)['warp-list'].style.visible = true
|
||||
else mod_gui.get_frame_flow(player)['warp-list'].style.visible = false end
|
||||
end
|
||||
end)
|
||||
|
||||
Event.register(defines.events.on_player_created, function(event)
|
||||
if event.player_index == 1 then
|
||||
local player = Game.get_player(event)
|
||||
player.force.chart(player.surface, {{player.position.x - 20, player.position.y - 20}, {player.position.x + 20, player.position.y + 20}})
|
||||
local tag = player.force.add_chart_tag(player.surface,{
|
||||
position={0,0},
|
||||
text='Warp: Spawn',
|
||||
icon={type='item',name=warp_item}
|
||||
})
|
||||
_warps().warps['Spawn'] = {tag=tag,surface=player.surface,position={0,0}}
|
||||
end
|
||||
end)
|
||||
49
to convert/Addons/load.lua
Normal file
49
to convert/Addons/load.lua
Normal file
@@ -0,0 +1,49 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
-- This file just contains all the diffrent requires
|
||||
|
||||
-- Admin dir
|
||||
verbose('Begain Admin Loading')
|
||||
require('Admin/player-info')
|
||||
require('Admin/admin') -- Used with Guis/admin-gui, but can work without
|
||||
require('Admin/reports') -- This adds onto Admin/admin, adds report command and warnings, and temp ban
|
||||
require('Admin/discord')
|
||||
require('Admin/auto-message')
|
||||
require('Admin/tree-decon')
|
||||
require('Admin/inventory-search')
|
||||
require('Admin/base-damage')
|
||||
require('Admin/afk-kick')
|
||||
require('Admin/auto-chat')
|
||||
|
||||
-- Commands dir
|
||||
verbose('Begain Command Loading')
|
||||
require('Commands/cheat-mode')
|
||||
require('Commands/kill')
|
||||
require('Commands/repair')
|
||||
require('Commands/bonus')
|
||||
require('Commands/tags')
|
||||
require('Commands/home')
|
||||
require('Commands/tp') -- Requires Admin/admin
|
||||
require('Commands/admin') -- Requires Admin/reports
|
||||
|
||||
-- GUIs dir
|
||||
verbose('Begain Gui Loading')
|
||||
require('Guis/readme')
|
||||
require('Guis/science')
|
||||
require('Guis/rockets')
|
||||
require('Guis/player-list')
|
||||
require('Guis/tasklist')
|
||||
require('Guis/warp-system')
|
||||
require('Guis/polls') -- Too many desyncs
|
||||
require('Guis/announcements')
|
||||
require('Guis/rank-changer')
|
||||
require('Guis/admin-gui') -- Used with Admin/admin, requires Admin/admin
|
||||
require('Guis/reports') -- Requires Admin/reports
|
||||
require('Guis/game-settings')
|
||||
224
to convert/Addons/playerRanks.lua
Normal file
224
to convert/Addons/playerRanks.lua
Normal file
@@ -0,0 +1,224 @@
|
||||
--[[
|
||||
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/r6dC2uK
|
||||
]]
|
||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||
|
||||
--[[
|
||||
How to use groups:
|
||||
name The name that you can use to reference it.
|
||||
disallow If present then all ranks in this group will have this added to their disallow.
|
||||
allow If present then all ranks in this group will have this added to their allow.
|
||||
highest Assigned by the script to show the highest rank in this group.
|
||||
lowest Assigned by the script to show the lowest rank in this group.
|
||||
How to add ranks:
|
||||
Name What will be used in the scripts and is often the best choice for display in text.
|
||||
short_hand What can be used when short on space but the rank still need to be displayed.
|
||||
tag The tag the player will gain when moved to the rank, it can be nil.
|
||||
time Used for auto-rank feature where you are moved to the rank after a certain play time in minutes.
|
||||
colour The RGB value that can be used to emphasise GUI elements based on rank.
|
||||
power Assigned by the script based on their index in ranks, you can insert new ranks between current ones.
|
||||
group Assigned by the script to show the group this rank is in.
|
||||
disallow A list containing input actions that the user can not perform.
|
||||
allow A list of custom commands and effects that that rank can use, all defined in the scripts.
|
||||
|
||||
For allow, add the allow as the key and the value as true
|
||||
Example: test for 'server-interface' => allow['server-interface'] = true
|
||||
|
||||
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
|
||||
--]]
|
||||
|
||||
-- See ExpCore/ranks.lua for examples - you add your own and edit pre-made ones here.
|
||||
|
||||
local groups = Ranking._groups(true)
|
||||
|
||||
groups['Root']:edit('allow',false,{
|
||||
['player-list']=true,
|
||||
['readme']=true,
|
||||
['rockets']=true,
|
||||
['science']=true,
|
||||
['tasklist']=true,
|
||||
['rank-changer']=true,
|
||||
['admin-commands']=true,
|
||||
['warn']=true,
|
||||
['temp-ban']=true,
|
||||
['clear-warings']=true,
|
||||
['clear-reports']=true,
|
||||
['clear-all']=true,
|
||||
['clear-inv']=true,
|
||||
['announcements']=true,
|
||||
['warp-list']=true,
|
||||
['polls']=true,
|
||||
['admin-items']=true,
|
||||
['all-items']=true,
|
||||
['repair']=true,
|
||||
['global-chat']=true
|
||||
})
|
||||
groups['Admin']:edit('allow',false,{
|
||||
['player-list']=true,
|
||||
['readme']=true,
|
||||
['rockets']=true,
|
||||
['science']=true,
|
||||
['tasklist']=true,
|
||||
['rank-changer']=true,
|
||||
['admin-commands']=true,
|
||||
['warn']=true,
|
||||
['temp-ban']=true,
|
||||
['clear-warings']=true,
|
||||
['clear-reports']=true,
|
||||
['clear-all']=true,
|
||||
['clear-inv']=true,
|
||||
['announcements']=true,
|
||||
['warp-list']=true,
|
||||
['polls']=true,
|
||||
['global-chat']=true
|
||||
})
|
||||
groups['User']:edit('allow',false,{
|
||||
['player-list']=true,
|
||||
['readme']=true,
|
||||
['rockets']=true,
|
||||
['science']=true,
|
||||
['tasklist']=true,
|
||||
['report']=true,
|
||||
['warp-list']=true,
|
||||
['polls']=true
|
||||
})
|
||||
groups['Jail']:edit('allow',false,{
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
groups['Root']:add_rank{
|
||||
name='Owner',
|
||||
short_hand='Owner',
|
||||
tag='[Owner]',
|
||||
time=nil,
|
||||
colour={r=170,g=0,b=0},
|
||||
is_admin = true,
|
||||
is_spectator=true,
|
||||
base_afk_time=false
|
||||
}
|
||||
groups['Root']:add_rank{
|
||||
name='Community Manager',
|
||||
short_hand='Com Mngr',
|
||||
tag='[Com Mngr]',
|
||||
colour={r=150,g=68,b=161},
|
||||
is_admin = true,
|
||||
is_spectator=true,
|
||||
base_afk_time=false
|
||||
}
|
||||
groups['Root']:add_rank{
|
||||
name='Developer',
|
||||
short_hand='Dev',
|
||||
tag='[Dev]',
|
||||
colour={r=179,g=125,b=46},
|
||||
is_admin = true,
|
||||
is_spectator=true,
|
||||
base_afk_time=false
|
||||
}
|
||||
|
||||
groups['Admin']:add_rank{
|
||||
name='Mod',
|
||||
short_hand='Mod',
|
||||
tag='[Mod]',
|
||||
colour={r=0,g=170,b=0},
|
||||
disallow={
|
||||
'server_command'
|
||||
},
|
||||
is_admin = true,
|
||||
is_spectator=true,
|
||||
base_afk_time=false
|
||||
}
|
||||
|
||||
groups['User']:add_rank{
|
||||
name='Donator',
|
||||
short_hand='P2W',
|
||||
tag='[P2W]',
|
||||
colour={r=233,g=63,b=233},
|
||||
power=0,
|
||||
is_spectator=true,
|
||||
base_afk_time=120
|
||||
}
|
||||
groups['User']:add_rank{
|
||||
name='Veteran',
|
||||
short_hand='Vet',
|
||||
tag='[Veteran]',
|
||||
time=600,
|
||||
colour={r=140,g=120,b=200},
|
||||
power=1,
|
||||
base_afk_time=60
|
||||
}
|
||||
groups['User']:add_rank{
|
||||
name='Regular',
|
||||
short_hand='Reg',
|
||||
tag='[Regular]',
|
||||
time=180,
|
||||
colour={r=24,g=172,b=188},
|
||||
power=3,
|
||||
base_afk_time=30
|
||||
}
|
||||
|
||||
local ranks = Ranking._ranks(true)
|
||||
|
||||
ranks['Developer']:edit('allow',false,{
|
||||
['cheat-mode']=true
|
||||
})
|
||||
|
||||
ranks['Admin']:edit('allow',false,{
|
||||
['game-settings']=true,
|
||||
['always-warp']=true,
|
||||
['admin-items']=true
|
||||
})
|
||||
ranks['Mod']:edit('allow',false,{
|
||||
['go-to']=true,
|
||||
['bring']=true,
|
||||
['no-report']=true
|
||||
})
|
||||
|
||||
ranks['Donator']:edit('allow',false,{
|
||||
['global-chat']=true,
|
||||
['jail']=true,
|
||||
['unjail']=true,
|
||||
['set-home']=true,
|
||||
['home']=true,
|
||||
['return']=true,
|
||||
['bonus']=true,
|
||||
['bonus-respawn']=true
|
||||
})
|
||||
ranks['Veteran']:edit('allow',false,{
|
||||
['tree-decon']=true,
|
||||
['create-poll']=true,
|
||||
['repair']=true
|
||||
})
|
||||
ranks['Member']:edit('allow',false,{
|
||||
['edit-tasklist']=true,
|
||||
['make-warp']=true,
|
||||
['nuke']=true,
|
||||
['base-damage']=true,
|
||||
['varified']=true
|
||||
})
|
||||
ranks['Regular']:edit('allow',false,{
|
||||
['kill']=true,
|
||||
['decon']=true,
|
||||
['capsules']=true
|
||||
})
|
||||
ranks['Guest']:edit('allow',false,{
|
||||
['tag']=true,
|
||||
['tag-clear']=true,
|
||||
['report']=true
|
||||
})
|
||||
|
||||
Ranking._base_preset{
|
||||
['badgamernl']='Owner',
|
||||
['arty714']='Community Manager',
|
||||
['cooldude2606']='Developer',
|
||||
['mark9064']='Admin',
|
||||
['propangaseddy']='Admin'
|
||||
}
|
||||
Reference in New Issue
Block a user