134 lines
5.8 KiB
Lua
134 lines
5.8 KiB
Lua
require("prototypes.mod_compatibility.heroturrets_script") --скрипт разжалования турелей
|
||
require("__PMRPGsystem__/prototypes/test")
|
||
|
||
--###############################################################################################
|
||
-- from some corpse marker
|
||
script.on_event(defines.events.on_pre_player_died, function(event)
|
||
local player = game.players[event.player_index]
|
||
player.force.add_chart_tag(player.surface, {position=player.position, text='Corpse: '..player.name..'; Time: '..math.floor(game.tick/60/60/60)..':'..(math.floor(game.tick/60/60)%60), icon={type="virtual",name="signal-info"}})
|
||
end)
|
||
|
||
if (settings.global["paranoidal-disable-vanilla-evolution"] or {}).value then
|
||
script.on_init(function() game.map_settings.enemy_evolution.enabled = false end)
|
||
end
|
||
--###############################################################################################
|
||
--код из SpilledItems
|
||
if settings.startup["item-drop"].value == true then
|
||
script.on_event(defines.events.on_entity_died, function (event)
|
||
-- on_entity_died
|
||
-- Called when an entity dies. Can be filtered using LuaEntityDiedEventFilters
|
||
|
||
-- Contains
|
||
-- entity :: LuaEntity
|
||
-- cause :: LuaEntity (optional): The entity that did the killing if available.
|
||
-- loot :: LuaInventory: The loot generated by this entity if any.
|
||
-- force :: LuaForce (optional): The force that did the killing if any.
|
||
-- damage_type :: LuaDamagePrototype (optional): The damage type if any.
|
||
local entity = event.entity
|
||
local surface = entity.surface
|
||
local position = entity.position
|
||
|
||
local inventories = {}
|
||
table.insert (inventories, entity.get_inventory(defines.inventory.chest))
|
||
-- print ('defines.inventory.chest' .. defines.inventory.chest)
|
||
table.insert (inventories, entity.get_inventory(defines.inventory.car_trunk))
|
||
-- print ('defines.inventory.car_trunk' .. defines.inventory.car_trunk)
|
||
table.insert (inventories, entity.get_inventory(defines.inventory.turret_ammo))
|
||
-- print ('defines.inventory.turret_ammo' .. defines.inventory.turret_ammo)
|
||
|
||
table.insert (inventories, entity.get_output_inventory())
|
||
|
||
table.insert (inventories, entity.get_module_inventory())
|
||
|
||
table.insert (inventories, entity.get_fuel_inventory())
|
||
|
||
table.insert (inventories, entity.get_burnt_result_inventory())
|
||
|
||
|
||
local grid = entity.grid -- LuaEquipmentGrid
|
||
if grid then
|
||
local equipments = grid.equipment -- array of LuaEquipment [R]
|
||
for i, equipment in pairs (equipments) do
|
||
local prototype = equipment.prototype -- LuaEquipmentPrototype [Read-only]
|
||
local item_prototype = prototype.take_result -- LuaItemPrototype [Read-only]
|
||
local name = item_prototype.name
|
||
surface.spill_item_stack(position, {name = name, count=1})
|
||
end
|
||
grid.clear() -- not for other mods
|
||
end
|
||
|
||
for i, inventory in pairs (inventories) do
|
||
for j = 1, #inventory do
|
||
local item_stack = inventory[j]
|
||
if item_stack and item_stack.valid_for_read then
|
||
if item_stack.grid then
|
||
surface.spill_item_stack(position, item_stack)
|
||
else
|
||
local prototype = item_stack.prototype
|
||
local stack_size = prototype.stack_size
|
||
local name = item_stack.name
|
||
local count = item_stack.count
|
||
-- if count >= stack_size then
|
||
-- surface.create_entity{name="item-on-ground",
|
||
-- position=position,
|
||
-- stack={name=name, count=count}}
|
||
-- else -- I want to split count by stacks, but not today
|
||
surface.spill_item_stack(position, {name=name, count=count})
|
||
-- end
|
||
end
|
||
item_stack.clear()
|
||
end
|
||
end
|
||
|
||
inventory.clear() -- not for other mods
|
||
end
|
||
end)
|
||
end
|
||
--###############################################################################################
|
||
--############################## Все ресурсы х5 на дефолт настройках
|
||
|
||
-- Список имен ресурсов, которые вы хотите изменить
|
||
local resourceNames = {"angels-ore1", "angels-ore2", "coal", "angels-ore3","angels-ore4","angels-ore5","angels-ore6","angels-natural-gas", "crude-oil" }
|
||
|
||
if settings.startup["newbie_resourse"].value == true then
|
||
-- Обработчик события on_chunk_generated
|
||
script.on_event(defines.events.on_chunk_generated, function(event)
|
||
-- Проверяем, что это именно генерация ресурсов
|
||
if event.surface.name == "nauvis" then
|
||
-- Изменяем настройки генерации ресурсов в чанках
|
||
for _, entity in pairs(event.surface.find_entities_filtered{area = event.area}) do
|
||
-- Проверяем, является ли сущность ресурсом
|
||
if isResource(entity.name, resourceNames) then
|
||
if entity.amount * 5 >= 4294967294 then
|
||
entity.amount = 4294967294
|
||
else
|
||
entity.amount = entity.amount * 5 -- Увеличьте количество ресурсов в чанке
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end)
|
||
|
||
-- Функция для проверки, является ли имя сущности ресурсом
|
||
function isResource(name, resourceNames)
|
||
for _, resourceName in ipairs(resourceNames) do
|
||
if name == resourceName then
|
||
return true
|
||
end
|
||
end
|
||
return false
|
||
end
|
||
end
|
||
--###############################################################################################
|
||
|
||
--############################## Скрипт для удаления лишнего окна в Gui Unifer
|
||
script.on_event(defines.events.on_built_entity, function(event)
|
||
myVariable = myVariable + 1
|
||
if myVariable <= 5 then
|
||
for _, player in pairs(game.players) do
|
||
if player.gui.top.mod_gui_top_frame and player.gui.top.mod_gui_top_frame.children[1] and player.gui.top.mod_gui_top_frame.children[1].random then
|
||
player.gui.top.mod_gui_top_frame.children[1].random.destroy()
|
||
end
|
||
end
|
||
end
|
||
end) |