1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00

Merge pull request #3 from ComfyFactory/planet_prison_fix_v2

more changes to planet prison
This commit is contained in:
Gerkiz 2021-03-21 23:57:13 +01:00 committed by GitHub
commit f1adda1f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 40 deletions

View File

@ -315,30 +315,11 @@ local function init_game()
Blueprints.set_blueprint_hook('merchant', init_merchant_bp)
end
local explode_ship_update =
Token.register(
function(data)
local ship = data.ship
local id = data.id
local time_left = data.time_left
for _, ent in pairs(ship.entities) do
if not ent.valid then
return false
end
end
rendering.set_text(id, CommonFunctions.get_time(time_left))
return true
end
)
local explode_ship =
Token.register(
function(data)
local ship = data.ship
local id = data.id
local surface = data.surface
local time_left = data.time_left
for _, ent in pairs(Blueprints.reference_get_entities(ship)) do
if not ent.valid then
goto continue
@ -356,9 +337,6 @@ local explode_ship =
local bb = Blueprints.reference_get_bounding_box(ship)
LayersFunctions.remove_excluding_bounding_box(bb)
Blueprints.destroy_reference(surface, ship)
rendering.destroy(id)
Task.set_timeout_in_ticks(60, explode_ship_update, {time_left = time_left, ship = ship})
Task.start_queue()
end
)
@ -371,22 +349,9 @@ local function do_spawn_point(player)
LayersFunctions.push_excluding_bounding_box(instance.bb)
local time_left = MapConfig.self_explode
local object = {
text = CommonFunctions.get_time(time_left),
surface = player.surface,
color = {
r = 255,
g = 20,
b = 20
},
target = {
x = point.x - 2,
y = point.y - 3
},
scale = 2.0
}
Task.set_timeout_in_ticks(60, explode_ship, {time_left = time_left, ship = instance, id = rendering.draw_text(object), surface = player.surface})
Task.set_timeout_in_ticks(60, explode_ship, {time_left = time_left, ship = instance, surface = player.surface})
Task.start_queue()
end
local function get_non_obstructed_position(s, radius)
@ -573,8 +538,8 @@ local function on_gui_click(e)
else
perks.flashlight_enable = true
if p.character and p.character.valid then
p.character.enable_flashlight()
end
p.character.enable_flashlight()
end
end
elseif elem.name == 'merchant_find' then
print_merchant_position(p)

View File

@ -285,7 +285,9 @@ local function _build_entities(surf, point, entities, hook, args)
if hook then
local token = Token.get(hook)
token(e, args)
if token then
token(e, args)
end
end
table.insert(_entities, e)

View File

@ -123,6 +123,9 @@ local function _do_job_entity(surf, layer)
return
end
func = Token.get(func)
if not func then
return
end
local deps = layer.deps
if not deps then
return