mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-02-09 13:37:02 +02:00
map ping when chest is unlocked
This commit is contained in:
parent
ca7fd371d1
commit
caba716520
@ -202,7 +202,9 @@ function Public.set_container(expanse, entity)
|
|||||||
|
|
||||||
if #container.price == 0 then
|
if #container.price == 0 then
|
||||||
Public.expand(expanse, container.left_top)
|
Public.expand(expanse, container.left_top)
|
||||||
expanse.containers[entity.unit_number] = nil
|
local a = math.floor(expanse.square_size * 0.5)
|
||||||
|
local expansion_position = {x = expanse.containers[entity.unit_number].left_top.x + a, y = expanse.containers[entity.unit_number].left_top.y + a}
|
||||||
|
expanse.containers[entity.unit_number] = nil
|
||||||
if not inventory.is_empty() then
|
if not inventory.is_empty() then
|
||||||
for name, count in pairs(inventory.get_contents()) do
|
for name, count in pairs(inventory.get_contents()) do
|
||||||
entity.surface.spill_item_stack(entity.position, {name = name, count = count}, true, nil, false)
|
entity.surface.spill_item_stack(entity.position, {name = name, count = count}, true, nil, false)
|
||||||
@ -213,7 +215,7 @@ function Public.set_container(expanse, entity)
|
|||||||
end
|
end
|
||||||
entity.destructible = true
|
entity.destructible = true
|
||||||
entity.die()
|
entity.die()
|
||||||
return
|
return expansion_position
|
||||||
end
|
end
|
||||||
|
|
||||||
for slot = 1, 30, 1 do
|
for slot = 1, 30, 1 do
|
||||||
|
@ -108,22 +108,26 @@ local function on_chunk_generated(event)
|
|||||||
event.surface.set_tiles(tiles, true)
|
event.surface.set_tiles(tiles, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_gui_opened(event)
|
local function container_opened(event)
|
||||||
local entity = event.entity
|
local entity = event.entity
|
||||||
if not entity then return end
|
if not entity then return end
|
||||||
if not entity.valid then return end
|
if not entity.valid then return end
|
||||||
if not entity.unit_number then return end
|
if not entity.unit_number then return end
|
||||||
if entity.force.index ~= 3 then return end
|
if entity.force.index ~= 3 then return end
|
||||||
Functions.set_container(expanse, entity)
|
local expansion_position = Functions.set_container(expanse, entity)
|
||||||
|
if expansion_position then
|
||||||
|
local player = game.players[event.player_index]
|
||||||
|
local colored_player_name = table.concat({"[color=", player.color.r * 0.6 + 0.35, ",", player.color.g * 0.6 + 0.35, ",", player.color.b * 0.6 + 0.35, "]", player.name, "[/color]"})
|
||||||
|
game.print(colored_player_name .. " unlocked new grounds! [gps=" .. math.floor(expansion_position.x) .. "," .. math.floor(expansion_position.y) .. ",expanse]")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_gui_opened(event)
|
||||||
|
container_opened(event)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_gui_closed(event)
|
local function on_gui_closed(event)
|
||||||
local entity = event.entity
|
container_opened(event)
|
||||||
if not entity then return end
|
|
||||||
if not entity.valid then return end
|
|
||||||
if not entity.unit_number then return end
|
|
||||||
if entity.force.index ~= 3 then return end
|
|
||||||
Functions.set_container(expanse, entity)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local ores = {"iron-ore", "iron-ore", "copper-ore", "coal"}
|
local ores = {"iron-ore", "iron-ore", "copper-ore", "coal"}
|
||||||
@ -171,7 +175,7 @@ local function on_player_left_game(event)
|
|||||||
for _ = 1, removed_count, 1 do
|
for _ = 1, removed_count, 1 do
|
||||||
player.surface.spill_item_stack(player.position, {name = "small-plane", count = 1}, false, nil, false)
|
player.surface.spill_item_stack(player.position, {name = "small-plane", count = 1}, false, nil, false)
|
||||||
end
|
end
|
||||||
game.print(player.name .. " dropped their tokens! [gps=" .. math.floor(player.position.x) .. "," .. math.floor(player.position.y) .. "]")
|
game.print(player.name .. " dropped their tokens! [gps=" .. math.floor(player.position.x) .. "," .. math.floor(player.position.y) .. "," .. player.surface.name .. "]")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user