1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00

minor tweaks

This commit is contained in:
Gerkiz 2020-08-26 11:08:12 +02:00
parent 834770cea2
commit b5990868e4
11 changed files with 283 additions and 224 deletions

View File

@ -172,8 +172,8 @@ local antigrief_functions = {
local fortress_functions = { local fortress_functions = {
['comfy_panel_disable_fullness'] = function(event) ['comfy_panel_disable_fullness'] = function(event)
local WPT = package.loaded['maps.mountain_fortress_v3.table'] local Fullness = package.loaded['modules.check_fullness']
local this = WPT.get() local this = Fullness.get()
if event.element.switch_state == 'left' then if event.element.switch_state == 'left' then
this.fullness_enabled = true this.fullness_enabled = true
get_actor(event, '{Fullness}', 'has enabled the inventory fullness function.') get_actor(event, '{Fullness}', 'has enabled the inventory fullness function.')
@ -432,10 +432,11 @@ local build_config_gui = (function(player, frame)
label.style.horizontal_align = 'left' label.style.horizontal_align = 'left'
label.style.vertical_align = 'bottom' label.style.vertical_align = 'bottom'
label.style.font_color = Color.green label.style.font_color = Color.green
local WPT = package.loaded['maps.mountain_fortress_v3.table']
local this = WPT.get() local Fullness = package.loaded['modules.check_fullness']
local full = Fullness.get()
switch_state = 'right' switch_state = 'right'
if this.fullness_enabled then if full.fullness_enabled then
switch_state = 'left' switch_state = 'left'
end end
add_switch( add_switch(
@ -448,6 +449,8 @@ local build_config_gui = (function(player, frame)
scroll_pane.add({type = 'line'}) scroll_pane.add({type = 'line'})
local WPT = package.loaded['maps.mountain_fortress_v3.table']
local this = WPT.get()
switch_state = 'right' switch_state = 'right'
if this.offline_players_enabled then if this.offline_players_enabled then
switch_state = 'left' switch_state = 'left'

View File

@ -7,11 +7,11 @@ commands.add_command(
'spaghetti', 'spaghetti',
'Does spaghett.', 'Does spaghett.',
function(cmd) function(cmd)
local p_modifer = Modifiers.get_table() local p_modifer = Modifiers.get_table()
local player = game.player local player = game.player
local _a = p_modifer local _a = p_modifer
local param = tostring(cmd.parameter) local param = tostring(cmd.parameter)
local force = game.forces["player"] local force = game.forces['player']
local p local p
if player then if player then
@ -21,82 +21,92 @@ commands.add_command(
p("[ERROR] You're not admin!", Color.fail) p("[ERROR] You're not admin!", Color.fail)
return return
end end
else else
p = log p = log
end end
end end
if param == nil then player.print("[ERROR] Arguments are true/false", Color.yellow) return end if param == nil then
if param == "true" then player.print('[ERROR] Arguments are true/false', Color.yellow)
if not _a.spaghetti_are_you_sure then return
_a.spaghetti_are_you_sure = true end
player.print("Spaghetti is not enabled, run this command again to enable spaghett", Color.yellow) if param == 'true' then
return if not _a.spaghetti_are_you_sure then
end _a.spaghetti_are_you_sure = true
if _a.spaghetti_enabled == true then player.print("Spaghetti is already enabled.", Color.yellow) return end player.print('Spaghetti is not enabled, run this command again to enable spaghett', Color.yellow)
game.print("The world has been spaghettified!", Color.success) return
force.technologies["logistic-system"].enabled = false end
force.technologies["construction-robotics"].enabled = false if _a.spaghetti_enabled == true then
force.technologies["logistic-robotics"].enabled = false player.print('Spaghetti is already enabled.', Color.yellow)
force.technologies["robotics"].enabled = false return
force.technologies["personal-roboport-equipment"].enabled = false end
force.technologies["personal-roboport-mk2-equipment"].enabled = false game.print('The world has been spaghettified!', Color.success)
force.technologies["character-logistic-trash-slots-1"].enabled = false force.technologies['logistic-system'].enabled = false
force.technologies["character-logistic-trash-slots-2"].enabled = false force.technologies['construction-robotics'].enabled = false
force.technologies["auto-character-logistic-trash-slots"].enabled = false force.technologies['logistic-robotics'].enabled = false
force.technologies["worker-robots-storage-1"].enabled = false force.technologies['robotics'].enabled = false
force.technologies["worker-robots-storage-2"].enabled = false force.technologies['personal-roboport-equipment'].enabled = false
force.technologies["worker-robots-storage-3"].enabled = false force.technologies['personal-roboport-mk2-equipment'].enabled = false
force.technologies["character-logistic-slots-1"].enabled = false force.technologies['character-logistic-trash-slots-1'].enabled = false
force.technologies["character-logistic-slots-2"].enabled = false force.technologies['character-logistic-trash-slots-2'].enabled = false
force.technologies["character-logistic-slots-3"].enabled = false force.technologies['auto-character-logistic-trash-slots'].enabled = false
force.technologies["character-logistic-slots-4"].enabled = false force.technologies['worker-robots-storage-1'].enabled = false
force.technologies["character-logistic-slots-5"].enabled = false force.technologies['worker-robots-storage-2'].enabled = false
force.technologies["character-logistic-slots-6"].enabled = false force.technologies['worker-robots-storage-3'].enabled = false
force.technologies["worker-robots-speed-1"].enabled = false force.technologies['character-logistic-slots-1'].enabled = false
force.technologies["worker-robots-speed-2"].enabled = false force.technologies['character-logistic-slots-2'].enabled = false
force.technologies["worker-robots-speed-3"].enabled = false force.technologies['character-logistic-slots-3'].enabled = false
force.technologies["worker-robots-speed-4"].enabled = false force.technologies['character-logistic-slots-4'].enabled = false
force.technologies["worker-robots-speed-5"].enabled = false force.technologies['character-logistic-slots-5'].enabled = false
force.technologies["worker-robots-speed-6"].enabled = false force.technologies['character-logistic-slots-6'].enabled = false
_a.spaghetti_enabled = true force.technologies['worker-robots-speed-1'].enabled = false
elseif param == "false" then force.technologies['worker-robots-speed-2'].enabled = false
if _a.spaghetti_enabled == false or _a.spaghetti_enabled == nil then player.print("Spaghetti is already disabled.", Color.yellow) return end force.technologies['worker-robots-speed-3'].enabled = false
game.print("The world is no longer spaghett!", Color.yellow) force.technologies['worker-robots-speed-4'].enabled = false
force.technologies["logistic-system"].enabled = true force.technologies['worker-robots-speed-5'].enabled = false
force.technologies["construction-robotics"].enabled = true force.technologies['worker-robots-speed-6'].enabled = false
force.technologies["logistic-robotics"].enabled = true _a.spaghetti_enabled = true
force.technologies["robotics"].enabled = true elseif param == 'false' then
force.technologies["personal-roboport-equipment"].enabled = true if _a.spaghetti_enabled == false or _a.spaghetti_enabled == nil then
force.technologies["personal-roboport-mk2-equipment"].enabled = true player.print('Spaghetti is already disabled.', Color.yellow)
force.technologies["character-logistic-trash-slots-1"].enabled = true return
force.technologies["character-logistic-trash-slots-2"].enabled = true end
force.technologies["auto-character-logistic-trash-slots"].enabled = true game.print('The world is no longer spaghett!', Color.yellow)
force.technologies["worker-robots-storage-1"].enabled = true force.technologies['logistic-system'].enabled = true
force.technologies["worker-robots-storage-2"].enabled = true force.technologies['construction-robotics'].enabled = true
force.technologies["worker-robots-storage-3"].enabled = true force.technologies['logistic-robotics'].enabled = true
force.technologies["character-logistic-slots-1"].enabled = true force.technologies['robotics'].enabled = true
force.technologies["character-logistic-slots-2"].enabled = true force.technologies['personal-roboport-equipment'].enabled = true
force.technologies["character-logistic-slots-3"].enabled = true force.technologies['personal-roboport-mk2-equipment'].enabled = true
force.technologies["character-logistic-slots-4"].enabled = true force.technologies['character-logistic-trash-slots-1'].enabled = true
force.technologies["character-logistic-slots-5"].enabled = true force.technologies['character-logistic-trash-slots-2'].enabled = true
force.technologies["character-logistic-slots-6"].enabled = true force.technologies['auto-character-logistic-trash-slots'].enabled = true
force.technologies["worker-robots-speed-1"].enabled = true force.technologies['worker-robots-storage-1'].enabled = true
force.technologies["worker-robots-speed-2"].enabled = true force.technologies['worker-robots-storage-2'].enabled = true
force.technologies["worker-robots-speed-3"].enabled = true force.technologies['worker-robots-storage-3'].enabled = true
force.technologies["worker-robots-speed-4"].enabled = true force.technologies['character-logistic-slots-1'].enabled = true
force.technologies["worker-robots-speed-5"].enabled = true force.technologies['character-logistic-slots-2'].enabled = true
force.technologies["worker-robots-speed-6"].enabled = true force.technologies['character-logistic-slots-3'].enabled = true
_a.spaghetti_enabled = false force.technologies['character-logistic-slots-4'].enabled = true
end force.technologies['character-logistic-slots-5'].enabled = true
end) force.technologies['character-logistic-slots-6'].enabled = true
force.technologies['worker-robots-speed-1'].enabled = true
force.technologies['worker-robots-speed-2'].enabled = true
force.technologies['worker-robots-speed-3'].enabled = true
force.technologies['worker-robots-speed-4'].enabled = true
force.technologies['worker-robots-speed-5'].enabled = true
force.technologies['worker-robots-speed-6'].enabled = true
_a.spaghetti_enabled = false
end
end
)
commands.add_command( commands.add_command(
'generate_map', 'generate_map',
'Pregenerates map.', 'Pregenerates map.',
function(cmd) function(cmd)
local p_modifer = Modifiers.get_table() local p_modifer = Modifiers.get_table()
local _a = p_modifer local _a = p_modifer
local player = game.player local player = game.player
local param = tonumber(cmd.parameter) local param = tonumber(cmd.parameter)
local p local p
@ -108,40 +118,50 @@ commands.add_command(
p("[ERROR] You're not admin!", Color.fail) p("[ERROR] You're not admin!", Color.fail)
return return
end end
else else
p = log p = log
end end
end
if param == nil then
player.print('[ERROR] Must specify radius!', Color.fail)
return
end
if param > 50 then
player.print('[ERROR] Value is too big.', Color.fail)
return
end end
if param == nil then player.print("[ERROR] Must specify radius!", Color.fail) return end
if param > 50 then player.print("[ERROR] Value is too big.", Color.fail) return end
if not _a.generate_map then if not _a.generate_map then
_a.generate_map = true _a.generate_map = true
player.print("[WARNING] This command will make the server LAG, run this command again if you really want to do this!", Color.yellow) player.print(
'[WARNING] This command will make the server LAG, run this command again if you really want to do this!',
Color.yellow
)
return return
end end
local radius = param local radius = param
local surface = game.players[1].surface local surface = game.players[1].surface
if surface.is_chunk_generated({radius, radius}) then if surface.is_chunk_generated({radius, radius}) then
game.print("Map generation done!", Color.success) game.print('Map generation done!', Color.success)
_a.generate_map = nil _a.generate_map = nil
return return
end end
surface.request_to_generate_chunks({0,0}, radius) surface.request_to_generate_chunks({0, 0}, radius)
surface.force_generate_chunk_requests() surface.force_generate_chunk_requests()
for _, pl in pairs(game.connected_players) do for _, pl in pairs(game.connected_players) do
pl.play_sound{path="utility/new_objective", volume_modifier=1} pl.play_sound {path = 'utility/new_objective', volume_modifier = 1}
end end
game.print("Map generation done!", Color.success) game.print('Map generation done!', Color.success)
_a.generate_map = nil _a.generate_map = nil
end) end
)
commands.add_command( commands.add_command(
'dump_layout', 'dump_layout',
'Dump the current map-layout.', 'Dump the current map-layout.',
function() function()
local p_modifer = Modifiers.get_table() local p_modifer = Modifiers.get_table()
local _a = p_modifer local _a = p_modifer
local player = game.player local player = game.player
local p local p
@ -152,65 +172,69 @@ commands.add_command(
p("[ERROR] You're not admin!", Color.warning) p("[ERROR] You're not admin!", Color.warning)
return return
end end
else else
p = log p = log
end end
end end
if not _a.dump_layout then if not _a.dump_layout then
_a.dump_layout = true _a.dump_layout = true
player.print("[WARNING] This command will make the server LAG, run this command again if you really want to do this!", Color.yellow) player.print(
'[WARNING] This command will make the server LAG, run this command again if you really want to do this!',
Color.yellow
)
return return
end end
local surface = game.players[1].surface local surface = game.players[1].surface
game.write_file("layout.lua", "" , false) game.write_file('layout.lua', '', false)
local area = { local area = {
left_top = {x = 0, y = 0}, left_top = {x = 0, y = 0},
right_bottom = {x = 32, y = 32} right_bottom = {x = 32, y = 32}
} }
local entities = surface.find_entities_filtered{area = area} local entities = surface.find_entities_filtered {area = area}
local tiles = surface.find_tiles_filtered{area = area} local tiles = surface.find_tiles_filtered {area = area}
for _, e in pairs(entities) do for _, e in pairs(entities) do
local str = "{position = {x = " .. e.position.x local str = '{position = {x = ' .. e.position.x
str = str .. ", y = " str = str .. ', y = '
str = str .. e.position.y str = str .. e.position.y
str = str .. '}, name = "' str = str .. '}, name = "'
str = str .. e.name str = str .. e.name
str = str .. '", direction = ' str = str .. '", direction = '
str = str .. tostring(e.direction) str = str .. tostring(e.direction)
str = str .. ', force = "' str = str .. ', force = "'
str = str .. e.force.name str = str .. e.force.name
str = str .. '"},' str = str .. '"},'
if e.name ~= "character" then if e.name ~= 'character' then
game.write_file("layout.lua", str .. '\n' , true) game.write_file('layout.lua', str .. '\n', true)
end end
end end
game.write_file("layout.lua",'\n' , true) game.write_file('layout.lua', '\n', true)
game.write_file("layout.lua",'\n' , true) game.write_file('layout.lua', '\n', true)
game.write_file("layout.lua",'Tiles: \n' , true) game.write_file('layout.lua', 'Tiles: \n', true)
for _, t in pairs(tiles) do for _, t in pairs(tiles) do
local str = "{position = {x = " .. t.position.x local str = '{position = {x = ' .. t.position.x
str = str .. ", y = " str = str .. ', y = '
str = str .. t.position.y str = str .. t.position.y
str = str .. '}, name = "' str = str .. '}, name = "'
str = str .. t.name str = str .. t.name
str = str .. '"},' str = str .. '"},'
game.write_file("layout.lua", str .. '\n' , true) game.write_file('layout.lua', str .. '\n', true)
player.print("Dumped layout as file: layout.lua", Color.success) player.print('Dumped layout as file: layout.lua', Color.success)
end end
_a.dump_layout = false _a.dump_layout = false
end) end
)
commands.add_command( commands.add_command(
'creative', 'creative',
'Enables creative_mode.', 'Enables creative_mode.',
function() function()
local p_modifer = Modifiers.get_table() local p_modifer = Modifiers.get_table()
local _a = p_modifer local _a = p_modifer
local player = game.player local player = game.player
local p local p
@ -221,54 +245,61 @@ commands.add_command(
p("[ERROR] You're not admin!", Color.fail) p("[ERROR] You're not admin!", Color.fail)
return return
end end
else else
p = log p = log
end end
end end
if not _a.creative_are_you_sure then if not _a.creative_are_you_sure then
_a.creative_are_you_sure = true _a.creative_are_you_sure = true
player.print("[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!", Color.yellow) player.print(
'[WARNING] This command will enable creative/cheat-mode for all connected players, run this command again if you really want to do this!',
Color.yellow
)
return
end
if _a.creative_enabled == true then
player.print('[ERROR] Creative/cheat-mode is already active!', Color.fail)
return return
end end
if _a.creative_enabled == true then player.print("[ERROR] Creative/cheat-mode is already active!", Color.fail) return end
game.print(player.name .. " has activated creative-mode!", Color.warning) game.print(player.name .. ' has activated creative-mode!', Color.warning)
Server.to_discord_bold(table.concat{'[Creative] ' .. player.name .. ' has activated creative-mode!'}) Server.to_discord_bold(table.concat {'[Creative] ' .. player.name .. ' has activated creative-mode!'})
for k, v in pairs(game.connected_players) do for k, v in pairs(game.connected_players) do
v.cheat_mode = true v.cheat_mode = true
v.insert{name="power-armor-mk2", count = 1} v.insert {name = 'power-armor-mk2', count = 1}
if v.character ~= nil then if v.character ~= nil then
local p_armor = v.get_inventory(5)[1].grid local p_armor = v.get_inventory(5)[1].grid
p_armor.put({name = "fusion-reactor-equipment"}) p_armor.put({name = 'fusion-reactor-equipment'})
p_armor.put({name = "fusion-reactor-equipment"}) p_armor.put({name = 'fusion-reactor-equipment'})
p_armor.put({name = "fusion-reactor-equipment"}) p_armor.put({name = 'fusion-reactor-equipment'})
p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = 'exoskeleton-equipment'})
p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = 'exoskeleton-equipment'})
p_armor.put({name = "exoskeleton-equipment"}) p_armor.put({name = 'exoskeleton-equipment'})
p_armor.put({name = "energy-shield-mk2-equipment"}) p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = "energy-shield-mk2-equipment"}) p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = "energy-shield-mk2-equipment"}) p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = "energy-shield-mk2-equipment"}) p_armor.put({name = 'energy-shield-mk2-equipment'})
p_armor.put({name = "personal-roboport-mk2-equipment"}) p_armor.put({name = 'personal-roboport-mk2-equipment'})
p_armor.put({name = "night-vision-equipment"}) p_armor.put({name = 'night-vision-equipment'})
p_armor.put({name = "battery-mk2-equipment"}) p_armor.put({name = 'battery-mk2-equipment'})
p_armor.put({name = "battery-mk2-equipment"}) p_armor.put({name = 'battery-mk2-equipment'})
local item = game.item_prototypes local item = game.item_prototypes
local i = 0 local i = 0
for _k, _v in pairs(item) do for _k, _v in pairs(item) do
i = i + 1 i = i + 1
if _k and _v.type ~= "mining-tool" then if _k and _v.type ~= 'mining-tool' then
_a[k].character_inventory_slots_bonus["creative"] = tonumber(i) _a[k].character_inventory_slots_bonus['creative'] = tonumber(i)
v.character_inventory_slots_bonus = _a[k].character_inventory_slots_bonus["creative"] v.character_inventory_slots_bonus = _a[k].character_inventory_slots_bonus['creative']
v.insert{name=_k, count=_v.stack_size} v.insert {name = _k, count = _v.stack_size}
v.print("Inserted all base items.", Color.success) v.print('Inserted all base items.', Color.success)
_a.creative_enabled = true _a.creative_enabled = true
end end
end end
end end
end end
end) end
)
commands.add_command( commands.add_command(
'clear-corpses', 'clear-corpses',
@ -277,30 +308,37 @@ commands.add_command(
local player = game.player local player = game.player
local trusted = Session.get_trusted_table() local trusted = Session.get_trusted_table()
local param = tonumber(cmd.parameter) local param = tonumber(cmd.parameter)
local p
if player then if not player or not player.valid then
if player ~= nil then return
p = player.print
if not trusted[player.name] then
if not player.admin then
p("[ERROR] Only admins and trusted weebs are allowed to run this command!", Color.fail)
return
end
end
else
p = log
end
end end
if param == nil then player.print("[ERROR] Must specify radius!", Color.fail) return end local p = player.print
if param > 500 then player.print("[ERROR] Value is too big.", Color.fail) return end if not trusted[player.name] then
local pos = player.position if not player.admin then
p('[ERROR] Only admins and trusted weebs are allowed to run this command!', Color.fail)
return
end
end
if param == nil then
player.print('[ERROR] Must specify radius!', Color.fail)
return
end
if param < 0 then
player.print('[ERROR] Value is too low.', Color.fail)
return
end
if param > 500 then
player.print('[ERROR] Value is too big.', Color.fail)
return
end
local pos = player.position
local radius = {{x = (pos.x + -param), y = (pos.y + -param)}, {x = (pos.x + param), y = (pos.y + param)}} local radius = {{x = (pos.x + -param), y = (pos.y + -param)}, {x = (pos.x + param), y = (pos.y + param)}}
for _, entity in pairs(player.surface.find_entities_filtered{area = radius, type = "corpse"}) do for _, entity in pairs(player.surface.find_entities_filtered {area = radius, type = 'corpse'}) do
if entity.corpse_expires then if entity.corpse_expires then
entity.destroy() entity.destroy()
end end
end end
player.print("Cleared biter-corpses.", Color.success) player.print('Cleared biter-corpses.', Color.success)
end) end
)

View File

@ -1010,6 +1010,7 @@ local on_player_or_robot_built_tile = function(event)
end end
end end
Event.add_event_filter(defines.events.on_entity_damaged, {filter = 'final-damage-amount', comparison = '>', value = 0})
Event.add(defines.events.on_entity_damaged, on_entity_damaged) Event.add(defines.events.on_entity_damaged, on_entity_damaged)
Event.add(defines.events.on_player_repaired_entity, on_player_repaired_entity) Event.add(defines.events.on_player_repaired_entity, on_player_repaired_entity)
Event.add(defines.events.on_player_mined_entity, on_player_mined_entity) Event.add(defines.events.on_player_mined_entity, on_player_mined_entity)

View File

@ -55,9 +55,6 @@ function Public.explosive_bullets(event)
if not weapon.valid_for_read or not ammo.valid_for_read then if not weapon.valid_for_read or not ammo.valid_for_read then
return return
end end
if weapon.name ~= 'pistol' then
return
end
if if
ammo.name ~= 'firearm-magazine' and ammo.name ~= 'piercing-rounds-magazine' and ammo.name ~= 'firearm-magazine' and ammo.name ~= 'piercing-rounds-magazine' and
ammo.name ~= 'uranium-rounds-magazine' ammo.name ~= 'uranium-rounds-magazine'

View File

@ -222,7 +222,7 @@ end
local function is_around_train(data) local function is_around_train(data)
local entity = data.entity local entity = data.entity
local aura = 60 local aura = data.aura + 20
local loco = data.locomotive.position local loco = data.locomotive.position
local area = { local area = {
left_top = {x = loco.x - aura, y = loco.y - aura}, left_top = {x = loco.x - aura, y = loco.y - aura},
@ -1630,11 +1630,13 @@ function Public.is_around_train(entity)
end end
local surface = game.surfaces[active_surface_index] local surface = game.surfaces[active_surface_index]
local aura = WPT.get('locomotive_xp_aura')
local data = { local data = {
locomotive = locomotive, locomotive = locomotive,
surface = surface, surface = surface,
entity = entity entity = entity,
aura = aura
} }
local success = is_around_train(data) local success = is_around_train(data)

View File

@ -1,4 +1,5 @@
local Server = require 'utils.server' local Server = require 'utils.server'
local Session = require 'utils.datastore.session_data'
local Modifers = require 'player_modifiers' local Modifers = require 'player_modifiers'
local WPT = require 'maps.mountain_fortress_v3.table' local WPT = require 'maps.mountain_fortress_v3.table'
@ -50,6 +51,7 @@ local function equip_players(player_starting_items, data)
end end
else else
data.players[player.index] = nil data.players[player.index] = nil
Session.clear_player(player)
game.remove_offline_players({player.index}) game.remove_offline_players({player.index})
end end
end end

View File

@ -55,6 +55,14 @@ function Public.enable_fullness(value)
return this.fullness_enabled return this.fullness_enabled
end end
function Public.get(key)
if key then
return this[key]
else
return this
end
end
local check_fullness = Public.check_fullness local check_fullness = Public.check_fullness
Event.add( Event.add(

View File

@ -155,9 +155,9 @@ local function poll_difficulty(player)
b.style.font = 'heading-2' b.style.font = 'heading-2'
b.style.minimal_width = 160 b.style.minimal_width = 160
b.tooltip = this.tooltip[i] b.tooltip = this.tooltip[i]
if this.difficulties[i].disabled then --[[ if this.difficulties[i].disabled then
b.enabled = false b.enabled = false
end end ]]
end end
local b = frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'}) local b = frame.add({type = 'label', caption = '- - - - - - - - - - - - - - - - - -'})
local b = local b =
@ -226,12 +226,6 @@ end
local function on_player_joined_game(event) local function on_player_joined_game(event)
local player = game.players[event.player_index] local player = game.players[event.player_index]
local player_count = #game.connected_players
if player_count >= 20 then
this.difficulties[1].disabled = true
this.tooltip[1] = 'Too many players connected!'
end
if game.tick < this.difficulty_poll_closing_timeout then if game.tick < this.difficulty_poll_closing_timeout then
if not this.difficulty_player_votes[player.name] then if not this.difficulty_player_votes[player.name] then
poll_difficulty(player) poll_difficulty(player)

View File

@ -276,7 +276,7 @@ function Public.extra_settings(player)
one_punch_gui_input.enabled = false one_punch_gui_input.enabled = false
one_punch_gui_input.tooltip = 'Enabled globally.' one_punch_gui_input.tooltip = 'Enabled globally.'
else else
if rpg_t[player.index].level <= 50 then if rpg_t[player.index].level <= 30 then
one_punch_gui_input.enabled = false one_punch_gui_input.enabled = false
one_punch_gui_input.tooltip = 'Level requirement: 30\nChecked = true\nUnchecked = false' one_punch_gui_input.tooltip = 'Level requirement: 30\nChecked = true\nUnchecked = false'
else else

View File

@ -14,9 +14,9 @@ local votejail = {}
local votefree = {} local votefree = {}
local settings = { local settings = {
playtime_for_vote = 25920000, -- 5 days playtime_for_vote = 25920000, -- 5 days
playtime_for_instant_jail = 103680000 -- 20 days playtime_for_instant_jail = 103680000, -- 20 days
votejail_count = 5
} }
local votejail_count = 5
local set_data = Server.set_data local set_data = Server.set_data
local try_get_data = Server.try_get_data local try_get_data = Server.try_get_data
local concat = table.concat local concat = table.concat
@ -231,7 +231,7 @@ local vote_to_jail = function(player, griefer)
votejail[griefer].index = votejail[griefer].index + 1 votejail[griefer].index = votejail[griefer].index + 1
Utils.print_to(player, 'You have voted to jail player ' .. griefer .. '.') Utils.print_to(player, 'You have voted to jail player ' .. griefer .. '.')
if if
votejail[griefer].index >= votejail_count or votejail[griefer].index >= settings.votejail_count or
(votejail[griefer].index == #game.connected_players - 1 and (votejail[griefer].index == #game.connected_players - 1 and
#game.connected_players > votejail[griefer].index) #game.connected_players > votejail[griefer].index)
then then
@ -254,7 +254,7 @@ local vote_to_free = function(player, griefer)
Utils.print_to(player, 'You have voted to free player ' .. griefer .. '.') Utils.print_to(player, 'You have voted to free player ' .. griefer .. '.')
if if
votefree[griefer].index >= votejail_count or votefree[griefer].index >= settings.votejail_count or
(votefree[griefer].index == #game.connected_players - 1 and (votefree[griefer].index == #game.connected_players - 1 and
#game.connected_players > votefree[griefer].index) #game.connected_players > votefree[griefer].index)
then then

View File

@ -4,8 +4,6 @@ local Token = require 'utils.token'
local Server = require 'utils.server' local Server = require 'utils.server'
local Event = require 'utils.event' local Event = require 'utils.event'
local table = require 'utils.table' local table = require 'utils.table'
local Print = require('utils.print_override')
local raw_print = Print.raw_print
local session_data_set = 'sessions' local session_data_set = 'sessions'
local session = {} local session = {}
@ -71,6 +69,7 @@ local try_upload_data =
local new_time = old_time_ingame + player.online_time - online_track[key] local new_time = old_time_ingame + player.online_time - online_track[key]
if new_time <= 0 then if new_time <= 0 then
new_time = old_time_ingame + player.online_time new_time = old_time_ingame + player.online_time
online_track[key] = 0
print('[ERROR] ' .. key .. ' had new time set as negative value: ' .. new_time) print('[ERROR] ' .. key .. ' had new time set as negative value: ' .. new_time)
return return
end end
@ -160,6 +159,21 @@ function Public.get_trusted_table()
return trusted return trusted
end end
--- Clears a given player from the session tables.
-- @param LuaPlayer
function Public.clear_player(player)
local name = player.name
if session[name] then
session[name] = nil
end
if online_track[name] then
online_track[name] = nil
end
if trusted[name] then
trusted[name] = nil
end
end
Event.add( Event.add(
defines.events.on_player_joined_game, defines.events.on_player_joined_game,
function(event) function(event)