This commit is contained in:
2024-09-14 00:18:59 +09:00
parent cd9109f348
commit 9428b7083d
11 changed files with 1052 additions and 1045 deletions

View File

@@ -1,51 +1,19 @@
local items = require 'config'
local function clock_display(sec)
local s = math.floor(sec) % 60
local m = math.floor(sec / 60) % 60
if sec > 3599 then
local h = math.floor(sec / 3600)
return string.format('%d:%02d:%02d', h, m, s)
else
return string.format('%d:%02d', m, s)
end
end
local function trash_creation(event)
local entity = event.created_entity or event.entity
if not entity then
return
end
if not entity.valid then
return
end
if entity.name == 'trash-chest' then
entity.infinity_container_filters = {}
entity.remove_unfiltered_items = true
elseif entity.name == 'trash-pipe' then
entity.set_infinity_pipe_filter(nil)
end
end
local function trash_check()
for _, surface in pairs(game.surfaces) do
for _, e in pairs(surface.find_entities_filtered{name='trash-chest'}) do
e.infinity_container_filters = {}
e.remove_unfiltered_items = true
end
for _, e in pairs(surface.find_entities_filtered{name='trash-pipe'}) do
e.set_infinity_pipe_filter(nil)
end
end
end
if settings.startup['PHI-XC'].value then
local function clock_display(sec)
local s = math.floor(sec) % 60
local m = math.floor(sec / 60) % 60
if sec > 3599 then
local h = math.floor(sec / 3600)
return string.format('%d:%02d:%02d', h, m, s)
else
return string.format('%d:%02d', m, s)
end
end
script.on_nth_tick(60, function(event)
for _, player in pairs(game.connected_players) do
if player.gui.top.phi_clock == nil then
@@ -59,18 +27,18 @@ end
if settings.startup['PHI-PB'].value then
commands.add_command('phi-pb-bonus', nil, function(command)
local player
if command.player_index then
player = game.get_player(command.player_index)
else
game.print('Command Error')
if not command.player_index then
game.print('Command Error - PHI-PB-BONUS')
return
end
local player = game.get_player(command.player_index)
local bonus = tonumber(command.parameter)
if not player then
return
end
if type(bonus) ~= 'number' then
player.print('Parameter need to be number')
return
@@ -97,12 +65,43 @@ if settings.startup['PHI-PB'].value then
end)
end
if settings.startup['PHI-CT'].value then
if settings.startup['PHI-CT-TRASH'].value then
script.on_init(trash_check)
script.on_event(defines.events.on_built_entity, trash_creation, {{filter='name', name='trash-chest', mode='or'}, {filter='name', name='trash-pipe', mode='or'}})
script.on_event(defines.events.on_robot_built_entity, trash_creation, {{filter='name', name='trash-chest', mode='or'}, {filter='name', name='trash-pipe', mode='or'}})
script.on_event(defines.events.script_raised_built, trash_creation)
script.on_event(defines.events.script_raised_revive, trash_creation)
if settings.startup['PHI-CT'].value and settings.startup['PHI-CT-TRASH'].value then
local function trash_creation(event)
local entity = event.created_entity or event.entity
if not entity then
return
end
if not entity.valid then
return
end
if entity.name == 'trash-chest' then
entity.infinity_container_filters = {}
entity.remove_unfiltered_items = true
elseif entity.name == 'trash-pipe' then
entity.set_infinity_pipe_filter(nil)
end
end
local function trash_check()
for _, surface in pairs(game.surfaces) do
for _, e in pairs(surface.find_entities_filtered{name='trash-chest'}) do
e.infinity_container_filters = {}
e.remove_unfiltered_items = true
end
for _, e in pairs(surface.find_entities_filtered{name='trash-pipe'}) do
e.set_infinity_pipe_filter(nil)
end
end
end
script.on_init(trash_check)
script.on_event(defines.events.on_built_entity, trash_creation, {{filter='name', name='trash-chest', mode='or'}, {filter='name', name='trash-pipe', mode='or'}})
script.on_event(defines.events.on_robot_built_entity, trash_creation, {{filter='name', name='trash-chest', mode='or'}, {filter='name', name='trash-pipe', mode='or'}})
script.on_event(defines.events.script_raised_built, trash_creation)
script.on_event(defines.events.script_raised_revive, trash_creation)
end